Z-Wave JS Setup Error "Failed to Connect"

Hello, I am new to Home Assistant. I have it installed as a Docker Container on a Synology DiskStation, and am trying to connect a Zooz ZST10 zwave stick. I have successfully got HA up and running, but am running into trouble getting Zwave set up.

I am trying to set up Z-Wave JS as described at (Alternative - Home Assistant) and (Z-Wave JS - Home Assistant). I have been able to get the Docker container started using the following command:

 sudo docker run --restart always -d --name homeassistant --privileged -v /volume1/SERVER1/HomeAssistant-Docker/config:/config --device=/dev/ttyACM0 -e TZ=America/Vancouver --net=host homeassistant/home-assistant:stable

When I try to add the Z-Wave JS Integration, it ask for a URL. Iā€™m not sure what to put here - Iā€™ve tried the default (ws://localhost:3000) as well as (ws://192.168.1.10:3000) which is the address of my Synology, and in both cases I get an error message ā€œFailed to Connectā€. Iā€™ve done some searches for this error message but none of the suggestions were able to get me past this error message.

Has anybody encountered this and been able to resolve it? Thank you for any pointers!

I think (?) that /dev/ttyACM0 is correct for my system - I unplugged/plugged my Zwave stick and ā€œttyACM0ā€ disappeared/reappeared from the /dev/ folder on my Synology.

I also confirmed that the ZST10 is a supported stick, per HAā€™s documentation (forum wonā€™t let me add more than 2 linksā€¦)

You need to install zwavejsmqtt in seperate docker container

This is where you will setup and pair all Zwave devices. It has nice UI and easy to use

Turn OFF mqtt in zwaveJSmqtt (mqtt not needed)
Turn ON websocket in zwavejsmqtt (HA will connect to this)

after zwavejs setup then use integration to connect them

1 Like

Thank you for the pointers! I was able to install zwave2jsmqtt in the Docker App on my Synology NAS, and I got it up and running and can access it through the web interface at port 8091, and was able to follow all the configuration steps at ZwaveJS2Mqtt. In the zwave2jsmqtt setup interface, I turned off MQTT and ON websocket (port 3000) as you indicated.

Iā€™m able to see my Zwave stick reported in the Control Panel of zwave2jsmqtt

In HA, when I try to add the Integration ā€œZ-Wave JSā€, it prompts me for a URL. For any of these settings, I get an error ā€œFailed to Connectā€

  • ws://localhost:3000
  • ws://192.168.1.10:3000 (this is the address of my Synology NAS)
  • ws://a0d7b954-zwavejs2mqtt:3000

Any thoughts on what I might be doing wrong? Thanks again for the help

Also - when I initially set up HA, I installed the docker from the terminal using

 sudo docker run --restart always -d --name homeassistant --privileged -v /volume1/SERVER1/HomeAssistant-Docker/config:/config --device=/dev/ttyACM0 -e TZ=America/Vancouver --net=host homeassistant/home-assistant:stable

If I am now connecting the Z-Wave stick to ā€œzwave2jsmqttā€ instead of ā€œhomeassistantā€, do I need to remove the ā€œā€“device=/dev/ttyACM0ā€ for homeassistant so that both containers arenā€™t trying to talk to the Z-Wave stick? If so, where can I change this setting? Or is it correct as-is? Thanks again

Did you expose port 3000 on the host in your Docker configuration?

do I need to remove the ā€œā€“device=/dev/ttyACM0ā€ for homeassistant so that both containers arenā€™t trying to talk to the Z-Wave stick

With the legacy z-wave integration removed, nothing inside the homeassistant container will try to use the stick, so itā€™s fine as-is. You can remove it though (I would). When I use containers, I try to restrict them to the least amount of access to resources as possible.

Thank you! Iā€™m new to a lot of this. I (think) I was able to open up port 3000 in the Synology Docker app for the zwave2jsmqtt container, and now when I try to add the Integration Z-Wave JS in the HA web interface, it prompts me for the URL, and if I enter ws://localhost:3000 it looks like it works and I can connect/add the integration. Thanks again.

You can remove it though (I would). When I use containers, I try to restrict them to the least amount of access to resources as possible.

Thanks - any thoughts on where I need to go to remove ā€œā€“device=/dev/ttyACM0ā€ from the homeassistant container? I just added that flag (following the instructions) when I installed the container from the command line, and now in the Synology Docker app I donā€™t see any place to adjust that setting. I looked through the config files in the homeassistant folder and donā€™t see the setting listed there either.

The only way to remove it is when you re-create the container. The container was probably created implicitly with the docker run command. You would need to delete it and re-run it. How have you been upgrading Home Assistant?

Ah, okay, thank you so much. Iā€™ll delete the container and re-run the command from the terminal, this time without ā€œā€“device=/dev/ttyACM0ā€ included

I havenā€™t upgraded HA yet, just getting started. It looks like there are some instructions on updating HA on a Synology NAS at Alternative - Home Assistant ?

Those instructions should be fine. The question was more to determine how you manage the containers, as that would determine how you would remove the device argument. If you were using docker-compose (which I recommend), for example, the instructions would be slightly different (the end result being the same).

Running into the same problem here. I expose both 8091 (works fine) and 3000. I can reach zwavejsmqtt fine from the browser on 8091, but not connecting on 3000 from HA.

Iā€™m using the standard docker-compose file from zwavejsmqtt and my z-wave stick is recognized fine.

version: ā€˜3.7ā€™
services:
zwavejs2mqtt:
container_name: zwavejs2mqtt
image: zwavejs/zwavejs2mqtt:latest
restart: always
tty: true
stop_signal: SIGINT
environment:
- SESSION_SECRET=mysupersecretkey
- ZWAVEJS_EXTERNAL_CONFIG=/usr/src/app/store/.config-db
# Uncomment if you want logs time and dates to match your timezone instead of UTC
# Available at List of tz database time zones - Wikipedia
#- TZ=America/New_York
networks:
- zwave
devices:
# Do not use /dev/ttyUSBX serial devices, as those mappings can change over time.
# Instead, use the /dev/serial/by-id/X serial device for your Z-Wave stick.
#- ā€˜/dev/serial/by-id/usb-Silicon_Labs_Zooz_ZST10 700_Z-Wave_Stick_0001-if00-port0:/dev/zwaveā€™
- /dev/ttyUSB0
volumes:
- zwave-config:/usr/src/app/store
ports:
- ā€˜8091:8091ā€™ # port for web interface
- ā€˜3000:3000ā€™ # port for Z-Wave JS websocket server
networks:
zwave:
volumes:
zwave-config:
name: zwave-config

In zwavejs ui setting menu there is home assistant section.

Did you enable websocket?
Also, you can disable mqttt

Since it is docker what up are you using? Host ip or container ip?

1 Like

In zwavejs ui setting menu there is home assistant section.

Did you enable websocket?

Yes

Also, you can disable mqttt

Also done

Since it is docker what up are you using? Host ip or container IP?

I need to read up on docker networking.

I can see the zwavejs webinterface from anywhere on my network and I see the HA interface from anywhere on my network, so I would expect HA could see zwavejs. But maybe HA is not seeing zwavejs. Iā€™ll add both the same docker-compose file on the same network.

In my zwavejs docker-compose, Iā€™m using:

 networks:
  zwave:

My HA docker command is:

docker run -d \
  --name homeassistant \
  --privileged \
  --restart=unless-stopped \
  -e TZ=MY_TIME_ZONE \
  -v ~/home_assistant/config:/config \
  -p 8123:8123 \
  ghcr.io/home-assistant/home-assistant:stable

Read this

I put HA and zwavejs in same docker network and set ha to connect to ws://zwavejs:3000 instead of through host ip

If port 3000 exposed you should be able to connect to that but honestly through docker network is better

Portainer is ui for docker
I always recommend use this especially if not familiar with docker. It may help correct these issue

If use Linux you can ā€œnmap hostip -p 3000ā€ to see if port is actually responding I believe. Also make sure no other service using 3000

1 Like

Finally sorted this one out (altough not 100% sure why)

  • Iā€™m running both HA and zwavejs2mqtt from the same Docker Compose file (see below)
  • Iā€™m exposing port 8123, 8091 and 3000 from the containers. I can reach HA and zwavejs2mqtt UI from my browser from anywhere on the network
  • HA zwave-js integration can NOT reach zwavejs2mqtt on localhost:3000 or 0.0.0.0:3000 or <HOST_IP>:3000. But CAN reach zwavejs2mqtt at zwavejs2mqtt:3000 (zwavejs2mqtt is the name of the zwavejs2mqtt container)

I have done a good amount of dockerizationin the past, but a bit rusty. It still doesnā€™t make sense why I can reach the UI ports from anywhere on the network, but not inbetween containers.

This is my compose file:

version: '3.7'
services:

  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:stable"
    volumes:
      - ~/home_assistant/config:/config
      - /etc/localtime:/etc/localtime:ro
    restart: unless-stopped
    privileged: true
    networks:
      - zwave
    ports:
      - '8123:8123' # port for web interface

  zwavejs2mqtt:
    container_name: zwavejs2mqtt
    image: zwavejs/zwavejs2mqtt:latest
    restart: always
    tty: true
    stop_signal: SIGINT
    environment:
      - SESSION_SECRET=mysupersecretkey
      - ZWAVEJS_EXTERNAL_CONFIG=/usr/src/app/store/.config-db
      # Uncomment if you want logs time and dates to match your timezone instead of UTC
      # Available at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
      #- TZ=America/New_York
    networks:
      - zwave
    #network_mode: host
    devices:
      # Do not use /dev/ttyUSBX serial devices, as those mappings can change over time.
      # Instead, use the /dev/serial/by-id/X serial device for your Z-Wave stick.
      #- '/dev/serial/by-id/usb-Silicon_Labs_Zooz_ZST10 700_Z-Wave_Stick_0001-if00-port0:/dev/zwave'
      - /dev/ttyUSB0
    volumes:
      - zwave-config:/usr/src/app/store
    ports:
      - '8091:8091' # port for web interface
      - '3000:3000' # port for Z-Wave JS websocket server
networks:
  zwave:
volumes:
  zwave-config:
    name: zwave-config

Exposing the port means the port is available on the host network, which is why you can connect from anywhere.

HA zwave-js integration can NOT reach zwavejs2mqtt on localhost:3000 or 0.0.0.0:3000

Since HA is in its own container, localhost refers to the services running locally, in the container. zwavejs2mqtt is in a different container, thus not available via localhost in the HA container. 0.0.0.0 will never work, it is not a route-able IP address. Itā€™s a wildcard address that basically means ā€œall IPs on this hostā€, so itā€™s not something you can connect to.

or <HOST_IP>:3000

Not sure about this one, maybe it only works if the container that is mapped to that port is running with host networking.

But CAN reach zwavejs2mqtt at zwavejs2mqtt:3000 (zwavejs2mqtt is the name of the zwavejs2mqtt container)

Youā€™ve created a docker user-defined bridge network (named zwave) and assigned both HA and z2m containers to that network. Youā€™ve also given the containers names. As a result, docker assigns their IP addresses to their names and they can be resolved via local DNS. The homeassistant container can then access the z2m container by DNS name zwavejs2mqtt.

Since youā€™re using docker compose, it already creates a user-defined network for your entire app (this particular docker-compose.yaml file). That means you can remove the zwave network entirely and the containers can continue to communicate via container names instead of IP addresses. With only two containers itā€™s not necessary to have that extra network. If you added additional containers to the same app and wanted to isolate them (which is always a good idea), then the network becomes useful.

Also, I would advise against exposing port 3000, unless you have a reason to talk to the zwave-js websocket server outside of HA. Anyone with access to your hostā€™s network could talk to the server, and it does not provide any kind of authentication or authorization. While realistically your risk of anyone accessing it is probably near zero, itā€™s still a good practice to reduce exposure of services.

1 Like