diff --git a/zwave/CHANGELOG.md b/zwave/CHANGELOG.md index 50abbf8..6ab5f62 100644 --- a/zwave/CHANGELOG.md +++ b/zwave/CHANGELOG.md @@ -1,104 +1,108 @@ -# Changelog - -## 0.8.0 - -- Update OpenZWave to 66619ed -- Update ozw-admin to f68b43e - - -## 0.7.1 - -- Fix timezone issue on Alpine - -## 0.7.0 - -- Fix vnc / ozwadmin -- Update Openzwave to 1c7b620 -- Update qt-openzwave to 7ebd43e2 - -## 0.6.0 - -- Fix vnc / ozwadmin - -## 0.5.4 - -- Fix build issues with 32bit CPU - -## 0.5.3 - -- Update Openzwave to 7eaae21 - -## 0.5.2 - -- Fix startup failure due to stray OZW Daemon status retained in MQTT -- Propagate shutdown OZW Daemon status to upstream MQTT on shutdown -- Update OpenZWave to 6cf3729 - -## 0.5.1 - -- Roll-back alpine to 3.11 and qt 5.12 -- Roll-back OpenZWave to 6c2ca613 - -## 0.5.0 - -- Update OpenZWave to 5d3978d5 -- Update ozw-admin to da04ebfb -- Update qt-openzwave to 3ad9138f -- Update alpine to 3.12 - -## 0.4.4 - -- Update OpenZWave to a35732f -- Update ozw-admin to 278427b - -## 0.4.3 - -- Update OpenZWave to 6cec95b -- Update ozw-admin to 167180c - -## 0.4.2 - -- Improve error message when using documented network_key - -## 0.4.1 - -- Fix optional instance parameter - -## 0.4.0 - -- Add OZW instance ID configuration option -- Fix persistent storage of OpenZWave -- Fix permissions on discovery script -- Fix OZW database location -- Improve build speed by using all available cores -- Add built-in ozw-admin -- Add VNC access to add-on to access ozw-admin -- Add Ingress support to add-on to access ozw-admin -- Documentation improvements -- Update OpenZWave (and database) to d2de699 -- Update ozwdaemon to 337e488 -- Add logo and icon -- Detect use of example network key from documentation - -## 0.3.0 - -- Add port to allow ozw-admin to connect -- Enable discovery again -- Set network key default to empty - -## 0.2.1 - -- Disable discovery for 0.110.0 - -## 0.2.0 - -- Update OZW / QTOZW -- Rename `zwave_mqtt` to `ozw` - -## 0.1.1 - -- Fix i386 build - -## 0.1.0 - -- Initial release +# Changelog + +## 0.9.0 + +- Update OpenZWave to ee90c89 +- Cleanup permissions + +## 0.8.0 + +- Update OpenZWave to 66619ed +- Update ozw-admin to f68b43e + +## 0.7.1 + +- Fix timezone issue on Alpine + +## 0.7.0 + +- Fix vnc / ozwadmin +- Update Openzwave to 1c7b620 +- Update qt-openzwave to 7ebd43e2 + +## 0.6.0 + +- Fix vnc / ozwadmin + +## 0.5.4 + +- Fix build issues with 32bit CPU + +## 0.5.3 + +- Update Openzwave to 7eaae21 + +## 0.5.2 + +- Fix startup failure due to stray OZW Daemon status retained in MQTT +- Propagate shutdown OZW Daemon status to upstream MQTT on shutdown +- Update OpenZWave to 6cf3729 + +## 0.5.1 + +- Roll-back alpine to 3.11 and qt 5.12 +- Roll-back OpenZWave to 6c2ca613 + +## 0.5.0 + +- Update OpenZWave to 5d3978d5 +- Update ozw-admin to da04ebfb +- Update qt-openzwave to 3ad9138f +- Update alpine to 3.12 + +## 0.4.4 + +- Update OpenZWave to a35732f +- Update ozw-admin to 278427b + +## 0.4.3 + +- Update OpenZWave to 6cec95b +- Update ozw-admin to 167180c + +## 0.4.2 + +- Improve error message when using documented network_key + +## 0.4.1 + +- Fix optional instance parameter + +## 0.4.0 + +- Add OZW instance ID configuration option +- Fix persistent storage of OpenZWave +- Fix permissions on discovery script +- Fix OZW database location +- Improve build speed by using all available cores +- Add built-in ozw-admin +- Add VNC access to add-on to access ozw-admin +- Add Ingress support to add-on to access ozw-admin +- Documentation improvements +- Update OpenZWave (and database) to d2de699 +- Update ozwdaemon to 337e488 +- Add logo and icon +- Detect use of example network key from documentation + +## 0.3.0 + +- Add port to allow ozw-admin to connect +- Enable discovery again +- Set network key default to empty + +## 0.2.1 + +- Disable discovery for 0.110.0 + +## 0.2.0 + +- Update OZW / QTOZW +- Rename `zwave_mqtt` to `ozw` + +## 0.1.1 + +- Fix i386 build + +## 0.1.0 + +- Initial release diff --git a/zwave/build.json b/zwave/build.json index e6dec4c..f6e8808 100644 --- a/zwave/build.json +++ b/zwave/build.json @@ -7,7 +7,7 @@ "aarch64": "homeassistant/aarch64-base:3.11" }, "args": { - "OZW_VERSION": "66619eda6caaf2b41d07d68672efa7170f6c4722", + "OZW_VERSION": "ee90c896c137b3a473232565c45a51d70c41c431", "QTOZW_VERSION": "7ebd43e246e97851ad20f2b1bb9c62bfd6a4a6ef", "QTOZWADMIN_VERSION": "f68b43ec162f6eb59173710e00b1f1aa192ce373", "QTMQTT_VERSION": "5.12.8", diff --git a/zwave/config.json b/zwave/config.json index 71e562d..61deba0 100644 --- a/zwave/config.json +++ b/zwave/config.json @@ -1,6 +1,6 @@ { "name": "OpenZWave", - "version": "0.8.0", + "version": "0.9.0", "slug": "zwave", "description": "Control a ZWave network with Home Assistant", "arch": ["amd64", "i386", "armhf", "armv7", "aarch64"], @@ -25,10 +25,6 @@ "services": ["mqtt:want"], "discovery": ["ozw"], "auto_uart": true, - "gpio": true, - "apparmor": false, - "privileged": ["SYS_RAWIO"], - "devices": ["/dev/bus/usb:/dev/bus/usb:rwm", "/dev/mem:/dev/mem:rw"], "options": { "device": null, "network_key": "" diff --git a/zwave_js/CHANGELOG.md b/zwave_js/CHANGELOG.md new file mode 100644 index 0000000..931929c --- /dev/null +++ b/zwave_js/CHANGELOG.md @@ -0,0 +1,5 @@ +# Changelog + +## 0.1.0 + +- Inital release diff --git a/zwave_js/DOCS.md b/zwave_js/DOCS.md new file mode 100644 index 0000000..224b77d --- /dev/null +++ b/zwave_js/DOCS.md @@ -0,0 +1,107 @@ +# Home Assistant Add-on: Z-Wave JS + +## Installation + +Follow these steps to get the add-on installed on your system: + +1. Navigate in your Home Assistant frontend to **Supervisor** -> **Add-on Store**. +2. Find the "Z-Wave JS" add-on and click it. +3. Click on the "INSTALL" button. + +## How to use + +The add-on needs to know where your Z-Wave stick can be found, and therefore, +you'll need to configure the add-on to point to the right device. + +If you're using Home Assistant you may find the correct value for this on the +`Supervisor -> System -> Host system -> Hardware` page. It is recommended +to use a "by-id" path to the device if one exists, as it is not subject to +change if other devices are added to the system. + +1. Replace `null` in the `device` option in the add-on configuration and specify + the device name in quotes: e.g., something like + `"/dev/serial/by-id/usb-0658_0200-if00"`, + `"/dev/ttyUSB0"`, `"/dev/ttyAMA0"`, or `"/dev/ttyACM0"`. +2. Set your 16-byte network key in the form `0x01, 0x02...` used in order to + connect securely to compatible devices. It is recommended that a network key + is configured as security enabled devices may not function correctly if they + are not added securely. +3. Click on "SAVE" to save the add-on configuration. +4. Start the add-on. +5. Add the Z-Wave JS integration to Home Assistant, see documentation: + + + +## Configuration + +Add-on configuration: + +```yaml +device: /dev/ttyUSB0 +network_key: 2232666D100F795E5BB17F0A1BB7A146 +``` + +### Option `device` + +The device address of your Z-Wave controller. + +If you're using Home Assistant you may find the correct value for this on the +`Supervisor -> System -> Host system -> Hardware` page. It is recommended +to use a "by-id" path to the device if one exists, as it is not subject to +change if other devices are added to the system. + +In most cases this looks like one of the following: + +- `"/dev/serial/by-id/usb-0658_0200-if00"` +- `"/dev/ttyUSB0"` +- `"/dev/ttyAMA0"` +- `"/dev/ttyACM0"` + +### Option `network_key` + +Security Z-Wave devices require a network key before being added to the network. +You must set the `network_key` configuration option to use a network key before +adding these devices. + +If you don't add an network key, it will autogenerate this for you. + +To generate a network key manual, you can use the following script in, e.g., the SSH +add-on: + +```bash +hexdump -n 16 -e '4/4 "%08X" 1 "\n"' /dev/random +``` + +You can also use sites like this one to generate the required data: + + + +Ensure you keep a backup of this key. If you have to rebuild your system and +don't have a backup of this key, you won't be able to reconnect to any security +devices. This may mean you have to do a factory reset on those devices, and your +controller, before rebuilding your Z-Wave network. + +### Option `emulate_hardware` (optional) + +If you don't have a USB stick, you can use a fake stick. + +## Known issues and limitations + +- Your hardware needs to be compatible with Z-Wave JS library + +## Support + +Got questions? + +You have several options to get them answered: + +- The [Home Assistant Discord Chat Server][discord]. +- The Home Assistant [Community Forum][forum]. +- Join the [Reddit subreddit][reddit] in [/r/homeassistant][reddit] + +In case you've found a bug, please [open an issue on our GitHub][issue]. + +[discord]: https://discord.gg/c5DvZ4e +[forum]: https://community.home-assistant.io +[issue]: https://github.com/home-assistant/hassio-addons/issues +[reddit]: https://reddit.com/r/homeassistant diff --git a/zwave_js/Dockerfile b/zwave_js/Dockerfile new file mode 100644 index 0000000..4a7a13b --- /dev/null +++ b/zwave_js/Dockerfile @@ -0,0 +1,26 @@ +ARG BUILD_FROM +FROM ${BUILD_FROM} + +ARG ZWAVEJS_SERVER_VERSION + +# Install Z-Wave JS +WORKDIR /usr/src +RUN \ + set -x \ + && apk add --no-cache \ + nodejs \ + npm \ + && apk add --no-cache --virtual .build-dependencies \ + build-base \ + git \ + linux-headers \ + python3 \ + \ + && npm config set unsafe-perm \ + && npm install -g @zwave-js/server@${ZWAVEJS_SERVER_VERSION} \ + \ + && apk del --no-cache \ + .build-dependencies + +WORKDIR / +COPY rootfs / diff --git a/zwave_js/README.md b/zwave_js/README.md new file mode 100644 index 0000000..395ff0c --- /dev/null +++ b/zwave_js/README.md @@ -0,0 +1,12 @@ +# Home Assistant Add-on: Z-Wave JS + +Allow Home Assistant to talk to a Z-Wave Network via a USB Controller. + +![Supports aarch64 Architecture][aarch64-shield] ![Supports amd64 Architecture][amd64-shield] ![Supports armhf Architecture][armhf-shield] ![Supports armv7 Architecture][armv7-shield] ![Supports i386 Architecture][i386-shield] + + +[aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg +[amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg +[armhf-shield]: https://img.shields.io/badge/armhf-yes-green.svg +[armv7-shield]: https://img.shields.io/badge/armv7-yes-green.svg +[i386-shield]: https://img.shields.io/badge/i386-yes-green.svg diff --git a/zwave_js/build.json b/zwave_js/build.json new file mode 100644 index 0000000..d7ad9b6 --- /dev/null +++ b/zwave_js/build.json @@ -0,0 +1,12 @@ +{ + "build_from": { + "amd64": "homeassistant/amd64-base:3.13", + "i386": "homeassistant/i386-base:3.13", + "armhf": "homeassistant/armhf-base:3.13", + "armv7": "homeassistant/armv7-base:3.13", + "aarch64": "homeassistant/aarch64-base:3.13" + }, + "args": { + "ZWAVEJS_SERVER_VERSION": "1.0.0-alpha.4" + } +} diff --git a/zwave_js/config.json b/zwave_js/config.json new file mode 100644 index 0000000..44568d3 --- /dev/null +++ b/zwave_js/config.json @@ -0,0 +1,30 @@ +{ + "name": "Z-Wave JS", + "version": "0.1.0", + "slug": "zwave_js", + "description": "Control a ZWave network with Home Assistant Z-Wave JS", + "arch": ["amd64", "i386", "armhf", "armv7", "aarch64"], + "url": "https://github.com/home-assistant/hassio-addons/tree/master/zwave_js", + "startup": "services", + "init": false, + "stage": "experimental", + "homeassistant": "2021.2.0.dev20210118", + "ports": { + "3000/tcp": null + }, + "ports_description": { + "3000/tcp": "Z-Wave JS communication" + }, + "discovery": ["zwave_js"], + "auto_uart": true, + "options": { + "device": null, + "network_key": "" + }, + "schema": { + "device": "str", + "network_key": "password", + "emulate_hardware": "bool?" + }, + "image": "homeassistant/{arch}-addon-zwave_js" +} diff --git a/zwave_js/icon.png b/zwave_js/icon.png new file mode 100644 index 0000000..65dfc13 Binary files /dev/null and b/zwave_js/icon.png differ diff --git a/zwave_js/logo.png b/zwave_js/logo.png new file mode 100644 index 0000000..6f55d12 Binary files /dev/null and b/zwave_js/logo.png differ diff --git a/zwave_js/rootfs/etc/cont-init.d/config.sh b/zwave_js/rootfs/etc/cont-init.d/config.sh new file mode 100644 index 0000000..6f07a9d --- /dev/null +++ b/zwave_js/rootfs/etc/cont-init.d/config.sh @@ -0,0 +1,40 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Generate Z-Wave JS config file +# ============================================================================== +declare network_key + +readonly DOCS_EXAMPLE_KEY="2232666D100F795E5BB17F0A1BB7A146" + +if [[ "${DOCS_EXAMPLE_KEY}" == "$(bashio::config 'network_key')" ]]; then + bashio::log.fatal + bashio::log.fatal 'The add-on detected that the Z-Wave network key used' + bashio::log.fatal 'is from the documented example.' + bashio::log.fatal + bashio::log.fatal 'Using this key is insecure, because it is publicly' + bashio::log.fatal 'listed in the documentation.' + bashio::log.fatal + bashio::log.fatal 'Please check the add-on documentation on how to' + bashio::log.fatal 'create your own, secret, "network_key" and replace' + bashio::log.fatal 'the one you have configured.' + bashio::log.fatal + bashio::log.fatal 'Click on the "Documentation" tab in the Z-Wave JS' + bashio::log.fatal 'add-on panel for more information.' + bashio::log.fatal + bashio::exit.nok +elif ! bashio::config.has_value 'network_key'; then + bashio::log.info "No Network Key is set, generate one..." + network_key=$(hexdump -n 16 -e '4/4 "%08X" 1 "\n"' /dev/random) + bashio::addon.option network_key "${network_key}" +else + network_key=$(bashio::config 'network_key') +fi + + +# Generate config +bashio::var.json \ + network_key "${network_key}" \ + logging "$(bashio::info.logging)" \ + | tempio \ + -template /usr/share/tempio/zwave_config.conf \ + -out /etc/zwave_config.json diff --git a/zwave_js/rootfs/etc/cont-init.d/structure.sh b/zwave_js/rootfs/etc/cont-init.d/structure.sh new file mode 100644 index 0000000..9be2e0c --- /dev/null +++ b/zwave_js/rootfs/etc/cont-init.d/structure.sh @@ -0,0 +1,5 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Setup folder structure +# ============================================================================== +mkdir -p /data/cache diff --git a/zwave_js/rootfs/etc/services.d/zwave_js/discovery b/zwave_js/rootfs/etc/services.d/zwave_js/discovery new file mode 100755 index 0000000..a9acd83 --- /dev/null +++ b/zwave_js/rootfs/etc/services.d/zwave_js/discovery @@ -0,0 +1,18 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Send zwave_js discovery information to Home Assistant +# ============================================================================== +declare ha_config + +# Prepare discovery payload +ha_config=$(\ + bashio::var.json \ + host "$(hostname)" \ + port "^3000" \ +) + +if bashio::discovery "zwave_js" "${ha_config}" > /dev/null; then + bashio::log.info "Successfully send discovery information to Home Assistant." +else + bashio::log.error "Discovery message to Home Assistant failed!" +fi diff --git a/zwave_js/rootfs/etc/services.d/zwave_js/finish b/zwave_js/rootfs/etc/services.d/zwave_js/finish new file mode 100644 index 0000000..d886e9f --- /dev/null +++ b/zwave_js/rootfs/etc/services.d/zwave_js/finish @@ -0,0 +1,8 @@ +#!/usr/bin/execlineb -S1 +# ============================================================================== +# Take down the S6 supervision tree when Z-Wave JS fails +# ============================================================================== +if { s6-test ${1} -ne 0 } +if { s6-test ${1} -ne 256 } + +s6-svscanctl -t /var/run/s6/services diff --git a/zwave_js/rootfs/etc/services.d/zwave_js/run b/zwave_js/rootfs/etc/services.d/zwave_js/run new file mode 100644 index 0000000..f283830 --- /dev/null +++ b/zwave_js/rootfs/etc/services.d/zwave_js/run @@ -0,0 +1,16 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Start Z-Wave JS service for Z-Wave radio +# ============================================================================== +SERIAL_DEVICE=$(bashio::config 'device') + +# Emulate serial Hardware for test & development +if bashio::config.true 'emulate_hardware'; then + SERIAL_DEVICE="--mock" +fi + +# Send out discovery information to Home Assistant +./discovery & + +# Run daemon +exec zwave-server ${SERIAL_DEVICE} --config /etc/zwave_config.json diff --git a/zwave_js/rootfs/usr/share/tempio/zwave_config.conf b/zwave_js/rootfs/usr/share/tempio/zwave_config.conf new file mode 100644 index 0000000..bb7487f --- /dev/null +++ b/zwave_js/rootfs/usr/share/tempio/zwave_config.conf @@ -0,0 +1,12 @@ +{ + "logConfig": { + "enabled": true, + "level": {{ if eq .logging "debug" }}5{{ else }}2{{ end }}, + "forceConsole": true + }, + "storage": { + "cacheDir": "/data/cache", + "throttle": "slow" + }, + "networkKey": "{{ .network_key }}" +}