Make sure calculations are done using Decimal
This commit is contained in:
parent
0cd5872fb6
commit
b5740d78c8
1 changed files with 8 additions and 6 deletions
14
solar_ble.py
14
solar_ble.py
|
@ -405,16 +405,18 @@ if __name__ == "__main__":
|
||||||
data = try_read_parse(dev, 0x0100, 11, parse_battery_state)
|
data = try_read_parse(dev, 0x0100, 11, parse_battery_state)
|
||||||
if data:
|
if data:
|
||||||
data[DataName.CALCULATED_BATTERY_POWER] = float(
|
data[DataName.CALCULATED_BATTERY_POWER] = float(
|
||||||
Decimal(data.get(DataName.BATTERY_VOLTAGE, 0))
|
Decimal(str(data.get(DataName.BATTERY_VOLTAGE, 0)))
|
||||||
* Decimal(data.get(DataName.BATTERY_CURRENT, 0))
|
* Decimal(
|
||||||
|
str(data.get(DataName.BATTERY_CURRENT, 0))
|
||||||
|
)
|
||||||
)
|
)
|
||||||
data[DataName.CALCULATED_PANEL_POWER] = float(
|
data[DataName.CALCULATED_PANEL_POWER] = float(
|
||||||
Decimal(data.get(DataName.PANEL_VOLTAGE, 0))
|
Decimal(str(data.get(DataName.PANEL_VOLTAGE, 0)))
|
||||||
* Decimal(data.get(DataName.PANEL_CURRENT, 0))
|
* Decimal(str(data.get(DataName.PANEL_CURRENT, 0)))
|
||||||
)
|
)
|
||||||
data[DataName.CALCULATED_LOAD_POWER] = float(
|
data[DataName.CALCULATED_LOAD_POWER] = float(
|
||||||
Decimal(data.get(DataName.LOAD_VOLTAGE, 0))
|
Decimal(str(data.get(DataName.LOAD_VOLTAGE, 0)))
|
||||||
* Decimal(data.get(DataName.LOAD_CURRENT, 0))
|
* Decimal(str(data.get(DataName.LOAD_CURRENT, 0)))
|
||||||
)
|
)
|
||||||
log(data)
|
log(data)
|
||||||
for consumer in consumers:
|
for consumer in consumers:
|
||||||
|
|
Loading…
Reference in a new issue