Closed tallpgr closed 2 years ago
Are you up for creating a pull request? I'd suggest using the mechanism already built into the code here: https://github.com/gwww/upb-lib/blob/main/upb_lib/upb.py#L38
Another bug/feature request needs to logged against HA too so that it can configure the use of the new flag. That should be created once this library is working.
When using a TCP connection to the PIM-IP from Pulseworx, the connection code always schedules a heartbeat check every 90 seconds. That works when using ser2tcp, but with such a direct connection the PIM does not provide any heartbeat traffic, so upb_lib constantly closes, reopens, and scans the whole network to assess state again every 90 seconds.
Things are even worse in Home Assistant’s UPB integration which uses added callbacks on the reconnection to establish link and scene integration each reconnection cycle.
Suggestion: allow heartbeat time to be overridden with a configuration option to the UpbPim() class. Or add it as a parsable flag on the TCP url, something like tcp://1.2.3.4[:port][?heartbeat_time=xxx[,name=val]*].