Closed DavidMStraub closed 4 years ago
Thank you! Fixed in master. I'll prepare a new release on pypi.
I use it in Home Assistant as well and submitted my component last month: https://github.com/home-assistant/home-assistant/pull/27962
If you could test and review my pull request, that would be awesome.
Awesome, even better!
Unfortunately I currently have 2 issues (unrelated to your code) which prevent me from testing your integration,
Until your PR is merged, you could put the integration in a custom repo and make it available via HACS, maybe this way people could test it and give feedback.
By the way, concerning hardware: I am using this IR tranceiver and I confirm it works perfectly with your library on a Raspberry Pi Zero W.
- I am too far away from my HA host, so I cannot make a direct USB connection (I realized after my initial post); so I'll probably use your library directly and push the data via MQTT.
You could use ser2net to bridge a serial port to TCP. In Home Assistant, it would look like this:
- platform: edl21
serial_port: socket://1.2.3.4:5678
I might consider HACS if my PR won't make progress. Thanks for your suggestion!
Thanks for the hint, that's very useful!
I set up ser2net
and tried out your component, but nothing showed up. Trying to understand why, I was wondering why your __init__.py
is empty. Don't you need a async_setup
? I am under the impression that you sensor platform setup will never be called if you don't set up the integration itself.
Also, it might be helpful to add some debug logging to the code.
It could be a problem with serial port settings. For my smart meter, this line in ser2net.conf
works:
1.2.3.4,5678:raw:0:/dev/ttyUSB0:9600 8DATABITS NONE 1STOPBIT -XONXOFF -RTSCTS -HANGUP_WHEN_DONE
There's probably no structural problem with the registration in Home Assistant, because otherwise it wouldn't work for me. You can strace -p $(pidof ser2net)
to see whether there's any activiy going on after a connection was established. Use lsof -i -n -P
on Home Assistant to see whether there are outgoing connections to your ser2net server. If the state says ESTABLISHED
, there's no problem with connectivity. If it stays at SYN_SENT
, your server or port is unreachable (maybe firewalled). You can try connecting to your ser2net server from HA using telnet
or nc
. It shouldn't remain silent.
I'll think about adding some debug printing to the component, but logging all telegrams would be very noisy and OTOH silent connections won't deliver any event to notify about. I should probably print something when connection errors occur, though, if that doesn't already happen.
Great, that solved it! I had "telnet" instead of "raw" previously, I guess that was the problem. Thanks a lot!
One initial suggestion: you could use the "electricity id" as device identifier (to define a device in Home Assistant) rather than as a sensor, given that it will probably never change.
I'll try it for a while and then give feedback in the PR.
Thanks for the great work and debugging help!
you could use the "electricity id" as device identifier (to define a device in Home Assistant) rather than as a sensor, given that it will probably never change.
Can you please give a code example, either from another component or just some (pseudo-)code in here? If it just means to change some kind of flag for the specific EDL21Entity, that shouldn't be a problem. But I wouldn't like to add many lines of code for the special case. By the way, repeating values already get filtered out, so it doesn't excessively fill up the database.
I think you just need to add a method device_info
to your EDL21Entity
class, see here for the docs and examples. All your entities will have to have the same 'identifiers'
key in order to be associated with the same device.
Admittedly, I'm not 100% sure if/how the electricity id could easily be used for that. I guess one would have to modify the loop over telegrams and first wait for one containing the ID and store that (without creating an entity).
I think you just need to add a method
device_info
to yourEDL21Entity
class, see here for the docs and examples. All your entities will have to have the same'identifiers'
key in order to be associated with the same device.
I tried it in another component, but it didn't show up in the 'Devices' page. I'll leave it for a later iteration.
Thanks for this nice library! I just found it and am using it successfully with my smart meter. I am interested in using this for a custom component for Home Assistant.
Just a small thing:
bitstring
should be added as dependency insetup.py
.