ZWavejs2Mqtt with Home Assistant Core (venv)

Has someone installed ZWavejs2Mqtt on a Mac using the Python virtual environment?

How do I do this step by step?

I like HA, but the documentation is horrible for beginners. Also why wouldn‘t I want to run it natively on an ARM Mac (M1)?

That’s subjective, but in this case your chosen installation method is for advanced users, not beginners.

In an advanced installation like this, you are responsible for installing zwavejs2mqtt (zwavejs2mqtt is a third party application, not provided by HA). The supported methods for using Z-Wave JS are with HAOS and the add-ons (official Z-Wave JS or community zwavejs2mqtt).

The official installation method for zwavejs2mqtt is Docker (instructions here). If you don’t want to use Docker, or are unable to, you will be required to build the application from source code. That means installing node-js and the necessary tooling. The “build from source” instructions can be found here. Quote: “The most complex way to run ZWavejs2Mqtt is on bare metal.

I believe Docker is available for M1 Macs. Your best bet is to install Docker and follow the instructions I’ve linked above to setup zwavejs2mqtt with Docker.

If you are after the beginner experience, reconsider using HAOS in a VM instead.

Thanks, I will look into it.

However, what exactly is more complex than docker if using this installation method:


cd ~
mkdir zwavejs2mqtt
cd zwavejs2mqtt
# download latest version
curl -s https://api.github.com/repos/zwave-js/zwavejs2mqtt/releases/latest  \
| grep "browser_download_url.*zip" \
| cut -d : -f 2,3 \
| tr -d \" \
| wget -i -
unzip zwavejs2mqtt-v*.zip
./zwavejs2mqtt

I can update the same way instead of replacing the Docker image. In either case I have to configure (ports).

As far as I understand, I can make another venv for this or use the same. I just like the idea of running natively without additional software like Docker.

I was using a VM in UTM for a test and the CPU was idling at 25 %!

You downloaded that zip file and ran the zwavejs2mqtt binary successfully in with your M1 Mac, not in a VM?

The binary is built for amd64 Linux platforms. I’ll be amazed if that ran successfully on your Mac.

❯ file zwavejs2mqtt
zwavejs2mqtt: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=574f253597e628e2e2fb991a1a5d22bd55e34864, for GNU/Linux 2.6.32, stripped

As far as I understand, I can make another venv for this or use the same.

zwavejs2mqtt does not use Python, so you wouldn’t need a Python venv for it.

No I didn‘t. Makes sense. I probably try docker first.

But compiling for M1 should be possible as well.

I am stuck with Docker.

docker pull  zwavejs/zwavejs2mqtt:latest

docker run \
  -d \
  --restart=unless-stopped \
  --name zwavejs2mqtt \
--privileged \
--network=host \
-v /Users/server/store:/usr/src/app/store \
zwavejs/zwavejs2mqtt:latest

Log:

ERROR GATEWAY: Zwave settings are not valid
APP: Listening on port 8091 host 0.0.0.0 protocol HTTP

It actually runs but I can’t reach it under localhost:8091 or 0.0.0.0:8019.

Is there anything that I missed? There is nothing stored in the store folder.

Try adding -p 8091:8091 to your docker run command

docker run \
  -d \
  --restart=unless-stopped \
  --name zwavejs2mqtt \
--privileged \
--network=host \
-p 8091:8091 \
-v /Users/server/store:/usr/src/app/store \
zwavejs/zwavejs2mqtt:latest

Still the same.

Try running your docker run command with the -it option to see if you can capture any more output from the container itself.

Right off the bat, I can see the zwave controller is not being specified, so you will probably need to pass the -d flag followed by the path to the device.

I’m sorry, I have no idea how this is done on mac, but in linux, this is something like /dev/ttyACM0

Also, instead of the docker run command, I would recommend you look into docker-compose.

I was hoping that --privileged made sure that all hardware is accessible, without prior definition.

I have to admit that the Home Assistant installation fails similarly:

docker run -d  \
  --name homeassistant \
  --privileged \
  --restart=unless-stopped \
  -e TZ=Europe/Zurich \
  -v /Users/server/home:/config \
  --network=host \
  ghcr.io/home-assistant/home-assistant:stable

This installs and some configuration files are made but I can’t reach it either. Maybe the issue is related.

Again,
You are not mapping the port number, so this would not work like that.

docker-compose would make this much easier for you.

Go ahead and install docker-compose and i’ll be more than happy to share my compose file or point you to a readily available online.

Got it!

I had to remove --network=host

Both are working now, well I can at least reach it. :slight_smile:

Good deal.
Still though, you should re-consider your approach. I dont like running containers with --privileged so I rather be very specific about which devices the container is allowed to access.

I would still recommend you get familiar with docker-compose, it helps a lot when maintaining and managing containers.

I recently migrated my install from a venv to docker because it’s much easier to keep it happy with updated libraries and whatever else it wants within the isolated container while everything else is kept intact.

Thanks, I am switching from venv as well.

I agree with privileged.

I just get an error:
docker: Error response from daemon: error gathering device information while adding custom device "/dev/cu.usbmodem2101": no such file or directory.

I have used this port in other software (which is deactivated now).

docker run \
  -d \
  --restart=unless-stopped \
  --name zwavejs2mqtt \
  -p 8091:8091 \
  --device=/dev/cu.usbmodem2101:/dev/zwave \
  -v /Users/server/store:/usr/src/app/store \
  zwavejs/zwavejs2mqtt:latest

Might have a look at docker-compose.

Oh no…

You should confirm that /dev/cu.usbmodem2101 is a valid device path on the host. In linux, it’s better to address devices by their uuid. If this exists in macOS, you may want to take a similar approach.

See above, it is not supported by Docker… :sob:

That’s unfortunate. Looks like your only option may be to compile from source.

Bummer

I guess your OS will restrict you to run it with the privileged flag, which is not ideal.

It is actually worse: It doesn’t work at all with Docker - since 2016.

But I have compiled everything myself and have it up and running in combination with venv.