Skip to content

Commit

Permalink
Multiple changes to get the addon working with the new release of the…
Browse files Browse the repository at this point in the history
… viewer.
  • Loading branch information
sjthespian committed Nov 1, 2020
1 parent a1e6fdd commit 01b8b44
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 19 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

## [0.3] - 2020-10-27
### Added
- Added missing python modules for latest Z-Wave Network Viewer [\#1](https://github.com/sjthespian/addon-zwave-network-viewer/issues/1)
- Added and updated configuration settings to match updates to the viewer, including adding the HA url, a long-lived access token, ssl support and configuration of the debug parameter

### Changed
- Upgraded to version 8.0.5 of the addon base image

### Removed
- Ingress support. It will not work with SSL and was not working properly with the latest version of the viewer even with SSL disabled. The "Open Web UI" link will now open the viewer in a separate window or tab, and it is no longer an option to put it in the sidebar.

### Notes
- Unlike earlier versions of this addon, it now requires configuration due to changes in the [Z-Wave Network Vieweer][zwave-network-viewer] itself. See the [documentation](DOCS.md) for more information.

## [0.2] - 2020-07-31
### Added
Expand Down
42 changes: 41 additions & 1 deletion DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,47 @@ Follow these steps to get the add-on installed on your system:

## Configuration

No configuration required
At a minimum the Home Assistant URL and a long-lived access token must be specified.

```
haurl: https://homeassistant.example.com:8123
token: 123456789abcdef
ssl: false
certfile: fullchain.pem
keyfile: privkey.pem
debug: false
```

### Option: haurl

The URL of your Home Assistant instance. If you do not have a DNS entry that resolves for it, use the IP.

Example:
```
haurl: https:192.168.0.10:8123
```

### Option: token

A long-lived authentication token to access HA. This can be created by clicking on your profile icon in the HA web interface and scrolling down to the bottom. Select "CREATE TOKEN" under the "Long-Lived Access Tokens" section.

***NOTE: You will only be able to see the token when you generate it. Save this token in a safe place as you will have to create a new one if you lose it.***

### Option: ssl

Set to true to enable SSL support in the viewer.

### Option: certfile

A file containing a certificate, including its chain. Leave empty to disable SSL.

### Option: keytfile

A file containing the private key. Leave empty to disable SSL.

### Option: debug

Set to true to enable debugging output in the logs

## Known issues and limitations

Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@ RUN apk add --no-cache \
build-base \
python3-dev \
git \
libffi-dev openssl-dev \
# ha-zwave-network
&& git clone --depth=1 https://github.com/elad-bar/ha-zwave-network.git \
&& cd ha-zwave-network \
&& pip install --no-cache-dir requests flask aiofiles asyncws \
&& pip install --no-cache-dir requests asyncws aiofiles flask pyopenssl \
&& mkdir -p /web \
&& find . -print | sed '/.git|Dockerfile/d' | cpio -pvdm / \
&& apk del .build-deps \
&& cd .. \
&& rm -rf /usr/src/ha-zwave-network.git
&& rm -rf /usr/src/ha-zwave-network.git \
&& mkdir /debug

COPY data/run.sh /

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ An addon for the [Z-Wave Network Viewer][zwave-network-viewer] application. It i

## About

For more information about the Z-Wave Network Viewer and how to use it, please see the [Z-Wave Network Vieweer][zwave-network-viewer]
For more information about the Z-Wave Network Viewer and how to use it, please see the [Z-Wave Network Vieweer][zwave-network-viewer]. The viewer will be available at http[s]://<your home assistant server name or ip>:6123/ by default. You can change the port number in the configuration.

***NOTE: Unlike earlier versions of this addon, it now requires configuration due to changes in the [Z-Wave Network Vieweer][zwave-network-viewer] itself. See the [documentation](DOCS.md) for more information.***

## Known issues and limitations

Expand Down
8 changes: 4 additions & 4 deletions build.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"squash": false,
"build_from": {
"aarch64": "hassioaddons/base-aarch64:8.0.1",
"amd64": "hassioaddons/base-amd64:8.0.1",
"armhf": "hassioaddons/base-armhf:8.0.1",
"armv7": "hassioaddons/base-armv7:8.0.1",
"i386": "hassioaddons/base-i386:8.0.1"
"amd64": "hassioaddons/base-amd64:8.0.5",
"armhf": "hassioaddons/base-armhf:8.0.5",
"armv7": "hassioaddons/base-armv7:8.0.5",
"i386": "hassioaddons/base-i386:8.0.5"
},
"args": {}
}
23 changes: 19 additions & 4 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,37 @@
"boot": "auto",
"description": "Visualization tool for the Z-Wave network",
"homeassistant_api": true,
"ingress": true,
"ingress": false,
"ingress_port": 6123,
"map": ["ssl"],
"name": "Z-Wave Network Viewer",
"options": {},
"options": {
"haurl": "https://homeassistant.local.hass.io:8123",
"token": "",
"ssl": false,
"certfile": "fullchain.pem",
"keyfile": "privkey.pem",
"debug": false
},
"panel_icon": "mdi:z-wave",
"ports": {
"6123/tcp": 6123
},
"ports_description": {
"6132/tcp": "Web interface Z-Wave Network Viewer"
},
"schema": {},
"schema": {
"haurl": "url",
"token": "password",
"ssl": "bool",
"certfile": "str",
"keyfile": "str",
"debug": "bool"
},
"slug": "zwavenetworkviewer",
"stage": "experimental",
"startup": "services",
"url": "https://github.com/sjthespian/addon-zwave-network-viewer",
"version": "0.2",
"version": "0.3",
"webui": "[PROTO:ssl]://[HOST]:[PORT:6123]"
}
50 changes: 43 additions & 7 deletions data/run.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,48 @@
#!/usr/bin/env bashio

