Install and setup Zwave JS UI with Snap on a Raspberry Pi

First, I write this not as a question but as an experience and gained knowledge, I hope this can help others like me.
I am not an expert in Raspberry pi or linux, but I use Home Assistant Core and Zwave JS UI on my RPi 4. I used Docker to run Z Wave UI before and now decide to switch to the Snap installation.
I read as many guides as I can found and still met several problems during installation. Luckily I found all the methods to solve these bugs and finally got my Zwave JS UI running. But all of them are in difference websites / places, so I try to summarize all those issue I met together in one page. I hope this helps other people like me who is searching for solutions.

1. Install Snap package

To use Snap package to install Zwave, of courser we need to install Snap first. Below commands are valid for Debian:

sudo apt-get update
sudo apt-get install snapd

Hint1: later we will need to use command like sudo zwave-js-ui.enable, to make it possible for Raspberry Pi OS 32-bit system, we need to add the binary-folder to sudoer, otherwise you will get error e.g.:
sudo zwave-js-ui.enable: command not found

So run command: sudo visudo
Find out this secure_path line, add :/snap/bin to the end of the path but before ". See below as an example:

Defaults    secure_path="/usr/local/bin:/usr/bin:/bin:/snap/bin"

Save and quit the editor, and restart the system sudo reboot.

2. Install the core snap

Install core snap is to get the latest snapd according to the official guide on snapcraft.

sudo snap install --channel=stable core

Hint2: because installed snap will be upgraded automatically, I personally prefer to use the argument --channel=stable to only update the major release instead of candidate or edge release version.

After this step, Snap is successfully installed. We also need to enable the hotplug support, and then restart the snapd service.

sudo snap set system experimental.hotplug=true
sudo systemctl restart snapd

3. Install Zwave JS UI with Snap

Hint2.1: later added comment, before run the next command, please read this Hint and also the Hint5 in below. By the release of Home Assistant 2023.10, it turns out the Home Assistant requires a higher version Zwave-JS-UI than the latest available stable version on snapd store.
Maybe use --channel=candidate is an option to prevent it.

Use this command to install zwave-js-ui snap:

sudo snap install --channel=stable zwave-js-ui

To give the package access to use USB devices and observe hardware. The second one is needed for the program to list available devices in the UI.

sudo snap connect zwave-js-ui:raw-usb
sudo snap connect zwave-js-ui:hardware-observe

Hint3: here we also need to deal with a bug which seems only on Raspberry Pi OS 32-bit system. Remove the link to the unknow libarmmem-file. This solves the failure like this:
ERROR: ld.so: object '/usr/lib/arm-linux-gnueabihf/libarmmem-${PLATFORM}.so' from /etc/ld.so.preload cannot be preloaded (cannot open shared object file): ignored.

Log into the shell and edit the file /var/lib/snapd/hostfs/etc/ld.so.preload.

sudo snap run --shell zwave-js-ui
vi /var/lib/snapd/hostfs/etc/ld.so.preload

I personally like nano but cannot use it in the shell, so only possible to edit it with vi. If one isnā€™t familiar with VI, it is very easy to get crazy. For those whoā€™s not familiar with it, do exactly as following described and nothing else including moving cursor :slight_smile:
Press i after launched the editor, and now the cursor should be at 1st position of the row, enter # to comment out the line /usr/lib/arm-linux-gnueabihf/libarmmem-${PLATFORM}.so. Afterwards prese one time ESC, and type :wq then press ENTER.
Now we should get out of the editor, then type exit to exit the shell.

4. Start the Zwave JS UI server

To start the server is easy with this command:

sudo zwave-js-ui.enable

But you still may get errorsā€¦

Hint4: before start the server we can run command zwave-js-ui.help to see some useful information as well as some commands we need to execute.

For example, we can see this information:

