Making Aeotec Z-Wave Stick Static

One of the problems I have encountered using the ZWave stick is that when you plug it in, it binds to ttyACM0. Then when you remove it (say to pair with a new Zwave device) and plug it back in, it binds to ttyACM1.

This is all well and good, but is problematic since the HA configuration file has the port hard coded:

zwave:
 usb_path: /dev/ttyACM0

So I thought I would try and make the path static, say something like /dev/Aeotec or something along those lines. When I check what is connected to the usb ports:

pi@raspberrypi:~ $ lsusb
Bus 001 Device 004: ID 0658:0200 Sigma Designs, Inc.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

The only thing that stands out to me is the Sigma Designs. I know what port the stick is connected to:

pi@raspberrypi:~ $ ls /dev/ttyACM*
/dev/ttyACM0

So I check to see if I can confirm that:

pi@raspberrypi:~ $ udevadm info /dev/ttyACM0
P: /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/tty/ttyACM0
N: ttyACM0
S: serial/by-id/usb-0658_0200-if00
S: serial/by-path/platform-3f980000.usb-usb-0:1.4:1.0
E: DEVLINKS=/dev/serial/by-id/usb-0658_0200-if00 /dev/serial/by-path/platform-3f980000.usb-usb-0:1.4:1.0
E: DEVNAME=/dev/ttyACM0
E: DEVPATH=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/tty/ttyACM0
E: ID_BUS=usb
E: ID_MODEL=0200
E: ID_MODEL_ENC=0200
E: ID_MODEL_ID=0200
E: ID_PATH=platform-3f980000.usb-usb-0:1.4:1.0
E: ID_PATH_TAG=platform-3f980000_usb-usb-0_1_4_1_0
E: ID_REVISION=0000
E: ID_SERIAL=0658_0200
E: ID_TYPE=generic
E: ID_USB_CLASS_FROM_DATABASE=Communications
E: ID_USB_DRIVER=cdc_acm
E: ID_USB_INTERFACES=:020201:0a0000:
E: ID_USB_INTERFACE_NUM=00
E: ID_VENDOR=0658
E: ID_VENDOR_ENC=0658
E: ID_VENDOR_FROM_DATABASE=Sigma Designs, Inc.
E: ID_VENDOR_ID=0658
E: MAJOR=166
E: MINOR=0
E: SUBSYSTEM=tty
E: TAGS=:systemd:
E: USEC_INITIALIZED=5699

And that is where I fall flat. What do I need to do now, with the information I have, to make that port assignment static? My preference is to make it /dev/AeotecStick or something like that. But I am unsure what the next steps are.

The answer is UDEV rules - this is referenced in the ZWave configuration instructions, there is a link there to this page which should help.

2 Likes

@aimc the link you provided is not working. I looked through the documentation, but did not see anything referring to that.

1 Like

Yeah, I found this on another site:

$ cat /etc/udev/rules.d/99-usb-serial.rules
SUBSYSTEM==ā€œttyā€, ATTRS{idVendor}==ā€œ0658ā€, ATTRS{idProduct}==ā€œ0200ā€, SYMLINK+=ā€œzwaveā€

This will let your stick always show up as /dev/zwave

As an added bonus, the following will allow you to turn off the blinking LED lights while it is plugged into the usb port. It doesnā€™t effect the lights when pairing and unpairing devices, just when you have it working in your device, it wonā€™t blink 24/7:

$ sudo apt-get install cu

then this to turn them off:

$ echo -e ā€˜\x01\x08\x00\xF2\x51\x01\x00\x05\x01\x51ā€™|cu -l /dev/zwave -s 115200

if you want them back on again, then do this:

$ echo -e ā€˜\x01\x08\x00\xF2\x51\x01\x01\x05\x01\x50ā€™|cu -l /dev/zwave -s 115200

Obviously the above command lines are assuming you used the UDEV rule to change the name to /dev/zwave, otherwise you will have to set it to /dev/ttyACM0

On Rasbperry Pi with the all-in-one installer, I had to run the command to turn off the LED lights when logged in as the hass user. If you try it while logged in as the root user or pi user it will probably give you a Permission Denied, Line in Use error.

Also, my Home Assistant was already shutdown when I sent the command to turn off the LED lights, so I am not sure if that is necessary, but I presume it is, otherwise even as the hass user it would probably say it was already in use.

9 Likes

@jbardi thank you for that information. Especially how to turn off the blinking light. That was getting a little annoying.

For reference, this was what I was trying to link:

http://hintshop.ludvig.co.nz/show/persistent-names-usb-serial-devices/

1 Like

He linked it wrong (now corrected), but you can find the reference at Z-Wave - Home Assistant in one of the notes.

1 Like

I guess this is why Ben reboots after pairing in his ZWave video; the reboot resets it back to bind on /ttyACM0.

Iā€™ve been doing the same thing but at this point Iā€™ve gotten all my sensors and devices done for awhile. Wish I knew this sooner.

Great post folks!

