msp1974 / aioWiserHeatAPI

MIT License
3 stars 1 forks source link

Be optimistic on battery percentage if data is not present #2

Closed georox123 closed 1 year ago

georox123 commented 1 year ago

If the Wiser hub is rebooted it can take a while for it pick up the battery levels again. From what I can see, when this happens the Wiser app assumes that battery levels are 100% (optimistic) but this API assumes them to be 0% (pessimistic).

If you think it's a good idea to change the bahviour then I think it could be done by changing line 40 in helpers/battery.py from:

TRV_BATTERY_LEVEL_MAPPING.get(self.voltage, 0)

to

TRV_BATTERY_LEVEL_MAPPING.get(self.voltage, 100)

(I'm assuming the value in self.voltage is empty (or zero) so the get method is returning the default value)

msp1974 commented 1 year ago

If you have the latest v3.3.10, we now make the battery unavailable and therefore have no state of 0, if not provided by the hub. This was to try and fix your issue of getting notifications as it previously would go to 0% as you say. I think this is a better option than showing 100% which will make your history graphs look wierd. They will now have a gap.

georox123 commented 1 year ago

Seems like I jumped the gun, and also my code sugestion wouldn't have worked as is. Doh!

Thanks for making that change.