Open hattabatatta opened 2 months ago
That is very interesting indeed. Do you know why that number might be negative in your particular case?
Tbh: No ... I have absolutely no clue, why this device responds with a negative number. But as I found out ... there are more than 1 P110 plugs, which have negative results in their stored monthly energy data. All I can assume that this behavior is based on a bug by TP-Link and we with the python library only can do a workaround by not using unsigned int64
Sorry for the long delay in response. How's the Tapo App displaying that negative value?
Hey there!
The python library crashes, when there are somehow negative values in monthly data. Don't ask me why, but one of my P110 does have negative values in its monthly data records (-51kwH) which lead into a crash when try to read the data through the python library:
Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "xxxxx/main.py", line 50, in main energy_data_monthly = await device.get_energy_data( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Exception: Serde(Error("invalid value: integer
-50784
, expected u64", line: 1, column: 70))