hthiery/python-fritzhome

Is there a reason for voltage/1000 while power and energy is not /1000?

Closed this issue · 4 comments

In fritzhomedevicepowermeter.py you define
self.power = int(val.findtext("power")) (---> gives value 25123 for real 25.123 W)
self.energy = int(val.findtext("energy")) (---> gives value 999123 for real 999.123 kWh)
but voltage is /1000 (---> gives value 230.123 for real 230.123 V)

self.voltage = float(int(val.findtext("voltage")) / 1000)

Is there a reason for that? I would expect real float values (230.123 V) for all or int values (230123 V) for all, but not mixed.

From the AVM Homeautomation (AHA) Documentation:

<powermeter>
 <power>Wert in 0,001 W (aktuelle Leistung, wird etwa alle 2 Minuten aktualisiert)
 <energy>Wert in 1.0 Wh (absoluter Verbrauch seit Inbetriebnahme)
 <voltage>Wert in 0,001 V (aktuelle Spannung, wird etwa alle 2 Minuten aktualisiert)

Thus it seems to be a bug. I would prefer to have all the values in float and divieded by 1000. Feel free to create a PR.

Thanks for your quick reply!
I have no overview and understanding of the whole code, but it may simply be changing 2 lines:

self.power = int(val.findtext("power"))

to self.power = float(int(val.findtext("power")) / 1000)

self.energy = int(val.findtext("energy"))

to self.energy = float(int(val.findtext("energy")) / 1000)

@mib1185 meanhwile created PR #64 for a change the other way around:
Remove the division by 1000 on voltage value, since all other powermeter values are also returned "native"

This will change
self.voltage = float(int(val.findtext("voltage")) / 1000)
to
self.voltage = int(val.findtext("voltage"))

According to AVM documentation
Wert in 0,001 W (aktuelle Leistung, wird etwa alle 2 Minuten aktualisiert)
Wert in 1.0 Wh (absoluter Verbrauch seit Inbetriebnahme)
Wert in 0,001 V (aktuelle Spannung, wird etwa alle 2 Minuten aktualisiert)
I follow @mib1185 argument that all values should be native as documented by AVM.

This is fixed by #64 and can be closed 😊