# Build config file from options
CONFIG_PATH=/data/options.json
# Validate config
err=0
if ! bashio::config.has_value 'token'; then
bashio::log.fatal
bashio::log.fatal "Add-on configuration is incomplete!"
bashio::log.fatal
bashio::log.fatal "No token value was specified. You must create a long-lived"
bashio::log.fatal "access token and add it to the configuration"
bashio::log.fatal
err=1
fi
if ! bashio::config.has_value 'haurl'; then
bashio::log.fatal
bashio::log.fatal "Add-on configuration is incomplete!"
bashio::log.fatal
bashio::log.fatal "The HA URL value was not specified. You must add the URL"
bashio::log.fatal "for your Home Assistant server to the configuration"
bashio::log.fatal
err=1
fi
if [ "$err" != 0 ]; then
bashio::exit.nok
fi

# Get config valuesj
#export HA_TOKEN="$(bashio::config 'token')"
export HA_TOKEN=${SUPERVISOR_TOKEN}
export HA_URL="http://supervisor/core"
# Get config values
export HA_URL=$(bashio::config 'haurl')
export HA_URL=$(echo $HA_URL | sed 's/\/$//') # strip trailing slash
export HA_TOKEN=$(bashio::config 'token')
export SSL_KEY=""
export SSL_CERTIFICATE=""
# Only enable ssl support if ssl is enabled
if [ $(bashio::config 'ssl') == "true" ]; then
bashio::log.info "Enabling SSL support"
export SSL_KEY=/ssl/$(bashio::config 'keyfile')
export SSL_CERTIFICATE=/ssl/$(bashio::config 'certfile')
# Output a warning if the cert or keyfile is not found
if [ ! -f $SSL_KEY -o ! -f $SSL_CERTIFICATE ]; then
bashio::log.warn "SSL certificate and/or key not found, disabling SSL support"
fi
fi
export SERVER_PORT=$(bashio::addon.port 6123)
export DEBUG=$(bashio::config 'debug')
export LOCAL=false

bashio::log.info "Start HA Z-Wave Network Viewer"
bashio::log.info "Starting HA Z-Wave Network Viewer on port ${SERVER_PORT}"
python3 webserver.py

0 comments on commit 01b8b44

Please sign in to comment.