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

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>.

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!

5 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.

1 Like

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