toreamun / amshan-homeassistant

Home Assistant integrasjon for strømmålere (AMS/HAN/P1). Integrasjonen støter både streaming (serieport/TCP-IP) og MQTT (Tibber Pulse, energyintelligence.se etc)
MIT License
146 stars 9 forks source link

No detection of closed connection with ser2net #42

Open droberg opened 2 years ago

droberg commented 2 years ago

Version of the AMSHAN

The version is 2022.4.0

Configuration

LGF E360 -> Homebrew adapter from hanporten.se -> Raspberry-pi with GPIO -> ser2net -> wifi -> Homeassistant OS in virtual machine -> Amshan v 2022.4.0

Describe the bug

After restart of the Rasperry pi it does not seem like the plugin detects that the connection is closed and does not start again (or the timeout is very long). A reload of the plugin fixes the issue.

ruant commented 1 year ago

I'm having a similar issue. I have a MA304H3E by Kaifa.

I connect to it like this: MA304H3E -> TTL to MBUS adapter (1) -> ESP32 GPIO -> streamserver (2) -> wifi -> HA with AMSHAM

It some times times out and a reload of the plugin fixes the issue. I've tried to make some logic in node-red to detect when it happens but the reload integration part in HA through either node-red or directly to the api is really bad and doesn't work at all for me. So what I have now is just a push notification to my phone, but it sucks getting woken up in the middle of the night because the connection has times out.

Would it be possible to implement some timeout watcher in AMSHAM? If no messages has been received in X amount of time (10..20 seconds) AMSHAM tries to reconnect?

(1) https://s.click.aliexpress.com/e/_DBeSVDz (2) https://github.com/oxan/esphome-stream-server

droberg commented 1 year ago

I tried solving it the same way but my experience is similar. I am using a timer to detect the problem but I have not found a good way to automatically reload.