-
-
Notifications
You must be signed in to change notification settings - Fork 221
Tapo P110M: Error processing Energy for device, module will be unavailable: get_energy_usage for Energy #1243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi & thanks for the report and the fixture! Could you try if #1245 fixes the issue? |
I'm not sure this is running the fixed branch, but this is what I tried:
|
@a81j Can you please run the
Furthermore, could you check if this also fails?
The Example
|
Hi, I think I may be encountering the same issue. Here's what I get when running `kasa ... --host `
Here's what I get when I try `kasa .... --debug command get_energy_usage`
Happy to provide anything else that might be helpful. |
Hi, could you try with the latest commit to #1245. I've pushed an experimental fix. |
Funny. Today I had the same issue after I had to unplug my P110M because apparently the relay got stuck. Then I noticed, that the clock had reset, because the device was without power. @a81j @donleistman I see that the clocks on your devices are also back in the year 2000. Run @sdb9696 @rytilahti At first I thought that the wrong time would break the encrypted communication, but other commands clearly work. My next guess is that the device needs the time for the stats and that fails because the clock is now in the past. This would explain, why only this one command fails. |
Did you test today with the latest commit to 1245? |
No. I used the 0.7.7 release. Setting the time back manually doesn't seem to break it. (for the release version and for af8e648) ❯ kasa --host 192.168.178.34 time set 2000 01 01 01 00
Discovering device 192.168.178.34 for 10 seconds
Old time: 2024-11-15 16:02:06+01:00 (CET)
New time: 2000-01-01 01:00:00+01:00 (CET)
❯ kasa --host 192.168.178.34 command get_energy_usage
Discovering device 192.168.178.34 for 10 seconds
{"get_energy_usage": {"today_runtime": 0, "month_runtime": 0, "today_energy": 0, "month_energy": 0, "local_time": "2000-01-01 01:00:08", "electricity_charge": [0, 0, 0], "current_power": 5283}}
❯ uv run kasa --host 192.168.178.34 command get_energy_usage
Discovering device 192.168.178.34 for 10 seconds
{"get_energy_usage": {"today_runtime": 0, "month_runtime": 0, "today_energy": 0, "month_energy": 0, "local_time": "2000-01-01 01:00:22", "electricity_charge": [0, 0, 0], "current_power": 5457}} |
@MrEbbinghaus, were you definitely getting the same error beforehand? i.e. |
@sdb9696 Yes, see my console log: console log❯ kasa
No host name given, trying discovery..
Discovering devices on 255.255.255.255 for 10 seconds
WARNING:kasa.smart.smartdevice:Error processing Energy for device 192.168.178.34, module will be unavailable: get_energy_usage for Energy (error_code=JSON_DECODE_FAIL_ERROR)
== Tapo1 - P110M ==
Host: 192.168.178.34
Port: 80
Device state: True
Time: 2000-01-02 01:04:57+01:00 (tz: CET)
Hardware: 1.0
Software: 1.2.3 Build 240617 Rel.153525
MAC (rssi): REDACTED (-34)
== Primary features ==
State (state): True
Unable to read value (current_consumption): ('Module update error', DeviceError(<SmartErrorCode.JSON_DECODE_FAIL_ERROR: -1003>))
== Information ==
Signal Level (signal_level): 3
Auto off at (auto_off_at): None
Cloud connection (cloud_connection): False
Unable to read value (consumption_today): ('Module update error', DeviceError(<SmartErrorCode.JSON_DECODE_FAIL_ERROR: -1003>))
Unable to read value (consumption_this_month): ('Module update error', DeviceError(<SmartErrorCode.JSON_DECODE_FAIL_ERROR: -1003>))
Update available (update_available): None
Check latest firmware (check_latest_firmware): <Action>
== Configuration ==
Auto off enabled (auto_off_enabled): False
Auto off in (auto_off_minutes): 120 min (range: 0-65536)
Auto update enabled (auto_update_enabled): False
LED (led): True
== Debug ==
Device ID (device_id): REDACTED
RSSI (rssi): -34 dBm
SSID (ssid): REDACTED
On since (on_since): 2000-01-02 01:02:26+01:00
Reboot (reboot): <Action>
Current firmware version (current_firmware_version): 1.2.3 Build 240617 Rel.153525
Available firmware version (available_firmware_version): None
Device time (device_time): 2000-01-02 01:04:57+01:00
Found 1 devices
❯ kasa --host 192.168.178.34 time sync
Discovering device 192.168.178.34 for 10 seconds
WARNING:kasa.smart.smartdevice:Error processing Energy for device 192.168.178.34, module will be unavailable: get_energy_usage for Energy (error_code=JSON_DECODE_FAIL_ERROR)
Old time: 2000-01-02 01:05:33+01:00 (CET)
New time: 2024-11-15 14:58:28+01:00 (CET)
❯ kasa
No host name given, trying discovery..
Discovering devices on 255.255.255.255 for 10 seconds
== Tapo1 - P110M ==
Host: 192.168.178.34
Port: 80
Device state: True
Time: 2024-11-15 14:58:33+01:00 (tz: CET)
Hardware: 1.0
Software: 1.2.3 Build 240617 Rel.153525
MAC (rssi): REDACTED (-34)
== Primary features ==
State (state): True
Current consumption (current_consumption): 16.1 W
== Information ==
Signal Level (signal_level): 3
Auto off at (auto_off_at): None
Cloud connection (cloud_connection): False
Today's consumption (consumption_today): 0.063 kWh
This month's consumption (consumption_this_month): 3.928 kWh
Update available (update_available): None
Check latest firmware (check_latest_firmware): <Action>
== Configuration ==
Auto off enabled (auto_off_enabled): False
Auto off in (auto_off_minutes): 120 min (range: 0-65536)
Auto update enabled (auto_update_enabled): False
LED (led): True
== Debug ==
Device ID (device_id): REDACTED
RSSI (rssi): -34 dBm
SSID (ssid): REDACTED
On since (on_since): 2024-11-15 14:55:21+01:00
Reboot (reboot): <Action>
Current firmware version (current_firmware_version): 1.2.3 Build 240617 Rel.153525
Available firmware version (available_firmware_version): None
Device time (device_time): 2024-11-15 14:58:33+01:00
Found 1 devices |
Cool thanks. Would you be able to test the PR with the device time set wrong again to see if the
|
@MrEbbinghaus Syncing the clock fixed my issue, thanks! I had synced it previously, but it looks like it was reset when I moved the plug. Is it necessary to sync the clock whenever the device loses power? |
The official app works just fine with the time not set. I have NTP blocked on this subnet, so it would be great if it would work without it too. I have tried the latest with the same errors: debug --feature:
--debug command get_energy_usage: |
uvx --from "python-kasa[speedups] @ git+https://github.com/python-kasa/python-kasa.git@fix/p110m_emeter" kasa --username redacted --password redacted --host 10.0.1.2 --debug command get_current_power If the current power reading could get working in Home Assistant, then that is all I need. |
@sdb9696 Same issue Log❯ uvx --from "python-kasa[speedups] @ git+https://github.com/python-kasa/python-kasa.git@fix/p110m_emeter" kasa --host 192.168.178.34 time get
Updated https://github.com/python-kasa/python-kasa.git (af8e648)
Discovering device 192.168.178.34 for 10 seconds
WARNING:kasa.smart.smartdevice:Error processing Energy for device 192.168.178.34, module will be unavailable: get_energy_usage for Energy (error_code=JSON_DECODE_FAIL_ERROR)
Current time: 2000-01-02 01:24:58+01:00 (CET)
❯ uvx --from "python-kasa[speedups] @ git+https://github.com/python-kasa/python-kasa.git@fix/p110m_emeter" kasa --host 192.168.178.34 --debug command get_energy_usage
Updated https://github.com/python-kasa/python-kasa.git (af8e648)
Discovering device 192.168.178.34 for 10 seconds
DEBUG:kasa.discover:[DISCOVERY] 192.168.178.34 >> {'system': {'get_sysinfo': {}}}
DEBUG:kasa.discover:Waiting a total of 10 seconds for responses...
DEBUG:kasa.klaptransport:Created KLAP transport for 192.168.178.34
DEBUG:kasa.discover:[DISCOVERY] 192.168.178.34 << {'error_code': 0,
'result': {'device_id': 'REDACTED_788d5dccb2d89e6bd1dbd23',
'device_model': 'P110M(EU)',
'device_type': 'SMART.TAPOPLUG',
'factory_default': False,
'ip': '192.168.178.34',
'is_support_iot_cloud': True,
'mac': 'F0-A7-31-00-00-00',
'mgt_encrypt_schm': {'encrypt_type': 'KLAP',
'http_port': 80,
'is_support_https': False,
'lv': 2},
'obd_src': 'matter',
'owner': '',
'protocol_version': 1}}
DEBUG:kasa.device:Initializing 192.168.178.34 of type <class 'kasa.smart.smartdevice.SmartDevice'>
DEBUG:kasa.smartprotocol:192.168.178.34 >> '{"method":"get_energy_usage","request_time_milis":1731852044731,"terminal_uuid":"lF0HvSAeYVnoq1oukpQPng=="}'
DEBUG:kasa.klaptransport:Starting handshake with 192.168.178.34
DEBUG:kasa.httpclient:Posting to http://192.168.178.34/app/handshake1
DEBUG:kasa.klaptransport:Handshake1 posted at 2024-11-17 15:00:44.747457. Host is 192.168.178.34, Response status is 200, Request was 99b2a6ab9086b45745e783a4b133cb57
DEBUG:kasa.klaptransport:Handshake1 success at 2024-11-17 15:00:44.747552. Host is 192.168.178.34, Server remote_seed is: 877ba9f571082bf602f328f779caa9f6, server hash is: 099f93fb882d566b3779bc8c4ce95f9f3b6c8f3669842d1eb41842395c6c80b0
DEBUG:kasa.klaptransport:Server response doesn't match our expected hash on ip 192.168.178.34, but an authentication with TAPO default credentials matched
DEBUG:kasa.httpclient:Posting to http://192.168.178.34/app/handshake2
DEBUG:kasa.klaptransport:Handshake2 posted 2024-11-17 15:00:44.754906. Host is 192.168.178.34, Response status is 200, Request was f09aaba71029611c0bfa7d4cca6b66f2b141c2d9cc3d33c86db5be3dd7cb0a0a
DEBUG:kasa.klaptransport:Handshake with 192.168.178.34 complete
DEBUG:kasa.httpclient:Posting to http://192.168.178.34/app/request
DEBUG:kasa.klaptransport:Device 192.168.178.34 query posted Host is 192.168.178.34, Sequence is -552720194, Response status is 200, Request was {"method":"get_energy_usage","request_time_milis":1731852044731,"terminal_uuid":"lF0HvSAeYVnoq1oukpQPng=="}
DEBUG:kasa.klaptransport:Device 192.168.178.34 query response received
DEBUG:kasa.smartprotocol:192.168.178.34 << {'error_code': -1003}
DEBUG:kasa.smartprotocol:Unable to query the device: 192.168.178.34, not retrying: Error querying device: 192.168.178.34: JSON_DECODE_FAIL_ERROR(-1003) for method: get_energy_usage (error_code=JSON_DECODE_FAIL_ERROR)
Raised error: Error querying device: 192.168.178.34: JSON_DECODE_FAIL_ERROR(-1003) for method: get_energy_usage (error_code=JSON_DECODE_FAIL_ERROR)
Traceback (most recent call last):
File "/Users/bjebb/Library/Caches/uv/archive-v0/qydokR5kDJ0CRcKXh6L7e/bin/kasa", line 10, in <module>
sys.exit(cli())
~~~^^
File "/Users/bjebb/Library/Caches/uv/archive-v0/qydokR5kDJ0CRcKXh6L7e/lib/python3.13/site-packages/asyncclick/core.py", line 1205, in __call__
return anyio.run(self._main, main, args, kwargs, **opts)
~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Caches/uv/archive-v0/qydokR5kDJ0CRcKXh6L7e/lib/python3.13/site-packages/anyio/_core/_eventloop.py", line 74, in run
return async_backend.run(func, args, {}, backend_options)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Caches/uv/archive-v0/qydokR5kDJ0CRcKXh6L7e/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 2284, in run
return runner.run(wrapper())
~~~~~~~~~~^^^^^^^^^^^
File "/usr/local/Cellar/python@3.13/3.13.0_1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/usr/local/Cellar/python@3.13/3.13.0_1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line 721, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "/Users/bjebb/Library/Caches/uv/archive-v0/qydokR5kDJ0CRcKXh6L7e/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 2272, in wrapper
return await func(*args)
^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Caches/uv/archive-v0/qydokR5kDJ0CRcKXh6L7e/lib/python3.13/site-packages/asyncclick/core.py", line 1208, in _main
return await main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Caches/uv/archive-v0/qydokR5kDJ0CRcKXh6L7e/lib/python3.13/site-packages/asyncclick/core.py", line 1120, in main
rv = await self.invoke(ctx)
^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Caches/uv/archive-v0/qydokR5kDJ0CRcKXh6L7e/lib/python3.13/site-packages/kasa/cli/common.py", line 238, in invoke
_handle_exception(self._debug, exc)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Caches/uv/archive-v0/qydokR5kDJ0CRcKXh6L7e/lib/python3.13/site-packages/kasa/cli/common.py", line 236, in invoke
return await super().invoke(ctx)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Caches/uv/archive-v0/qydokR5kDJ0CRcKXh6L7e/lib/python3.13/site-packages/asyncclick/core.py", line 1739, in invoke
return await _process_result(await sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Caches/uv/archive-v0/qydokR5kDJ0CRcKXh6L7e/lib/python3.13/site-packages/asyncclick/core.py", line 1485, in invoke
return await ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Caches/uv/archive-v0/qydokR5kDJ0CRcKXh6L7e/lib/python3.13/site-packages/asyncclick/core.py", line 824, in invoke
rv = await rv
^^^^^^^^
File "/Users/bjebb/Library/Caches/uv/archive-v0/qydokR5kDJ0CRcKXh6L7e/lib/python3.13/site-packages/kasa/cli/common.py", line 129, in wrapper
return await ctx.invoke(wrapped_function, dev, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Caches/uv/archive-v0/qydokR5kDJ0CRcKXh6L7e/lib/python3.13/site-packages/asyncclick/core.py", line 824, in invoke
rv = await rv
^^^^^^^^
File "/Users/bjebb/Library/Caches/uv/archive-v0/qydokR5kDJ0CRcKXh6L7e/lib/python3.13/site-packages/kasa/cli/main.py", line 446, in cmd_command
res = await dev._query_helper(command, parameters)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Caches/uv/archive-v0/qydokR5kDJ0CRcKXh6L7e/lib/python3.13/site-packages/kasa/smart/smartdevice.py", line 596, in _query_helper
res = await self.protocol.query({method: params})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Caches/uv/archive-v0/qydokR5kDJ0CRcKXh6L7e/lib/python3.13/site-packages/kasa/smartprotocol.py", line 89, in query
return await self._query(request, retry_count)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Caches/uv/archive-v0/qydokR5kDJ0CRcKXh6L7e/lib/python3.13/site-packages/kasa/smartprotocol.py", line 150, in _query
raise ex
File "/Users/bjebb/Library/Caches/uv/archive-v0/qydokR5kDJ0CRcKXh6L7e/lib/python3.13/site-packages/kasa/smartprotocol.py", line 94, in _query
return await self._execute_query(
^^^^^^^^^^^^^^^^^^^^^^^^^^
request, retry_count=retry, iterate_list_pages=True
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/Users/bjebb/Library/Caches/uv/archive-v0/qydokR5kDJ0CRcKXh6L7e/lib/python3.13/site-packages/kasa/smartprotocol.py", line 281, in _execute_query
self._handle_response_error_code(response_data, smart_method)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/bjebb/Library/Caches/uv/archive-v0/qydokR5kDJ0CRcKXh6L7e/lib/python3.13/site-packages/kasa/smartprotocol.py", line 356, in _handle_response_error_code
raise DeviceError(msg, error_code=error_code)
kasa.exceptions.DeviceError: Error querying device: 192.168.178.34: JSON_DECODE_FAIL_ERROR(-1003) for method: get_energy_usage (error_code=JSON_DECODE_FAIL_ERROR)
@donleistman Usually the plug sets the time automatically via NTP, but I blocked the device's access to the internet. Seems like it queries You can wrap large console outputs in HTML Example: <details>
<summary>This is the title for the collapsed section</summary>
```console
> foo
my example log
```
</details> becomes This is the title for the collapsed section> foo
my example log |
Can someone test if this is an issue with other models as well? |
We may need to adjust our failure logic to allow graceful failing on multi-query modules. That way we could fall back even if a single query fails, like it seems to be in this case. |
Hi @a81j and @MrEbbinghaus, any chance of an update fixture from the master branch? |
## [0.8.0](https://github.com/python-kasa/python-kasa/tree/0.8.0) (2024-11-26) [Full Changelog](0.7.7...0.8.0) **Release highlights:** - **Initial support for devices using the Tapo camera protocol, i.e. Tapo cameras and the Tapo H200 hub.** - New camera functionality such as exposing RTSP streaming urls and camera pan/tilt. - New way of testing module support for individual features with `has_feature` and `get_feature`. - Adding voltage and current monitoring to `smart` devices. - Migration from pydantic to mashumaro for serialization. Special thanks to @ryenitcher and @Puxtril for their new contributions to the improvement of the project! Also thanks to everyone who has helped with testing, contributing fixtures, and reporting issues! **Breaking change notes:** - Removed support for python <3.11. If you haven't got a compatible version try [uv](https://docs.astral.sh/uv/). - Renamed `device_config.to_dict()` to `device_config.to_dict_control_credentials()`. `to_dict()` is still available but takes no parameters. - From the `iot.Cloud` module the `iot.CloudInfo` class attributes have been converted to snake case. **Breaking changes:** - Migrate iot cloud module to mashumaro [\#1282](#1282) (@sdb9696) - Replace custom deviceconfig serialization with mashumaru [\#1274](#1274) (@sdb9696) - Remove support for python \<3.11 [\#1273](#1273) (@sdb9696) **Implemented enhancements:** - Update cli modify presets to support smart devices [\#1295](#1295) (@sdb9696) - Use credentials\_hash for smartcamera rtsp url [\#1293](#1293) (@sdb9696) - Add voltage and current monitoring to smart Devices [\#1281](#1281) (@ryenitcher) - Update cli feature command for actions not to require a value [\#1264](#1264) (@sdb9696) - Add pan tilt camera module [\#1261](#1261) (@sdb9696) - Add alarm module for smartcamera hubs [\#1258](#1258) (@sdb9696) - Move TAPO smartcamera out of experimental package [\#1255](#1255) (@sdb9696) - Add SmartCamera Led Module [\#1249](#1249) (@sdb9696) - Use component queries to select smartcamera modules [\#1248](#1248) (@sdb9696) - Print formatting for IotLightPreset [\#1216](#1216) (@Puxtril) - Allow getting Annotated features from modules [\#1018](#1018) (@sdb9696) - Add common Thermostat module [\#977](#977) (@sdb9696) **Fixed bugs:** - TP-Link Tapo S505D cannot disable gradual on/off [\#1309](#1309) - Inconsistent emeter information between features and emeter cli [\#1308](#1308) - How to dump power usage after latest updates? [\#1306](#1306) - kasa.discover: Got unsupported connection type: 'device\_family': 'SMART.IPCAMERA' [\#1267](#1267) - device \_\_repr\_\_ fails if no sys\_info [\#1262](#1262) - Tapo P110M: Error processing Energy for device, module will be unavailable: get\_energy\_usage for Energy [\#1243](#1243) - Listing light presets throws error [\#1201](#1201) - Include duration when disabling smooth transition on/off [\#1313](#1313) (@rytilahti) - Expose energy command to cli [\#1307](#1307) (@rytilahti) - Make discovery on unsupported devices less noisy [\#1291](#1291) (@rytilahti) - Fix repr for device created with no sysinfo or discovery info" [\#1266](#1266) (@sdb9696) - Fix discovery by alias for smart devices [\#1260](#1260) (@sdb9696) - Make \_\_repr\_\_ work on discovery info [\#1233](#1233) (@rytilahti) **Added support for devices:** - Add HS200 \(US\) Smart Fixture [\#1303](#1303) (@ZeliardM) - Add smartcamera devices to supported docs [\#1257](#1257) (@sdb9696) - Add P110M\(AU\) fixture [\#1244](#1244) (@rytilahti) - Add L630 fixture [\#1240](#1240) (@rytilahti) - Add EP40M Fixture [\#1238](#1238) (@ryenitcher) - Add KS220 Fixture [\#1237](#1237) (@ryenitcher) **Documentation updates:** - Use markdown footnotes in supported.md [\#1310](#1310) (@sdb9696) - Update docs for the new module attributes has/get feature [\#1301](#1301) (@sdb9696) - Fixup contributing.md for running test against a real device [\#1236](#1236) (@sdb9696) **Project maintenance:** - Rename tests/smartcamera to tests/smartcam [\#1315](#1315) (@sdb9696) - Do not error on smartcam hub attached smartcam child devices [\#1314](#1314) (@sdb9696) - Add P110M\(EU\) fixture [\#1305](#1305) (@sdb9696) - Run tests with caplog in a single worker [\#1304](#1304) (@sdb9696) - Rename smartcamera to smartcam [\#1300](#1300) (@sdb9696) - Move iot fixtures into iot subfolder [\#1299](#1299) (@sdb9696) - Annotate fan\_speed\_level of Fan interface [\#1298](#1298) (@sdb9696) - Add PIR ADC Values to Test Fixtures [\#1296](#1296) (@ryenitcher) - Exclude \_\_getattr\_\_ for deprecated attributes from type checkers [\#1294](#1294) (@sdb9696) - Simplify omit http\_client in DeviceConfig serialization [\#1292](#1292) (@sdb9696) - Add SMART Voltage Monitoring to Fixtures [\#1290](#1290) (@ryenitcher) - Remove pydantic dependency [\#1289](#1289) (@sdb9696) - Do not print out all the fixture names at the start of test runs [\#1287](#1287) (@sdb9696) - dump\_devinfo: iot light strip commands [\#1286](#1286) (@sdb9696) - Migrate TurnOnBehaviours to mashumaro [\#1285](#1285) (@sdb9696) - dump\_devinfo: query smartlife.iot.common.cloud for fw updates [\#1284](#1284) (@rytilahti) - Migrate RuleModule to mashumaro [\#1283](#1283) (@sdb9696) - Update sphinx dependency to 6.2 to fix docs build [\#1280](#1280) (@sdb9696) - Update DiscoveryResult to use mashu Annotated Alias [\#1279](#1279) (@sdb9696) - Extend dump\_devinfo iot queries [\#1278](#1278) (@sdb9696) - Migrate triggerlogs to mashumaru [\#1277](#1277) (@sdb9696) - Migrate smart firmware module to mashumaro [\#1276](#1276) (@sdb9696) - Migrate IotLightPreset to mashumaru [\#1275](#1275) (@sdb9696) - Allow callable coroutines for feature setters [\#1272](#1272) (@sdb9696) - Fix deprecated SSLContext\(\) usage [\#1271](#1271) (@sdb9696) - Use \_get\_device\_info methods for smart and iot devs in devtools [\#1265](#1265) (@sdb9696) - Remove experimental support [\#1256](#1256) (@sdb9696) - Move protocol modules into protocols package [\#1254](#1254) (@sdb9696) - Add linkcheck to readthedocs CI [\#1253](#1253) (@rytilahti) - Update cli energy command to use energy module [\#1252](#1252) (@sdb9696) - Consolidate warnings for fixtures missing child devices [\#1251](#1251) (@sdb9696) - Update smartcamera fixtures with components [\#1250](#1250) (@sdb9696) - Move transports into their own package [\#1247](#1247) (@rytilahti) - Fix warnings in our test suite [\#1246](#1246) (@rytilahti) - Move tests folder to top level of project [\#1242](#1242) (@sdb9696) - Fix test framework running against real devices [\#1235](#1235) (@sdb9696) - Add Additional Firmware Test Fixures [\#1234](#1234) (@ryenitcher) - Update DiscoveryResult to use Mashumaro instead of pydantic [\#1231](#1231) (@sdb9696) - Update fixture for ES20M 1.0.11 [\#1215](#1215) (@rytilahti) - Enable ruff check for ANN [\#1139](#1139) (@rytilahti) **Closed issues:** - Expose Fan speed range from the library [\#1008](#1008) - \[META\] 0.7 series - module support for SMART devices, support for introspectable device features and refactoring the library [\#783](#783)
Still doesn't show power reading in Home assistant dev. The power reading is "Unavailable"
now shows the correct power reading in there, but gives the same error as before as well:
|
The device time is set to
|
The current_consumption shouldn't require the time to be set correctly. Maybe it might be needed for todays_consumption or this_month_s_consumption Unfortunately, I can't have the time set correctly always on this, but I need to be able to see the current_consumption to detect if a device is currently in use. |
kasa command get_current_power works perfectly with the time wrong, so it should be possible to get it into home assistant. |
Can you try again with the latest commit to #1245 please. |
|
Presumably these numbers are all reporting 0 though?
|
They are reporting 0.0 yes. There is only a 2W load on it so I can't see if it should be something else. Reporting today's and monthly consumption doesn't make a difference for my use case. Even if I did need it, Home Assistant can generate and record those values from the current consumption easily. |
They're only available in the module that is erroring and they get set to 0 in that case. @rytilahti maybe we should return None on these if not available so that it doesn't mess up HA's TOTAL_INCREASING function? |
So this behavior of returning "0" for unavailable values might have been copied over from the homeassistant integration, so I went down the git blame history and found out that https://github.com/home-assistant/core/pull/53596/files#diff-d1aee68b279979c0c59cf7c893fec0964f0e03f84a2a761937940c541e0d176aL165-L168 was the PR that changed the behavior. If my memory serves me correctly, the reason for this hack was that the entities were initialized only during the startup, so if your device reported no information (e.g., if there was no consumption for the day after a midnight restart or so), there would be no entity created until the next HA restart. I think we should return None for unavailable information (and maybe suppress creation of such entities?), but we want to avoid reintroducing the issue this hack aimed to solve. |
This is no longer the behaviour since the move to the feature entities. The logic now is that if the feature is there, the entity is created regardless of value.
I don't think we should suppress the creation as the error could be (and usually is) intermittent. The latest commit to 1245 will return None for the consumption values on error. |
## [0.8.0](https://github.com/python-kasa/python-kasa/tree/0.8.0) (2024-11-26) [Full Changelog](0.7.7...0.8.0) **Release highlights:** - **Initial support for devices using the Tapo camera protocol, i.e. Tapo cameras and the Tapo H200 hub.** - New camera functionality such as exposing RTSP streaming urls and camera pan/tilt. - New way of testing module support for individual features with `has_feature` and `get_feature`. - Adding voltage and current monitoring to `smart` devices. - Migration from pydantic to mashumaro for serialization. Special thanks to @ryenitcher and @Puxtril for their new contributions to the improvement of the project! Also thanks to everyone who has helped with testing, contributing fixtures, and reporting issues! **Breaking change notes:** - Removed support for python <3.11. If you haven't got a compatible version try [uv](https://docs.astral.sh/uv/). - Renamed `device_config.to_dict()` to `device_config.to_dict_control_credentials()`. `to_dict()` is still available but takes no parameters. - From the `iot.Cloud` module the `iot.CloudInfo` class attributes have been converted to snake case. **Breaking changes:** - Migrate iot cloud module to mashumaro [\#1282](#1282) (@sdb9696) - Replace custom deviceconfig serialization with mashumaru [\#1274](#1274) (@sdb9696) - Remove support for python \<3.11 [\#1273](#1273) (@sdb9696) **Implemented enhancements:** - Update cli modify presets to support smart devices [\#1295](#1295) (@sdb9696) - Use credentials\_hash for smartcamera rtsp url [\#1293](#1293) (@sdb9696) - Add voltage and current monitoring to smart Devices [\#1281](#1281) (@ryenitcher) - Update cli feature command for actions not to require a value [\#1264](#1264) (@sdb9696) - Add pan tilt camera module [\#1261](#1261) (@sdb9696) - Add alarm module for smartcamera hubs [\#1258](#1258) (@sdb9696) - Move TAPO smartcamera out of experimental package [\#1255](#1255) (@sdb9696) - Add SmartCamera Led Module [\#1249](#1249) (@sdb9696) - Use component queries to select smartcamera modules [\#1248](#1248) (@sdb9696) - Print formatting for IotLightPreset [\#1216](#1216) (@Puxtril) - Allow getting Annotated features from modules [\#1018](#1018) (@sdb9696) - Add common Thermostat module [\#977](#977) (@sdb9696) **Fixed bugs:** - TP-Link Tapo S505D cannot disable gradual on/off [\#1309](#1309) - Inconsistent emeter information between features and emeter cli [\#1308](#1308) - How to dump power usage after latest updates? [\#1306](#1306) - kasa.discover: Got unsupported connection type: 'device\_family': 'SMART.IPCAMERA' [\#1267](#1267) - device \_\_repr\_\_ fails if no sys\_info [\#1262](#1262) - Tapo P110M: Error processing Energy for device, module will be unavailable: get\_energy\_usage for Energy [\#1243](#1243) - Listing light presets throws error [\#1201](#1201) - Include duration when disabling smooth transition on/off [\#1313](#1313) (@rytilahti) - Expose energy command to cli [\#1307](#1307) (@rytilahti) - Make discovery on unsupported devices less noisy [\#1291](#1291) (@rytilahti) - Fix repr for device created with no sysinfo or discovery info" [\#1266](#1266) (@sdb9696) - Fix discovery by alias for smart devices [\#1260](#1260) (@sdb9696) - Make \_\_repr\_\_ work on discovery info [\#1233](#1233) (@rytilahti) **Added support for devices:** - Add HS200 \(US\) Smart Fixture [\#1303](#1303) (@ZeliardM) - Add smartcamera devices to supported docs [\#1257](#1257) (@sdb9696) - Add P110M\(AU\) fixture [\#1244](#1244) (@rytilahti) - Add L630 fixture [\#1240](#1240) (@rytilahti) - Add EP40M Fixture [\#1238](#1238) (@ryenitcher) - Add KS220 Fixture [\#1237](#1237) (@ryenitcher) **Documentation updates:** - Use markdown footnotes in supported.md [\#1310](#1310) (@sdb9696) - Update docs for the new module attributes has/get feature [\#1301](#1301) (@sdb9696) - Fixup contributing.md for running test against a real device [\#1236](#1236) (@sdb9696) **Project maintenance:** - Rename tests/smartcamera to tests/smartcam [\#1315](#1315) (@sdb9696) - Do not error on smartcam hub attached smartcam child devices [\#1314](#1314) (@sdb9696) - Add P110M\(EU\) fixture [\#1305](#1305) (@sdb9696) - Run tests with caplog in a single worker [\#1304](#1304) (@sdb9696) - Rename smartcamera to smartcam [\#1300](#1300) (@sdb9696) - Move iot fixtures into iot subfolder [\#1299](#1299) (@sdb9696) - Annotate fan\_speed\_level of Fan interface [\#1298](#1298) (@sdb9696) - Add PIR ADC Values to Test Fixtures [\#1296](#1296) (@ryenitcher) - Exclude \_\_getattr\_\_ for deprecated attributes from type checkers [\#1294](#1294) (@sdb9696) - Simplify omit http\_client in DeviceConfig serialization [\#1292](#1292) (@sdb9696) - Add SMART Voltage Monitoring to Fixtures [\#1290](#1290) (@ryenitcher) - Remove pydantic dependency [\#1289](#1289) (@sdb9696) - Do not print out all the fixture names at the start of test runs [\#1287](#1287) (@sdb9696) - dump\_devinfo: iot light strip commands [\#1286](#1286) (@sdb9696) - Migrate TurnOnBehaviours to mashumaro [\#1285](#1285) (@sdb9696) - dump\_devinfo: query smartlife.iot.common.cloud for fw updates [\#1284](#1284) (@rytilahti) - Migrate RuleModule to mashumaro [\#1283](#1283) (@sdb9696) - Update sphinx dependency to 6.2 to fix docs build [\#1280](#1280) (@sdb9696) - Update DiscoveryResult to use mashu Annotated Alias [\#1279](#1279) (@sdb9696) - Extend dump\_devinfo iot queries [\#1278](#1278) (@sdb9696) - Migrate triggerlogs to mashumaru [\#1277](#1277) (@sdb9696) - Migrate smart firmware module to mashumaro [\#1276](#1276) (@sdb9696) - Migrate IotLightPreset to mashumaru [\#1275](#1275) (@sdb9696) - Allow callable coroutines for feature setters [\#1272](#1272) (@sdb9696) - Fix deprecated SSLContext\(\) usage [\#1271](#1271) (@sdb9696) - Use \_get\_device\_info methods for smart and iot devs in devtools [\#1265](#1265) (@sdb9696) - Remove experimental support [\#1256](#1256) (@sdb9696) - Move protocol modules into protocols package [\#1254](#1254) (@sdb9696) - Add linkcheck to readthedocs CI [\#1253](#1253) (@rytilahti) - Update cli energy command to use energy module [\#1252](#1252) (@sdb9696) - Consolidate warnings for fixtures missing child devices [\#1251](#1251) (@sdb9696) - Update smartcamera fixtures with components [\#1250](#1250) (@sdb9696) - Move transports into their own package [\#1247](#1247) (@rytilahti) - Fix warnings in our test suite [\#1246](#1246) (@rytilahti) - Move tests folder to top level of project [\#1242](#1242) (@sdb9696) - Fix test framework running against real devices [\#1235](#1235) (@sdb9696) - Add Additional Firmware Test Fixures [\#1234](#1234) (@ryenitcher) - Update DiscoveryResult to use Mashumaro instead of pydantic [\#1231](#1231) (@sdb9696) - Update fixture for ES20M 1.0.11 [\#1215](#1215) (@rytilahti) - Enable ruff check for ANN [\#1139](#1139) (@rytilahti) **Closed issues:** - Expose Fan speed range from the library [\#1008](#1008) - \[META\] 0.7 series - module support for SMART devices, support for introspectable device features and refactoring the library [\#783](#783)
Working perfectly in Home Assistant when testing using the following:
Thank you |
Tapo P110M AU & Home Assistant 2024.11.1
On/off works in Home Assistant but energy consumption sensors say Unavailable.
Fixture file attached.
P110M(AU)_1.0_1.2.3.json
Kasa 0.7.7:
The text was updated successfully, but these errors were encountered: