dbus-shelly-3em-smartmeter
dbus-shelly-3em-smartmeter copied to clipboard
performance tweaks
trafficstars
Hi,
I have a CCGX (slow CPU) and using dbus-shelly-3em-smartmeter is noticable. Even more powerful Cerbo-s will benefit from the following optimizations:
- _getConfig() gets called 2 times per update, meaning config file is open/read/parsed/closed 2 times every ~500ms. Consider caching configuration, and configurable update period (FR).
- for each update a new TCP connection is created Consider caching connection, i.e. using requests.Session object. See https://stackoverflow.com/questions/24873927/python-requests-module-and-connection-reuse
Great project!!!
Update: I have been testing connection reuse against 3EM. 3EM drops the connection after request, so reuse is not possible.
I see 2Hz rate is a but too high (I get the same value most of the time). 1Hz looks good, i.e. ~900ms sleep accounting some delay for the request.
@fabian-lauer the _getConfig() issue is fixed in PR #71