@cadwal commented on Jan 27, 2019, 7:10 PM UTC:
Version info:
arch: armhf
channel: stable
hassos: "1.13"
homeassistant: 0.86.3
machine: raspberrypi3
supervisor: "142"
In a few different current issues people are having trouble with persistent naming for USB devices if you have more than one of them (I have an RFLink and an AOETEC Z-stick myself). It might be over reboots of your host or some other time when you remove sticks for management or something else like that.
Some issues:
https://community.home-assistant.io/t/persistant-usb-names/31500
https://community.home-assistant.io/t/naming-usb/36939/4
I am running from hassos on a rPi 3B+ and have managed to create custom persisted names (symlinks) for my devices on the host using udev-rules, I did not find this documentation until after that but I assume getting udev rules onto the host that way also works. The devices also have "persistent" names in the /dev/serial/by-id tree, also as symlinks.
None of those names turns up in any container on the platform, even if I switch it to non-protected mode (tested with SSH & Web Terminal).
After a bit of searching I found this code:
which ends up in
and that explains why the only serial devices that shows up in the normal container is those named like in my case /dev/ttyACM0 and /dev/ttyACM1 (and ttyUSB and others) as those are the only ones mapped into the container.
I assume sys_hardware comes from
but I don't know python so how it gets there, I have no idea.
Since we can do the udev persistence mapping using current config, would it be possible to add the ability to map additional devices (or perhaps folders since the custom persistent nodes are symlinks) in some other config? I might even already exist, but I can't find it. A deeper look says that putting symlinks to devices in the list of devices to map should work since docker 1.12.
This issue was moved by cgarwood from home-assistant/home-assistant#20516.
@cgarwood commented on Jan 28, 2019, 1:27 AM UTC:
/move to home-assistant/hassio
move[bot] commented on Jan 28, 2019, 1:27 AM UTC:
Related issue: https://github.com/home-assistant/hassio/issues/867
A compiled list of issues/discussions that refer to the same problem:
https://community.home-assistant.io/t/persistant-usb-names/31500/23
https://community.home-assistant.io/t/naming-usb/36939
https://github.com/home-assistant/hassio/issues/261
https://github.com/home-assistant/hassio/issues/485
https://github.com/home-assistant/home-assistant/issues/14692
I've been fidling with this issue and I've read a bunch of discussions/issues - these list is the ones I have tabs open - there's more tho.
I've tried to apply this trick mapping the device to /dev/ttyZWAVE, but such device was not exposed to home assistant (probaly because it's a symlink).
So, serial devices in hassio.io seems broken to me - if the server reboots (e.g. power outage), when getting back to life, it's a gamble if the serial devices will be mapped to match the config or not.
I've tried to apply this trick mapping the device to
/dev/ttyZWAVE, but suck device was not exposed to home assistant (probaly because it's a symlink).
Yes, the code I mentioned only propagates "actual" device nodes.
/dev/serial/by-id/xxxxx worked for me on 0.87.0b6 for an Aeotec Z-stick set up in the built-in integration dialog. (I did not try it in an earlier version, nor did I try it in configuration.yaml instead of the integration.)
For the zigbee2mqtt add on at least, /dev/serial/by-id/xxxxx in the config JSON does not work.
It seems that Hassio itself, integrations and add-ons may differ as to which device names are exposed.
It seems that Hassio itself, integrations and add-ons may differ as to which device names are exposed.
Yes, the context I was speaking in is the containerized Hass.io on hassOS. Non-containerized Hass.io most likely works just fine, and containerized might work depending on how the container(s) gets started.
A simple way to solve this would be to just include the symlinks when generating the list of serial devices.
Currently, this code is:
Something like this will also include any symlinks:
def serial_devices(self):
"""Return all serial and connected devices."""
dev_list = set()
for device in self.context.list_devices(subsystem='tty'):
if 'ID_VENDOR' in device or RE_TTY.search(device.device_node):
dev_list.add(device.device_node)
dev_list.extend(device.device_links)
return dev_list
device.device_links is a list that has the symlinks for the device that were generated by udev: https://pyudev.readthedocs.io/en/latest/api/pyudev.html#pyudev.Device.device_links
For /dev/ttyACM0 (or whatever the stick is mapped to currently), /dev/serial/by-id/usb-0658_0200-if00 will be an item in the device.device_links list. If you use your own udev rules to create a /dev/ttyZWAVE symlink, that will also be part of device_links.
Another approach could be to just whitelist the entire /dev/serial/by-id path as suggested here, but that would not allow for custom udev rules that generate symlinks elsewhere (e.g. /dev/ttyZWAVE).
Thank you! That looks like a nice one-liner fix for this issue.
Just ran into this as well. Glad to see there's already a fix for it.
Nope, that fix did not work since the code ran inside the supervisor container and had no access to the device links.
Not sure if home-assistant/hassos#381 did it (I didn't try before I updated), but with HassOS 2.11, the /dev/serial/by-id/ paths are working for my HUSBZB-1. They don't show in the hardware list, but the paths do work.
You can solve that issue if you provide a udev rule for Home Assistant inside Home Assistant container. We are ready to ship that out.
-> https://github.com/home-assistant/hassio-homeassistant/tree/master/base
create a folder udev rules and copy the data inside into right pleace on container.
Ah, yes, using the /dev/serial/by-id/ paths works for me as well now when I test (and check inside the container). (turns out my rflink, a Mega 2560 + shield, has a very long id including lots of text)
I do have udev rules on the hassos base that works, but it is not that obvious to me how to get the rules into the hassio container in a persistent way.
Though, since I don't have multiple sticks of the same type, the default by-id setup is enough for me.
So, as #944 has been reverted, is there any current solution when using hassio images to use the usb ids?
I have a zigbee and a zwave stick both connected to my RPi, and they show up as /dev/ttyACM0 and /dev/ttyACM1 and won't keep their order after reboot.
I connected through ssh into hassio on port 2222 to look up both ids in /dev/serial/by-id/ and used them, but they don't work inside the container.
You can solve that issue if you provide a udev rule for Home Assistant inside Home Assistant container. We are ready to ship that out.
-> https://github.com/home-assistant/hassio-homeassistant/tree/master/base
create a folder udev rules and copy the data inside into right pleace on container.
Could you elaborate further on that? The link just leads to the base image, but still left me clueless where to create an udev rule there.
I created the udev rules in the homeassistant container and they do seem to work. They still don't show up in the HW list though and I'm not sure yet if they'll persist after an update.
I created the udev rules in the homeassistant container and they do seem to work. They still don't show up in the HW list though and I'm not sure yet if they'll persist after an update.
How did you do that?
Getting them onto hassos itself is documented in https://github.com/home-assistant/hassos/blob/dev/Documentation/configuration.md but getting them into the homeassistant container even temporarily?
On the host (or an add-on with access to the host Docker):
docker exec -it homeassistant /bin/sh
Then add the files to /etc/udev/rules.d/. That is how I did it anyway. Not sure if there's a better way.
Hi,
It will be great to have option to create directory under
/hassio/homeassistant with files which will be bind to homeassistant docker
/etc directory!
Not only way to permanently link user rules, but also
easy way to get rid of annoying docker/apparmorr/dns/socat error.
JS
W dniu pon., 1.04.2019 o 22:19 Trevor notifications@github.com napisał(a):
On the host (or an add-on with access to the host Docker):
docker exec -it homeassistant /bin/sh
Then add the files to /etc/udev/rules.d/. That is how I did it anyway.
Not sure if there's a better way.—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/home-assistant/hassio/issues/911#issuecomment-478731525,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AjEGrH8Y21WYxVTpQNNJrBdl_D6B07Oqks5vcmnHgaJpZM4aVD32
.
I just updated from 0.90.2 to 0.91 and it did indeed delete my rules on the Home Assistant container. I'm not sure how to make them persist.
Anyone already come up with a solution for this ?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
no fix found?
Use /dev/serial/by-id/xxx. See #1111
This issue isn't fully resolved. In my case three usb devices based on CH340 chip have same vendor/product ID, and show as one symlink in /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0
I can resolve it by udev rules, but symlinks created on host still aren't visible in home assistant.
Most helpful comment
This issue isn't fully resolved. In my case three usb devices based on CH340 chip have same vendor/product ID, and show as one symlink in /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0
I can resolve it by udev rules, but symlinks created on host still aren't visible in home assistant.