Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get ttyUSB* devices available in Home Assistant container #50

Closed
lnlp opened this issue Nov 7, 2019 · 4 comments
Closed

Unable to get ttyUSB* devices available in Home Assistant container #50

lnlp opened this issue Nov 7, 2019 · 4 comments

Comments

@lnlp
Copy link

lnlp commented Nov 7, 2019

My Home Assistant configuration is using two devices connected via USB (USB to Serial).
According to docker-compose documentation (https://docs.docker.com/compose/compose-file/) ttyUSB* host devices can be made available in a container via the 'devices:' option as follows:

 hassio:
    image: "homeassistant/home-assistant:latest"
    container_name: "hassio"
    restart: unless-stopped
    network_mode: "host"
    #depends_on:
    #  - influxdb
    #  - mosquitto
    ports:
      - 8123:8123
    volumes:
      - ./volumes/hassio/config:/config
      - /etc/localtime:/etc/localtime:ro
    devices:
      - "/dev/ttyUSB0:/dev/ttyUSB0"
      - "/dev/ttyUSB1:/dev/ttyUSB1"

I have tried using both with and without the surrounding double quotes but both without success.
(I restarted the stack both times after updating docker-compose.yml and hassio service.yml.)

My Home Assistance setup is configured to use /dev/ttyUSB0 and /dev/ttyUSB1 and home-assistant.log shows that files /dev/ttyUSB0 and /dev/ttyUSB1 do not exist.
(This was not an issue previously when my Home Assistant was not running in a container.)

When opening a terminal to the hassio container (from within Portainer) and doing an ls /dev, the ttyUSB0 and ttyUSB1 devices are not visible (which is consistent with Home Assistant's error messages in the log).

How can ttyUSB0 and ttyUSB1 be made available in the Home Assistant container?

(It would be useful to add this information to the IOTstack documentation.)

@gcgarner
Copy link
Owner

gcgarner commented Nov 8, 2019

Regarding #49, because the correct version of hassio works through its own service it is no longer operated through the stack. Be sure to remove the 'hassio' service from your docker-compose.yml file.

I haven't tested adding USB devices on the fixed version. I do think that it's own service should add support for usb.

If you can please install the corrected version and report back on whether the USB works as expected

@lnlp
Copy link
Author

lnlp commented Nov 8, 2019

After some further experimenting yesterday, removing the home-assistant docker image (the previous non-hassio version) and pulling a new instance the ttyUSB devices became visible, so got this working with the 'old situation'. Before, I had restarted the stack and rebooted the host several times but that did not help getting the ttyUSB devices available, but pulling a new image did. I cannot explain why that helped.

After that I installed the new hassio via the updated IOTstack menu (and removed the old Home Assistant image).

In a console session to the new hassio "homeassistant" container I can see that /dev/ttyUSB0 and /dev/ttyUSB1 are visible without having to do any additional configuration.

Docker unfortunately does not handle symbolic links to devices (defined using udev rules) so from now I will use /dev/serial/by-id/... to always configure the correct USB/serial device.

Any idea how to restore a Home Assistant configuration in hassio (which does not use IOTstack's ./volumes directory in the host for storing configuration files)?

@gcgarner
Copy link
Owner

gcgarner commented Nov 8, 2019

In the little testing that is did is did see that the preferred method of doing backups for hassio is to use the built-in system snapshots. That should be stored in ls /usr/share/hassio/backup/.

I want to test making a symbolic link to that directory and possibly the the homeassistant directory as well into the IOTstack/backups directory. That way i could integrate the backups together. If memory serves tar requires additional parameters to follow symbolic links.

Thanks for the heads up on the USB/Serial. This topic is going to come up in the future

@gcgarner
Copy link
Owner

Added hassio backup to todo list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants