kukulich / home-assistant-jablotron100

Home Assistant custom component for JABLOTRON 100+ alarm system
MIT License
65 stars 24 forks source link

/dev/hidraw[x] unreliable and /dev/serial/by-id/ non-existant #71

Closed DarkWarden85 closed 1 year ago

DarkWarden85 commented 1 year ago

Hi,

I have the issue that my jablotron becomes unavailable at random times after a restart. This is because it switches between /dev/hidraw0 and /dev/hidraw1. I would like to define it as /dev/serial/by-id/... in order to get rid of the problem. However, the jablotron usb-connection doesn't show up under serial, so I can't do that. What it does is that it shows up under sda or sdb like so:

/dev/disk/by-id/usb-JABTRON_JA-100_Flexi_14004027628491-0:0

How do I have to define the port so that I get a reliable connection? Is there something wrong with my usb-connection?

Im running Home Assistant 2023.3.6 on HAOS on a raspberry Pi 4 with jablotron integration 3.17.

kukulich commented 1 year ago

I never have a problem with this type of switch on my Raspberry. It is sometimes reported when people use docker but not with HaOS on Rapsberry..

DarkWarden85 commented 1 year ago

Wish I could report the same. It's an issue that happens randomly. Sometimes it's fine for a few months, other times it switches almost daily.

enicky commented 1 year ago

I have the same issue on an Intel NUC... It just switches the ports around

JairoFraile commented 1 year ago

I've the same issue too on an intel NUC. Any luck sorting it out? thanks

kukulich commented 1 year ago

You can try to ask on Discord, see README

DarkWarden85 commented 1 year ago

It happened again yesterday after updating Home Assistant OS to version 10.0. I don't know why it happens so randomly. There are many restarts where the ports stay the same, other times though...

kukulich commented 1 year ago

There’s nothing I can do about it.

fransward commented 1 year ago

I have the same issue now also since the upgrade to 2023.4. Never had the problem before. Using HAOS on an Odroid-N2. Changes daily between /dev/hidraw0 and /dev/hidraw1 making the device unavailable and thus failing some of the automations.

standamo commented 1 year ago

Maybe this would help:

# lsusb|grep -i jablotron
Bus 001 Device 006: ID 16d6:0008 Jablotron ltd JA-100 Flexi
# ll /sys/class/hidraw|grep -i :16d6:
lrwxrwxrwx    1 root     root             0 May 14 10:37 hidraw1 -> ../../devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb1/1-1/1-1.4/1-1.4:1.0/0003:16D6:0008.0002/hidraw/hidraw1
PereViader commented 1 year ago

It's also happening the same for me. Will research more

enicky commented 1 year ago

The thing I did right now is a nightly restart of Homa Assistant ... then it keeps on working for me

DarkWarden85 commented 1 year ago

I think it would be great if we could specify some kind of fallback port for the integration to scan if the connection to the other available port fails. Let's assume the integration usually connects to /dev/hidraw0 and we had a fallback port on /dev/hidraw1. If the integration now fails to connect on /dev/hidraw0, it tries to connect via /dev/hidraw1 once and only throws an error if both connections don't work. This would at least provide a workaround to the problem.

PereViader commented 1 year ago

I don't really like the fallback approach, as it could be that someone has more stuff plugged in. But it would definitely work for me

standamo commented 1 year ago

I agree. Sending something to some device is risky. Why not lookup the right /dev/hidrawX based on vendor:device as I suggested above?

DarkWarden85 commented 1 year ago

@standamo I find your suggestion difficult to understand. What do I enter into serial port field of the basic settings of the jablotron integration based on your suggestion?

PereViader commented 1 year ago

As reference https://stackoverflow.com/questions/4327032/how-do-i-uniquely-identify-an-usb-device Looks like the vendor id approach could work @DarkWarden85 it would require some new development on the integration

kukulich commented 1 year ago

some kind of fallback port

I will not do this. It's your installation problem, not problem of the integration.

DarkWarden85 commented 1 year ago

I'm just looking for any kind of workaround to a problem I share with other people here that renders the integration unreliable. A fallback port is a bad suggestion as I understand now, but the issue remains

PereViader commented 1 year ago

Haven't tested, but this proposal looks possible and with no development from the integration side https://chat.openai.com/share/c9b839a8-d582-459a-8a66-8228d8e12e11

DarkWarden85 commented 1 year ago

Haven't tested, but this proposal looks possible and with no development from the integration side https://chat.openai.com/share/c9b839a8-d582-459a-8a66-8228d8e12e11

Looks interesting, but be careful if openai isn't making stuff up in the details.

standamo commented 1 year ago

@standamo I find your suggestion difficult to understand. What do I enter into serial port field of the basic settings of the jablotron integration based on your suggestion?

@DarkWarden85 Not suggesting fix for you to put into the field for hidraw, but suggesting that the integration should ideally lookup the correct port by itself by something like the above mentioned piece of code - i.e. look for /sys/class/hidraw/hidrawX which links to the expected vendor:device pair. And thus avoid the need for that field.

filipek92 commented 1 year ago

I wrote autodetection feature in merge request #76. Testing in progress in my home instalation in proxmox virtual environment.

DarkWarden85 commented 1 year ago

@filipek92 Wow that's nice. Can't wait for it :)

kukulich commented 1 year ago

Auto detection released in https://github.com/kukulich/home-assistant-jablotron100/releases/tag/3.20.0