One tip: You donā€™t have to detach the stick to pair. You can put the controller in inclusion mode via HASS (or OZWCP), then perform the physical action on the device (hit the switch or turn it on) to pair, all while the stick remained plugged in.

5 Likes

Agreed, this is an easier alternative, and the OZWCP method is a MUST when adding secure devices, such as locks, as the pairing method of the Zstick itself, as well as the Hass option, do not allow for secure device adding, but yes, adding through OZWCP or Hass is quicker, and in some cases the only option. However, this only works if you have a battery powered device you can bring to the device your Hass is running on, such as a Raspberry Pi, otherwise it is hard for it to see it unless you have a REALLY good mesh network going on.

1 Like

Hi!
I am trying to find the framing structure of the command above.
So far, I found
AEOTEC ZSTICK
where you can see the following:
0xF2 is ā€œSet Commandā€
0x51 is ā€œWhen the USB power supply, the LED indicator light configuration - 0 = disable, 1 = enable, other = ignoreā€
0x01 is the size of the data
0x01 is the value (in this case, 1 means enable as stated above)

Now I am trying to figure out what are the:
0x01 0x08 0x00
and
0x05 0x01 0x50.

Does somebody know what those extra bytes mean?
Thanks!

Actually, I might have found something here but need confirmation (maybe it does not make sense at all)

Since we need a request:
REQ | 0xf2 | Parameter Number | size | Value

0x01 Header
0x08 Length
0x00 Type (00 means request, 0x01 means response)

0xF2 is ā€œSet Commandā€
0x51 is ā€œWhen the USB power supply, the LED indicator light configuration - 0 = disable, 1 = enable, other = ignoreā€
0x01 is the size of the data
0x01 is the value (in this case, 1 means enable as stated above)

My assumption is this is parity/checksum? but no ideaā€¦
0x05 0x01 0x50.

Any ideas in the forum?
Thanks!

You might want to give Aeotec a try.
https://aeotec.freshdesk.com/support/tickets/new

Hi, Iā€™m having issues with z-wave. My Z wave USB stick sometimes disappears after a reboot. Iā€™m think this might help, hope you donā€™t mind me asking some basic questions for clarity:

  1. I donā€™t have the file ā€œ99-usb-serial.rulesā€. Do I create the file and add the text above? Do I create it via HASS.io or via the host (Iā€™m running HASS.io in a container)?
  2. Once Iā€™ve created that file, I amend the zwave entry in configuration.yaml to the name of the SYMLINK value.

Thanks for any pointers. Iā€™ve had a hard time getting this zwave thing to work.

  1. (create?) yes: if you donā€™t have the file, create one. really, itā€™s in a rules.d file, which by convention is a directory in which all files are read, so you have a lot of freedom on the name. but if in doubt, use 99-usb-serial.rules
  2. (zwave entry?) The directive suggested for 99-usb-serial.rules is telling udevd to create a softlink called ā€œ/dev/zwaveā€ pointing to wherever the device appears; you should therefore set /dev/zwave as the device in your configuration.yaml. Additionally, a --device option would be needed if launching from a ā€œdocker runā€ command line.

I need to clarify though: Iā€™ve answered as though youā€™re running on docker or docker-compose, but youā€™re actually running from inside hass.io ? This would be a host-level config, but do you have access to the host in your config?

Iā€™m using Ubuntu 18 and reference the Aeotec stick by Id rather then name. The Id doesnā€™t change.

/dev/serial/by-id/usb-0658_0200-if00

2 Likes

Hey mate, thanks for your advice. I am running HASS.io in a docker container on an NUC. So, yes I have access to the host, so I assume I log into the host system and configure it there (instead of through the HASS.io CLI interface). Iā€™m not sure about the ā€œā€“deviceā€ option your referring to.

Thanks again for getting back to me on this.

ā€”device is a config parameter given to docker when running your container: it allows the container to see the USB device in the host.

You might need to make that config change in the Hass.io supervisor container as I think it talks to docker and launches the Hass image itself

1 Like

Has anyone found other solution for making the stick static in /dev apart of using udevadm-generated symlink?
I tried that and it does the trick, but does not solve one problem - it happens to me periodically that my stick changes its file in /dev from ttyACM0 to ttyACM1 while HA is running. This caues HA to stop working with it as the mapping between Docker and HA is broken then (/dev/ttyACM0 maps to /zwaveusbstick in Docker container). Using symlink does not solve the problem as I read Docker does not support symlinks outside the build context. Meaning it always substitues the symlinkā€™s source path when creating a container, but later on - it doesnā€™t. So when this happens (I honestly donā€™t know why) the udevadm symlink does not help as Docker is still using the ā€˜oldā€™ symlink pathā€¦ :frowning:

Any other ideas here? I donā€™t want to leave the Docker solution and install HA without it as it has more cons than pros.

have you tried setting the udev rule to symlink the dev by id?

This what I use for my Aeotec Z stick;

SUBSYSTEM=="tty", ATTRS{idVendor}=="0658", ATTRS{idProduct}=="0200", SYMLINK+="ttyUSB-ZStick-5G"