How to set up ZWavejs2MQTT on a Raspberry Pi and integrate it with Home-Assistant

Please include the full text in the first post. That way if you go AWOL and the guide becomes out of date it can be edited by anyone to correct it.

Do I need to write a Community Guide on how to write a Community Guide?

1 Like

I noticed there was a statement on migration and network/secure key…thought I would add my experience. For anyone migrating from zwave2mqtt to zwavejs2mqtt the network key of the former uses hex notation 0x and comma separated list of bytes, whereas the latter removes the 0x hex notation and concatenates the bytes together. So just a little hand editing should work.

@flemmingss, Thanks for the share! :slight_smile:

I mean… could you? :joy:
When I wrote up my HassOS USB boot guide I kind of wished there was like, a best practices guide or something, but couldn’t find one. Could help trim the rambling ones like mine :joy::wink:

I would like to try this too - but not just yet - please let us know how you get on and maybe a brief set of notes on what you had to do that was different to the blog post.

Many thanks for your guide. I used your instructions and was able to get zwavejs2mqtt working. It’s apparently a WIP, but already seem to work better than the 2 other previous methods…
Having tried several other home automation systems, I fail to understand why HA developers always seem to prefer adding additional layers to make things work.
Other home automation systems have perfectly working zwave integration WITHOUT mqtt. And it’s also faster on other home automation systems. I’m trying REALLY hard to like HA, but the added complexity in insisting in using docker containers and intermediary layers makes me wonder…
I may be wrong, but I don’t think most home automation enthusiasts are willing to get a degree on software development in order to finally be able to USE their systems. The added complexity caused by additional layers make even the simplest thing hard or cumbersome enough to turn away a lot of potential users. Just my 2 cents.

Hi, interesting! Will this work with ubuntu server 20 as well? And what about future upgrades of the container, is that possible.

FWIW, the implementation of zwaveJS that is being worked into HomeAssistant Core talks to the Z-Wave Driver using web sockets, so it is a reduction of layers (no broker in between the two) when it is released.

Re the docket containers issue, it’s to make sure updating or changing one platform’s software doesn’t effect the other. Prior to using HomeAssistant, most of my time trying to smarten up my home was spent resolving conflicts between different platform’s software requirements.
Updating the software I used to track my TVs state and control it would often require updating stuff like python, avahi and other frameworks like that which other control software, such as for my air conditioner and smart plugs, also used, and sometimes those shared resources being updated would break compatibility with other control software that hadn’t had an update in a while. I broke Z-Way’s networking at least twice trying to get control of my PlayStation into my old system.

So while it looks messy and complex from the outside, a lot of work is done frequently to use these things like docker to make less of those issues need solving by users. I do miss some of the more fine tuned control I used to have over the whole system, but that’s easily outweighed by how much less effort it takes me to get my devices working together.

And for those interested, Home Assistant Provides a lot of good and varied examples of working docker configurations to learn from. I’ve massively improved my understanding of containerisation since using HA compared to my attempts to figure it out on my own previously.

Hope this maybe answers some of your wondering about why HA is laid out the way it is. All anecdotal of course, but another point of view :blush:

2 Likes

Thanks, @FreelancerJ, for taking the time to answer with your experience.
It’s always good to learn from another point of view. Even though I’m a retired IT consultant, in my time most of the technologies used now in HA had not yet been developed, which makes me a total newbie. I will persist, of course. It’s in my blood to not give up easily.

Hey, most of the stuff in modern home automation didn’t exist back when I did all my formal IT study either, and I’m a “young’n”. I’m right there with ya, trying to catch up on all that’s changed and all that’s new.
At least it means most of the “early adopter” pains have been dealt with so we don’t have to :joy:

Thank you for the guide. I’ve just tried ZWavejs2MQTT, and I really like what I see so far.

But in your guide you have the “Retain discovery” option disabled. I read in this thread that it ought to be enabled, as Home Assistant will lose devices/entities that have been auto-discovered if restarted and discovery messages are not retained on the MQTT broker.

Can you confirm that this is not the case, and that it’s safe to have discovery messages not retained on the broker (ie. the devices/entities are not lost in HA)?

For anyone running Home-Assistant Core, I just got this running on my Pi 3 using Snap instead of Docker.

I just followed the instructions here:
https://zwave-js.github.io/zwavejs2mqtt/#/getting-started/quick-start?id=snap-package

Then i had to run the following the commands via ssh to access the ZWaveJS2MQQT config page from my local network network (I am running Pi as a headless setup):

sudo snap set zwavejs2mqtt server.host=0.0.0.0
sudo snap run zwavejs2mqtt.enable

Be sure to replace “0.0.0.0” with your dedicated IP for the Pi.

Everything else was per your guide and is working great! Thanks for putting it together.

2 Likes

Thank you, your guide helped me a lot to remote (on a RPI) my ZWave USB controller from my HA instance.
At first I followed the MQTT approach you described: the zwavejs2mqtt used the MQTT of my HA, with MQTT discovery enabled on HA.
I also tested zwavejs2mqtt with the MQTT Gateway disabled and WS server enabled, on HA I configured the ZWave JS integration (not the addon) to rely on the zwavejs2mqtt host.
Is it correct to assume that your (guide) approach is to rely on MQTT to announce devices/entities/updates while the WS relies on websocket? Any other difference/potential impact of choosing one approach VS the other one?

first of all many thanks for the guide, I tried to set up Z-Wave2MQTT on a spare Pi and it instantly worked, very nice! I thought I will comment here instead of opening a new thread in order to have the whole history.

You also wrote a guide on how-to setup Zigbee2MQTT. My intention is to use a Pi for Z-Wave2MQTT as well as Zigbee2MQTT.

My setup is:
Pi 4
Aeotec Z-Wave 5 Stick
conbee II USB stick

would you mind writing a guide on how to run both integrations on one instance? alternatively I guess I could try to follow your guide beginning from installing Zigbee2MQTT? If so, I wonder how I can define the path to the Zigbee-stick, which cant be /dev/ttyACM0 as it is already used by the Z-Wave stick.

many thanks

Hi. And thanks for the reply.
I have not tried that myself, but looking at it I think it will run fine side-by-side just by following both guides.

In the zigbee2mqtt configuration I guess you can change this if your stick has a different port:

# Serial settings
serial:
  # Location of CC2531 USB sniffer
  port: /dev/ttyACM0

And same in ZWavejs2MQTT: docker-compose.yml

services:
  zwavejs2mqtt:
    container_name: zwavejs2mqtt
    image: zwavejs/zwavejs2mqtt:latest
    restart: always
    tty: true
    stop_signal: SIGINT
    networks:
      - zwave
    devices:
      - '/dev/ttyACM0:/dev/ttyACM0'

many thanks, I already tried to install Zigbee2MQTT side-by-side and I could install it except I cant access the frontend on port 8080. I need to investigate the root of the issue, I cant explain why it doesnt work atm.

idk, but maybe you can try to change it in /opt/zigbee2mqtt/data/configuration.yaml

frontend:
  port: 8080

I already tried that but I cant access it, my browser says this address is unknown :confused: I will read through forums to find a solution for it :wink:

finally I got it working :wink: I though Zigbee2MQTT would start without a Zigbee-stick, but it doesnt. I had to wait until today to get mine.

Just wanted to confirm that you can run Zigbee2MQTT as well as ZWave2MQTT on the same device (in my case Pi 4). I followed the guides from flemmings.

I just ran the below command to determine the device path, in my case it looks as following:

ls -l /dev/serial/by-id

update the paths in the config-files and you are good to go

I got it working (but only 1 time) …
I could access the config page from my LAN, but after rebooting the Pi it seems to be stuck in a “restart job” loop