Server configuration values: {
	"server": {
		"host": "localhost",
		"port": 8091,
		"ssl": false

The default host address is localhost, if you use ssh to connect to the pi and want to access the UI page <your IP address>:8091 on your remote computer, you need to change the host to the IP address of your Pi. I met this problem myself, server was correctly enabled without error information, but I just cannot open the UI page until I realized this. Use below command:

sudo snap set zwave-js-ui server.host='<your IP address>'

Then we need to connect the serial-port to the plug zwave-js-ui. First list available serial slots:

sudo snap interface serial-port

We may get below information:

name:    serial-port
summary: allows accessing a specific serial port
plugs:
  - zwave-js-ui
slots:
  - core:<example-slot> (allows accessing a specific serial port)

Then use this command to connect the correct serial slot to zwave-js-ui:

sudo snap connect zwave-js-ui:serial-port <slot name>

The <slot name> is the one you listed before, here it is core:<example-slot>.

Hint5: The hint is later added to include the new issue which a lot of people met and metioned in the replies.
After a certern version of update, there might appear such an error message:
Driver: Failed to open the serial port: Error: Operation not permitted, cannot open /dev/ttyUSB0 (ZW0100)
To solve this error, the proved way is to install the zwave-js-ui in devmode, use below command:

sudo snap refresh --devmode --channel=stable zwave-js-ui

Note: If your installed version was already the lastest version, the refresh will not work, you will get snap ā€œzwave-js-uiā€ has no updates available. You will then need either revert the revision to an older version and run above command again; or switch to candidate release, because candidate release is always higher than stable release.
By new installation, please consider to install directly in devmode:
sudo snap install --devmode --channel=stable zwave-js-ui

After all these steps about, now we can finally enable the zwave-js-ui.

sudo zwave-js-ui.enable

Then access it via webpage: <your IP address>:8091. At least these are all the bugs I have met.

Again, I am not the expert to create these solutions, but I found them and collected them together. Thanks to all the awesome people!
If you have any questions with other bugs you have, donā€™t ask me, I am not able to answer probablyā€¦ Use google, you will find the answer most of the cases.

Good Luck to all!

10 Likes

THANK YOU! Your writeup was EXCELENT! Iā€™ve been trying to get ZWave JS UI installed standalone on a RPi for a bit now, and kept running into walls. I started with Docker (I really donā€™t like docker - Itā€™s supposed to be easy, right? Nope - makes things more complicated than they need to be IMO) and couldnā€™t even get close to getting it working. Using the info here (Z-Wave JS UI) it errored out. Never came close to getting it going. Dunno. I then tried using snap and I got pretty close, it installed without errors but I couldnā€™t quite get there. Then I found your writeup, which bridged the gaps and I got it working FINALLY.

A few notes - if you want flexibility, instead of using:

sudo snap set zwave-js-ui server.host='<your IP address>'

Instead, use:

sudo snap set zwave-js-ui server.host=0.0.0.0

Thatā€™ll make it listen on all interfaces, so if you want to do as Iā€™m going to and use this to make an image to keep as a backup and to depoy to other RPis for the same function, you donā€™t have to remember to go back and change the IP.

The other is after running:

sudo snap connect zwave-js-ui:serial-port core:aeotecz-stickgen5zw0

It WOULD NOT CONNECT. I found that I had to go into the UI, to ā€˜Settingsā€™, then ā€˜ZWaveā€™ and set the serial port, in my case ā€˜/dev/ttyACM0ā€™. After I did that, it connected and Iā€™m off to the races. I know that using ā€˜/dev/ttyACM0ā€™ is ā€˜frowned uponā€™ because it ā€˜can changeā€™, but Iā€™ve never seen that happen with a dedicated RPi thatā€™s only serving this one function. If youā€™re talking about something that youā€™re using for other things that can present serial ports and whatnot, sure, I can see that happening, but when you have the one USB-Serial device and the onboard serial (ttyACM0 and ttyAMA0, respectively), thatā€™s not likely to happen.

2 Likes

THANKS SO much for this write up. I have been trying to get this working with Docker and this just worked!

Thanks so much. I finally for this up and running. Only issue I had was it wouldnā€™t display a slot for me to connect to when I typed
ā€˜sudo snap interface serial-portā€™

By chance is anyone part of the HA discord server?

Maybe a stupid question, have you check the spell of the command? because I remember in the help of snap, this command was spelt wronglyā€¦

Iā€™m so close to getting this working. The only issue is I can not connect to the JS UI running on my PI from Home Assistant. It seems like the port 3000 is not open when I try to connect to ws://ip:port

Did you configure the setting correctly via the web interface to open 3000 port?

I have fixed this issue. My problem was I did not have a Z stick connected. I was trying to test without having the zstick connected. Once I ordered and connected the zstick I was able to connect js ui to port 3000

Hi,

Great write-up.

Itā€™s not always that there is a serial-port available. Some USB sticks do not offer it, and the connection raw-usb should be enough.

Iā€™m the developer and maintainer of the Zwave-js-ui snap package (not ZUI itself), and I could probably change the default host to be 0.0.0.0.

I often hear people struggle to find out thatā€™s the reason they think the snap is not working properly.

1 Like

Hi, just wanted to share a solution to a possible headache that happened to me on ubuntu server on an rp4 last week: Probably after an automatic update to the lates version of the snap package, the ā€œcurrentā€ symlink got removed from the /snap/zwave-js-ui folder, causing my setup to break.
This fixed it:

$ ls /snap/zwave-js-ui
143  152 
$ sudo ln -s /snap/zwave-js-ui/152 /snap/zwave-js-ui/current
$ sudo snap restart zwave-js-ui

Any suggestions for a a very light distro to use for this? I have some homeseer z-nets that I want to just put my own os on and put only z-wavejs ui on them for managing the z-wave network for each of my z-nets.

Note that it appears my z-nets (v1) run on Pi-1 B+ boards.

You donā€™t need to run Z-Wave JS UI on your Z-NETs, you can access them via TCP serial ports. That way you can run a barebones OS on the Z-NETs, and use a more capable one for Z-Wave JS UI.

https://docs.homeseer.com/products/interfaces/z-net/z-net-integration-with-home-assistant

https://zwave-js.github.io/node-zwave-js/#/usage/tcp-connection

Yup, as I mentioned in the other thread. Iā€™m not looking to add another piece of hardware to my mix. If I can run z-wave js ui on the pis themselves, that reduces complexity in my setup. Now, itā€™s possible these pis wonā€™t handle it well and if thatā€™s the case I should be able to swap out the pis themselves for raspberry pi 3s (or just swap out one for a pi 3 and run 2 instances of zwave js ui on it)

I followed this excellent write up and since 21Dec2022 everything was running smoothly, until the automatic update (189) of the snap package on 4Jun2023. Since then my Z-Wave JS UI only shows this error message: Driver: Failed to open the serial port: Error: Operation not permitted, cannot open /dev/ttyUSB0 (ZW0100)
Error: Driver: Failed to open the serial port: Error: Operation not permitted, cannot open /dev/ttyUSB0 (ZW0100)

Has anyone else encountered this issue and managed to solve it - how?

Have you try command: ls /dev/tty* ? Check if your USB port is really there?

Yes, /dev/ttyUSB0 is definitely there and in addition dmesg | grep ttyUSB0 shows ā€˜usb 1-1.3: cp210x converter now attached to ttyUSB0ā€™. Since the error message says Operation not permitted I was also thinking of a privileges issue (although I had never bothered with this in the initial setup) and I tried a sudo chmod 777 /dev/ttyUSB0 but also without any success, the same error remains showing.

Hey there :slight_smile:

Iā€™ve had the same issues as you since I upgrade my linux Debian to the latest version.

Only way I found was to refresh the snap using --devmode flag.
Then it works.

The reason why ? Absolutely no clue ā€¦ still, it works now ā€¦ give it a shot :slight_smile:

1 Like

Thanks for your suggestion!
However in my case when I try snap refresh zwave-js-ui --devmode I just get ā€˜snap ā€œzwave-js-uiā€ has no updates availableā€™ and nothing changesā€¦
I have the latest/stable zwave-js-ui v8.18.1 Rev195 for the moment.

In the meantime I have also tried with a backup of my system of 30May on which I still have zwave-js-ui v8.16.2 Rev183 installed. This Z-Wave JS UI still works as before without any issues!
So by blocking future zwave-js-ui snap updates (with snap refresh zwave-js-ui --hold) of this older version I have a workaround to keep my Z-Wave JS UI functioning properly :slight_smile:

Okay now I canā€™t follow anymoreā€¦ I had swapped to my ā€˜newerā€™ system again to try out the suggestion above with the --devmode flag that didnā€™t work.
And when I just put my 30May SD card in again with the older zwave-js-ui v8.16.2 Rev183 that worked just fine one hour ago, now I get the same error message showing Driver: Failed to open the serial port: Error: Operation not permitted, cannot open /dev/ttyUSB0 (ZW0100)
Error: Driver: Failed to open the serial port: Error: Operation not permitted, cannot open /dev/ttyUSB0 (ZW0100)

:roll_eyes:???

So I was wrong, it is the zwave-js-ui ā€˜workingā€™ Rev44 => ā€˜problematicā€™ Rev189 update on 4Jun that caused the issue on my primary system. And when I started up my backup system, there was an immediate update from the initially ā€˜workingā€™ Rev177 => also ā€˜problematicā€™ Rev183.

So before I could apply the snap refresh zwave-js-ui --hold there was already a new snap update that destroyed my workaround for this issue :frowning_face:

YES now I got there thanks to your tip!!! :smiley:

But to obtain a real update (unlike my previous try when I already had the latest revision installed) I now did snap revert zwave-js-ui --revision 189 at first.
After that snap refresh zwave-js-ui --devmode does a real upgrade to the latest zwave-js-ui v8.18.1 Rev195 again and thanks to the --devmode flag everything seems to work fine again!?

So reading about the usage of this --devmode flag Put snap in development mode and disable security confinement => my problem had something to do with the ā€˜security confinementā€™ of the snapā€¦?

I guess @joachimmg can explain and help to prevent these kind of issues in the future

1 Like