W00D00 / home-assistant-elero

Elero Centero component
GNU General Public License v3.0
39 stars 10 forks source link

Issues discovering elero stick #7

Closed r00tat closed 4 years ago

r00tat commented 4 years ago

Hi Istvan,

great work!

I had some troubles finding the correct id of the transmitter stick and I'm not a 100% sure, what went wrong.

TLDR: hass.io's packaging of Home Assistant into a container might break the discovery.

The logs did not show any information about the elero stick, so I did some debugging.

The discovery did not display any Elero sticks, so I wrote a small script (from your sources) to discover the usb stick.

#!env python
import serial
from serial.tools import list_ports
import logging

# Default serial info
DEFAULT_BRAND = 'elero'
DEFAULT_PRODUCT = 'Transmitter Stick'

_LOGGER = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)

ports = list_ports.comports()
_LOGGER.info("discovering elero devices")
_LOGGER.info("found %s devices", len(ports))
for cp in ports:
    _LOGGER.info("USB Device: %s %s %s %s", cp.manufacturer, cp.product, cp.device, cp.serial_number)
    if (cp and cp.manufacturer and DEFAULT_BRAND in cp.manufacturer and cp.product and
            DEFAULT_PRODUCT in cp.product):
        _LOGGER.info("Elero - an Elero Transmitter Stick is found on port: '{}'"
                     " with serial number: '{}'.".format(cp.device, cp.serial_number))

It worked in the first place, but now I got:

INFO:__main__:discovering elero devices
INFO:__main__:found 2 devices
INFO:__main__:USB Device: None None /dev/ttyUSB0 None
INFO:__main__:USB Device: None None /dev/ttyAMA0 None

I'm not sure why it worked in the first place but now it didn't.

I'm using Home Assistant with hass.io on a Raspberry Pi4. To execute the code I've used the Cloud9 IDE, running in unprotected mode.

After a restart of Cloud9 I was able to get the the ID of the stick:

INFO:__main__:discovering elero devices
INFO:__main__:found 2 devices
INFO:__main__:USB Device: elero GmbH Transmitter Stick /dev/ttyUSB1 XXXXX
INFO:__main__:Elero - an Elero Transmitter Stick is found on port: '/dev/ttyUSB1' with serial number: 'XXXXX'.
INFO:__main__:USB Device: None None /dev/ttyAMA0 None

So I think the cause of the issue is that Home Assistant is running in a Docker container. I don't know if there is an easy workaround for that issue.

W00D00 commented 4 years ago

Hi Paul,

Kindly sorry for my late answer. I am very happy about you are using my Elero lib. At first, I have no idea why it happens. My the Home Assistant has been running on a Raspberry Pi3B in a Docker container on USB SSD without any problem for one year. Please give me a time and I will get back soon.

Thanks, Istvan

r00tat commented 4 years ago

It seems it's somehow tied to when the stick is connected. If it is connected pre boot it will show up in the logs.

As a recommendation I would say it should be connected before it boots or at least the container is started.

I think we can close this issue.