2022-03-16T11:47:02+01:00 systemd[1]: snap.zwavejs2mqtt.zwavejs2mqtt.service: Main process exited, code=exited, status=1/FAILURE
2022-03-16T11:47:02+01:00 systemd[1]: snap.zwavejs2mqtt.zwavejs2mqtt.service: Failed with result 'exit-code'.
2022-03-16T11:47:02+01:00 systemd[1]: snap.zwavejs2mqtt.zwavejs2mqtt.service: Consumed 12.708s CPU time.
2022-03-16T11:47:02+01:00 systemd[1]: snap.zwavejs2mqtt.zwavejs2mqtt.service: Scheduled restart job, restart counter is at 3.
2022-03-16T11:47:02+01:00 systemd[1]: Stopped Service for snap application zwavejs2mqtt.zwavejs2mqtt.
2022-03-16T11:47:02+01:00 systemd[1]: snap.zwavejs2mqtt.zwavejs2mqtt.service: Consumed 12.708s CPU time.
2022-03-16T11:47:02+01:00 systemd[1]: Started Service for snap application zwavejs2mqtt.zwavejs2mqtt.
2022-03-16T11:47:02+01:00 zwavejs2mqtt.zwavejs2mqtt[2402]: Missing plug: «serial-port»
2022-03-16T11:47:02+01:00 zwavejs2mqtt.zwavejs2mqtt[2363]: OPTIONAL plug
2022-03-16T11:47:02+01:00 zwavejs2mqtt.zwavejs2mqtt[2363]: Connect with: $ sudo snap connect zwavejs2mqtt:serial-port
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]: 2022-03-16 11:47:12.854 INFO APP: Version: 6.4.1.db1571e
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]: 2022-03-16 11:47:12.864 INFO APP: Application path:/snap/zwavejs2mqtt/330/lib/node_modules/zwavejs2mqtt/server
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]:  ______                       _     ___                  _   _
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]: |___  /                      (_)   |__ \                | | | |
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]:    / /_      ____ ___   _____ _ ___   ) |_ __ ___   __ _| |_| |_
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]:   / /\ \ /\ / / _` \ \ / / _ \ / __| / /| '_ ` _ \ / _` | __| __|
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]:  / /__\ V  V / (_| |\ V /  __/ \__ \/ /_| | | | | | (_| | |_| |_
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]: /_____|\_/\_/ \__,_| \_/ \___| |___/____|_| |_| |_|\__, |\__|\__|
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]:                             _/ |                      | |
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]:                            |__/                       |_|
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]: 2022-03-16 11:47:12.929 WARN STORE: scenes.json not found
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]: SyntaxError: /var/snap/zwavejs2mqtt/330/nodes.json: Unexpected end of JSON input
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]:     at JSON.parse (<anonymous>)
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]:     at _readFile (/snap/zwavejs2mqtt/330/lib/node_modules/zwavejs2mqtt/node_modules/jsonfile/index.js:25:16)
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]:     at StorageHelper._getFile (/snap/zwavejs2mqtt/330/lib/node_modules/zwavejs2mqtt/server/lib/jsonStore.js:51:20)
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]:     at StorageHelper.init (/snap/zwavejs2mqtt/330/lib/node_modules/zwavejs2mqtt/server/lib/jsonStore.js:42:25)
  • what am I doing wrong ?
  • and also : how can I get it to completely start itself upon boot (e.g. in case of power failure) ?

Thanks
Pascal

I got it working using snap, following the instructions of Goncezilla Matt, …but only 1 time …
I could access the config page from my LAN, but after rebooting the Pi it seems to be stuck in a “restart job” loop

2022-03-16T11:47:02+01:00 systemd[1]: snap.zwavejs2mqtt.zwavejs2mqtt.service: Main process exited, code=exited, status=1/FAILURE
2022-03-16T11:47:02+01:00 systemd[1]: snap.zwavejs2mqtt.zwavejs2mqtt.service: Failed with result 'exit-code'.
2022-03-16T11:47:02+01:00 systemd[1]: snap.zwavejs2mqtt.zwavejs2mqtt.service: Consumed 12.708s CPU time.
2022-03-16T11:47:02+01:00 systemd[1]: snap.zwavejs2mqtt.zwavejs2mqtt.service: Scheduled restart job, restart counter is at 3.
2022-03-16T11:47:02+01:00 systemd[1]: Stopped Service for snap application zwavejs2mqtt.zwavejs2mqtt.
2022-03-16T11:47:02+01:00 systemd[1]: snap.zwavejs2mqtt.zwavejs2mqtt.service: Consumed 12.708s CPU time.
2022-03-16T11:47:02+01:00 systemd[1]: Started Service for snap application zwavejs2mqtt.zwavejs2mqtt.
2022-03-16T11:47:02+01:00 zwavejs2mqtt.zwavejs2mqtt[2402]: Missing plug: «serial-port»
2022-03-16T11:47:02+01:00 zwavejs2mqtt.zwavejs2mqtt[2363]: OPTIONAL plug
2022-03-16T11:47:02+01:00 zwavejs2mqtt.zwavejs2mqtt[2363]: Connect with: $ sudo snap connect zwavejs2mqtt:serial-port
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]: 2022-03-16 11:47:12.854 INFO APP: Version: 6.4.1.db1571e
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]: 2022-03-16 11:47:12.864 INFO APP: Application path:/snap/zwavejs2mqtt/330/lib/node_modules/zwavejs2mqtt/server
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]:  ______                       _     ___                  _   _
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]: |___  /                      (_)   |__ \                | | | |
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]:    / /_      ____ ___   _____ _ ___   ) |_ __ ___   __ _| |_| |_
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]:   / /\ \ /\ / / _` \ \ / / _ \ / __| / /| '_ ` _ \ / _` | __| __|
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]:  / /__\ V  V / (_| |\ V /  __/ \__ \/ /_| | | | | | (_| | |_| |_
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]: /_____|\_/\_/ \__,_| \_/ \___| |___/____|_| |_| |_|\__, |\__|\__|
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]:                             _/ |                      | |
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]:                            |__/                       |_|
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]: 2022-03-16 11:47:12.929 WARN STORE: scenes.json not found
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]: SyntaxError: /var/snap/zwavejs2mqtt/330/nodes.json: Unexpected end of JSON input
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]:     at JSON.parse (<anonymous>)
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]:     at _readFile (/snap/zwavejs2mqtt/330/lib/node_modules/zwavejs2mqtt/node_modules/jsonfile/index.js:25:16)
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]:     at StorageHelper._getFile (/snap/zwavejs2mqtt/330/lib/node_modules/zwavejs2mqtt/server/lib/jsonStore.js:51:20)
2022-03-16T11:47:12+01:00 zwavejs2mqtt.zwavejs2mqtt[2486]:     at StorageHelper.init (/snap/zwavejs2mqtt/330/lib/node_modules/zwavejs2mqtt/server/lib/jsonStore.js:42:25)
  • what am I doing wrong ?
  • and also : how can I get it to completely start itself upon boot (e.g. in case of power failure) ?

Thanks
Pascal