Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Tapo P110 does not have "usage" module #1511

@r3Fuze

Description

@r3Fuze

Firmware version: 1.3.1 Build 240621 Rel.162048
Hardware version: 1.0
python-kasa version: 0.10.2

I'm trying to get daily/monthly runtime data from my Tapo P110 plug, but the "usage" module is not available for this device. I've followed this part of the Docs, but I'm getting KeyError: 'usage'.

The end goal is to update Home Assistant's TP-Link integration to expose daily/monthly runtime entities like the home-assistant-tapo-p100 custom integration does. The custom integration uses plugp100 under the hood.

Here is a list of the available modules on the device (click to expand)
device_id
state
signal_level
rssi
ssid
on_since
reboot
device_time
auto_off_enabled
auto_off_minutes
auto_off_at
cloud_connection
current_consumption
consumption_today
consumption_this_month
voltage
current
auto_update_enabled
update_available
current_firmware_version
available_firmware_version
check_latest_firmware
led
overheated
overloaded
power_protection_threshold

The Tapo app has runtime information available, and running kasa --host 192.168.1.173 --debug returns JSON containing the runtime information.

Full output of the command (click to expand)
Discovering device 192.168.1.173 for 10 seconds
DEBUG:kasa.discover:[DISCOVERY] 192.168.1.173 >> {'system': {'get_sysinfo': {}}}
DEBUG:kasa.discover:Waiting a total of 10 seconds for responses...
DEBUG:kasa.device_factory:Using SmartDevice for SMART.TAPOPLUG
DEBUG:kasa.device_factory:Finding protocol for 192.168.1.173
DEBUG:kasa.device_factory:Finding protocol for DeviceFamily.SmartTapoPlug
DEBUG:kasa.device_factory:Finding transport for SMART.KLAP
DEBUG:kasa.transports.klaptransport:Created KLAP transport for 192.168.1.173
DEBUG:kasa.discover:[DISCOVERY] 192.168.1.173 << {'error_code': 0,
 'result': {'device_id': 'REDACTED_0f2052c834b27cb8429c4d2',
            'device_model': 'P110(EU)',
            'device_type': 'SMART.TAPOPLUG',
            'factory_default': False,
            'ip': '192.168.1.173',
            'is_support_iot_cloud': True,
            'mac': '30-DE-4B-00-00-00',
            'mgt_encrypt_schm': {'encrypt_type': 'KLAP',
                                 'http_port': 80,
                                 'is_support_https': False,
                                 'lv': 2},
            'obd_src': 'tplink',
            'owner': 'REDACTED_DDA8E2DCAEFD5DC1FFF715B',
            'protocol_version': 1}}
DEBUG:kasa.device:Initializing 192.168.1.173 of type <class 'kasa.smart.smartdevice.SmartDevice'>
DEBUG:kasa.protocols.smartprotocol:192.168.1.173 multi-request-batch-1-of-1 >> '{"method":"multipleRequest","request_time_milis":1740401793215,"terminal_uuid":"4WgaWLKXWDoGImx5PBXiHg==","params":{"requests":[{"method":"component_nego"},{"method":"get_device_info"},{"method":"get_connect_cloud_state"}]}}'
DEBUG:kasa.transports.klaptransport:Starting handshake with 192.168.1.173
DEBUG:kasa.httpclient:Posting to http://192.168.1.173/app/handshake1
DEBUG:kasa.transports.klaptransport:Handshake1 posted at 2025-02-24 13:56:33.232507. Host is 192.168.1.173, Response status is 200, Request was c8b9069bd5cdabff62bbbc37ae6dce01
DEBUG:kasa.transports.klaptransport:Handshake1 success at 2025-02-24 13:56:33.232507. Host is 192.168.1.173, Server remote_seed is: b9858f5d65358d5fd55b8f5ebb038e5f, server hash is: 053181b1930b0d77872fb2a84011a47716a0dae1665358c063ae0332f004c06d
DEBUG:kasa.transports.klaptransport:handshake1 hashes match with expected credentials
DEBUG:kasa.httpclient:Posting to http://192.168.1.173/app/handshake2
DEBUG:kasa.transports.klaptransport:Handshake2 posted 2025-02-24 13:56:33.238665. Host is 192.168.1.173, Response status is 200, Request was a330ac62dfc526ccf3f7af50552f22c985db14ae62dddd38f5f83c3d45fc06c6
DEBUG:kasa.transports.klaptransport:Handshake with 192.168.1.173 complete
DEBUG:kasa.httpclient:Posting to http://192.168.1.173/app/request
DEBUG:kasa.transports.klaptransport:Device 192.168.1.173 query posted Host is 192.168.1.173, Sequence is -1883260276, Response status is 200, Request was {"method":"multipleRequest","request_time_milis":1740401793215,"terminal_uuid":"4WgaWLKXWDoGImx5PBXiHg==","params":{"requests":[{"method":"component_nego"},{"method":"get_device_info"},{"method":"get_connect_cloud_state"}]}}
DEBUG:kasa.transports.klaptransport:Device 192.168.1.173 query response received
DEBUG:kasa.protocols.smartprotocol:192.168.1.173 multi-request-batch-1-of-1 << {'error_code': 0,
 'result': {'responses': [{'error_code': 0,
                           'method': 'component_nego',
                           'result': {'component_list': [{'id': 'device',
                                                          'ver_code': 2},
                                                         {'id': 'firmware',
                                                          'ver_code': 2},
                                                         {'id': 'quick_setup',
                                                          'ver_code': 3},
                                                         {'id': 'time',
                                                          'ver_code': 1},
                                                         {'id': 'wireless',
                                                          'ver_code': 1},
                                                         {'id': 'schedule',
                                                          'ver_code': 2},
                                                         {'id': 'countdown',
                                                          'ver_code': 2},
                                                         {'id': 'antitheft',
                                                          'ver_code': 1},
                                                         {'id': 'account',
                                                          'ver_code': 1},
                                                         {'id': 'synchronize',
                                                          'ver_code': 1},
                                                         {'id': 'sunrise_sunset',
                                                          'ver_code': 1},
                                                         {'id': 'led',
                                                          'ver_code': 1},
                                                         {'id': 'cloud_connect',
                                                          'ver_code': 1},
                                                         {'id': 'iot_cloud',
                                                          'ver_code': 1},
                                                         {'id': 'device_local_time',
                                                          'ver_code': 1},
                                                         {'id': 'default_states',
                                                          'ver_code': 1},
                                                         {'id': 'auto_off',
                                                          'ver_code': 2},
                                                         {'id': 'localSmart',
                                                          'ver_code': 1},
                                                         {'id': 'energy_monitoring',
                                                          'ver_code': 2},
                                                         {'id': 'power_protection',
                                                          'ver_code': 1},
                                                         {'id': 'charging_protection',
                                                          'ver_code': 2},
                                                         {'id': 'current_protection',
                                                          'ver_code': 1}]}},
                          {'error_code': 0,
                           'method': 'get_device_info',
                           'result': {'auto_off_remain_time': 0,
                                      'auto_off_status': 'off',
                                      'avatar': 'plug',
                                      'charging_status': 'normal',
                                      'default_states': {'state': {},
                                                         'type': 'last_states'},
                                      'device_id': 'REDACTED_17AE4DCEDD80BABC905668C20A251FD',
                                      'device_on': True,
                                      'fw_id': 'REDACTED_00000000000000000000000',
                                      'fw_ver': '1.3.1 Build 240621 Rel.162048',
                                      'has_set_location_info': True,
                                      'hw_id': 'REDACTED_F920C44099401D396C6B55B',
                                      'hw_ver': '1.0',
                                      'ip': '192.168.1.173',
                                      'lang': 'da_DK',
                                      'latitude': 0,
                                      'longitude': 0,
                                      'mac': '30-DE-4B-00-00-00',
                                      'model': 'P110',
                                      'nickname': 'I01BU0tFRF9OQU1FIw==',
                                      'oem_id': 'REDACTED_4AF8407B3EF871EACFCECF5',
                                      'on_time': 6817,
                                      'overcurrent_status': 'normal',
                                      'overheat_status': 'normal',
                                      'power_protection_status': 'normal',
                                      'region': 'Europe/Copenhagen',
                                      'rssi': -49,
                                      'signal_level': 3,
                                      'specs': '',
                                      'ssid': 'I01BU0tFRF9TU0lEIw==',
                                      'time_diff': 60,
                                      'type': 'SMART.TAPOPLUG'}},
                          {'error_code': 0,
                           'method': 'get_connect_cloud_state',
                           'result': {'status': 0}}]}}
DEBUG:kasa.smart.smartdevice:Device 192.168.1.173, found required auto_off, adding AutoOff to modules.
DEBUG:kasa.smart.smartdevice:Device 192.168.1.173, found required cloud_connect, adding Cloud to modules.        
DEBUG:kasa.smart.smartdevice:Device 192.168.1.173, found required device, adding DeviceModule to modules.        
DEBUG:kasa.smart.smartdevice:Device 192.168.1.173, found required energy_monitoring, adding Energy to modules.   
DEBUG:kasa.smart.smartdevice:Device 192.168.1.173, found required firmware, adding Firmware to modules.
DEBUG:kasa.smart.smartdevice:Device 192.168.1.173, found required led, adding Led to modules.
DEBUG:kasa.smart.smartdevice:Device 192.168.1.173, found required None, adding OverheatProtection to modules.    
DEBUG:kasa.smart.smartdevice:Device 192.168.1.173, found required power_protection, adding PowerProtection to modules.
DEBUG:kasa.smart.smartdevice:Device 192.168.1.173, found required time, adding Time to modules.
DEBUG:kasa.smart.smartdevice:Querying 192.168.1.173 for modules: Time, AutoOff, Energy, Firmware, Led, PowerProtection
DEBUG:kasa.protocols.smartprotocol:192.168.1.173 multi-request-batch-1-of-3 >> '{"method":"multipleRequest","request_time_milis":1740401793329,"terminal_uuid":"4WgaWLKXWDoGImx5PBXiHg==","params":{"requests":[{"method":"get_device_time"},{"method":"get_auto_off_config","params":{"start_index":0}},{"method":"get_energy_usage"},{"method":"get_current_power"},{"method":"get_emeter_data"}]}}'
DEBUG:kasa.httpclient:Posting to http://192.168.1.173/app/request
DEBUG:kasa.transports.klaptransport:Device 192.168.1.173 query posted Host is 192.168.1.173, Sequence is -1883260275, Response status is 200, Request was {"method":"multipleRequest","request_time_milis":1740401793329,"terminal_uuid":"4WgaWLKXWDoGImx5PBXiHg==","params":{"requests":[{"method":"get_device_time"},{"method":"get_auto_off_config","params":{"start_index":0}},{"method":"get_energy_usage"},{"method":"get_current_power"},{"method":"get_emeter_data"}]}}
DEBUG:kasa.transports.klaptransport:Device 192.168.1.173 query response received
DEBUG:kasa.protocols.smartprotocol:192.168.1.173 multi-request-batch-1-of-3 << {'error_code': 0,
 'result': {'responses': [{'error_code': 0,
                           'method': 'get_device_time',
                           'result': {'region': 'Europe/Copenhagen',
                                      'time_diff': 60,
                                      'timestamp': 1740401791}},
                          {'error_code': 0,
                           'method': 'get_auto_off_config',
                           'result': {'delay_min': 120, 'enable': False}},
                          {'error_code': 0,
                           'method': 'get_energy_usage',
                           'result': {'current_power': 29166,
                                      'electricity_charge': [0, 0, 0],
                                      'local_time': '2025-02-24 13:56:31',
                                      'month_energy': 6505,
                                      'month_runtime': 3495,
                                      'today_energy': 56,
                                      'today_runtime': 114}},
                          {'error_code': 0,
                           'method': 'get_current_power',
                           'result': {'current_power': 29}},
                          {'error_code': 0,
                           'method': 'get_emeter_data',
                           'result': {'current_ma': 412,
                                      'energy_wh': 22756,
                                      'power_mw': 29166,
                                      'voltage_mv': 230159}}]}}
DEBUG:kasa.protocols.smartprotocol:192.168.1.173 multi-request-batch-2-of-3 >> '{"method":"multipleRequest","request_time_milis":1740401793366,"terminal_uuid":"4WgaWLKXWDoGImx5PBXiHg==","params":{"requests":[{"method":"get_emeter_vgain_igain"},{"method":"get_auto_update_info"},{"method":"get_led_info"},{"method":"get_protection_power"},{"method":"get_max_power"}]}}'
DEBUG:kasa.httpclient:Posting to http://192.168.1.173/app/request
DEBUG:kasa.transports.klaptransport:Device 192.168.1.173 query posted Host is 192.168.1.173, Sequence is -1883260274, Response status is 200, Request was {"method":"multipleRequest","request_time_milis":1740401793366,"terminal_uuid":"4WgaWLKXWDoGImx5PBXiHg==","params":{"requests":[{"method":"get_emeter_vgain_igain"},{"method":"get_auto_update_info"},{"method":"get_led_info"},{"method":"get_protection_power"},{"method":"get_max_power"}]}}
DEBUG:kasa.transports.klaptransport:Device 192.168.1.173 query response received
DEBUG:kasa.protocols.smartprotocol:192.168.1.173 multi-request-batch-2-of-3 << {'error_code': 0,
 'result': {'responses': [{'error_code': 0,
                           'method': 'get_emeter_vgain_igain',
                           'result': {'igain': 10883, 'vgain': 122273}},
                          {'error_code': 0,
                           'method': 'get_auto_update_info',
                           'result': {'enable': False,
                                      'random_range': 120,
                                      'time': 180}},
                          {'error_code': 0,
                           'method': 'get_led_info',
                           'result': {'bri_config': {'bri_type': 'overall',
                                                     'overall_bri': 50},
                                      'led_rule': 'always',
                                      'led_status': True,
                                      'night_mode': {'end_time': 445,
                                                     'night_mode_type': 'sunrise_sunset',
                                                     'start_time': 1072,
                                                     'sunrise_offset': 0,
                                                     'sunset_offset': 0}}},
                          {'error_code': 0,
                           'method': 'get_protection_power',
                           'result': {'enabled': False, 'protection_power': 0}},
                          {'error_code': 0,
                           'method': 'get_max_power',
                           'result': {'max_power': 3832}}]}}
DEBUG:kasa.smart.smartdevice:Update completed 192.168.1.173: ['component_nego', 'get_device_info', 'get_connect_cloud_state', 'get_device_time', 'get_auto_off_config', 'get_energy_usage', 'get_current_power', 'get_emeter_data', 'get_emeter_vgain_igain', 'get_auto_update_info', 'get_led_info', 'get_protection_power', 'get_max_power']     
== P110-3 - P110 ==
Host: 192.168.1.173
Port: 80
Device state: True
Time:         2025-02-24 13:56:31+01:00 (tz: Europe/Copenhagen)
Hardware:     1.0 (EU)
Firmware:     1.3.1 Build 240621 Rel.162048
MAC (rssi):   30:DE:4B:36:74:7E (-49)

== Primary features ==
State (state): True
Current consumption (current_consumption): 29.2 W
Voltage (voltage): 230.2 V
Current (current): 0.41 A

== Information ==
Signal Level (signal_level): 3
Auto off at (auto_off_at): None
Cloud connection (cloud_connection): True
Today's consumption (consumption_today): 0.056 kWh
This month's consumption (consumption_this_month): 6.505 kWh
Update available (update_available): None
Check latest firmware (check_latest_firmware): <Action>
Overheated (overheated): False
Overloaded (overloaded): False

== 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
Power protection threshold (power_protection_threshold): 0 W (range: 0-3832)

== Debug ==
Device ID (device_id): 80221512917AE4DCEDD80BABC905668C20A251FD
RSSI (rssi): -49 dBm
SSID (ssid): mollebakken-IOT
On since (on_since): 2025-02-24 12:02:54+01:00
Reboot (reboot): <Action>
Device time (device_time): 2025-02-24 13:56:31+01:00
Current firmware version (current_firmware_version): 1.3.1 Build 240621 Rel.162048
Available firmware version (available_firmware_version): None

DEBUG:kasa.smart.smartdevice:Querying 192.168.1.173 for modules: Time, AutoOff, DeviceModule, Energy, PowerProtection
DEBUG:kasa.protocols.smartprotocol:192.168.1.173 multi-request-batch-1-of-3 >> '{"method":"multipleRequest","request_time_milis":1740401793392,"terminal_uuid":"4WgaWLKXWDoGImx5PBXiHg==","params":{"requests":[{"method":"get_device_time"},{"method":"get_auto_off_config","params":{"start_index":0}},{"method":"get_device_info"},{"method":"get_device_usage"},{"method":"get_energy_usage"}]}}'
DEBUG:kasa.transports.klaptransport:Starting handshake with 192.168.1.173
DEBUG:kasa.httpclient:Posting to http://192.168.1.173/app/handshake1
DEBUG:kasa.transports.klaptransport:Handshake1 posted at 2025-02-24 13:56:33.409016. Host is 192.168.1.173, Response status is 200, Request was e599efafe0176f62155b54d3e8e9f740
DEBUG:kasa.transports.klaptransport:Handshake1 success at 2025-02-24 13:56:33.409016. Host is 192.168.1.173, Server remote_seed is: f5d81e5438931e57f3f51d5715909d56, server hash is: 66ac3e91b8f00952aaf4283762f958b6e79be98ade5e85c0a4faa34bbfeb0ee8
DEBUG:kasa.transports.klaptransport:handshake1 hashes match with expected credentials
DEBUG:kasa.httpclient:Posting to http://192.168.1.173/app/handshake2
DEBUG:kasa.transports.klaptransport:Handshake2 posted 2025-02-24 13:56:33.415017. Host is 192.168.1.173, Response status is 200, Request was 12618b62f28d39ce14aa6dbb80acead196ddd8f5e64bb058d838939dd4cebd64
DEBUG:kasa.transports.klaptransport:Handshake with 192.168.1.173 complete
DEBUG:kasa.httpclient:Posting to http://192.168.1.173/app/request
DEBUG:kasa.transports.klaptransport:Device 192.168.1.173 query posted Host is 192.168.1.173, Sequence is -581503168, Response status is 200, Request was {"method":"multipleRequest","request_time_milis":1740401793392,"terminal_uuid":"4WgaWLKXWDoGImx5PBXiHg==","params":{"requests":[{"method":"get_device_time"},{"method":"get_auto_off_config","params":{"start_index":0}},{"method":"get_device_info"},{"method":"get_device_usage"},{"method":"get_energy_usage"}]}}
DEBUG:kasa.transports.klaptransport:Device 192.168.1.173 query response received
DEBUG:kasa.protocols.smartprotocol:192.168.1.173 multi-request-batch-1-of-3 << {'error_code': 0,
 'result': {'responses': [{'error_code': 0,
                           'method': 'get_device_time',
                           'result': {'region': 'Europe/Copenhagen',
                                      'time_diff': 60,
                                      'timestamp': 1740401791}},
                          {'error_code': 0,
                           'method': 'get_auto_off_config',
                           'result': {'delay_min': 120, 'enable': False}},
                          {'error_code': 0,
                           'method': 'get_device_info',
                           'result': {'auto_off_remain_time': 0,
                                      'auto_off_status': 'off',
                                      'avatar': 'plug',
                                      'charging_status': 'normal',
                                      'default_states': {'state': {},
                                                         'type': 'last_states'},
                                      'device_id': 'REDACTED_17AE4DCEDD80BABC905668C20A251FD',
                                      'device_on': True,
                                      'fw_id': 'REDACTED_00000000000000000000000',
                                      'fw_ver': '1.3.1 Build 240621 Rel.162048',
                                      'has_set_location_info': True,
                                      'hw_id': 'REDACTED_F920C44099401D396C6B55B',
                                      'hw_ver': '1.0',
                                      'ip': '192.168.1.173',
                                      'lang': 'da_DK',
                                      'latitude': 0,
                                      'longitude': 0,
                                      'mac': '30-DE-4B-00-00-00',
                                      'model': 'P110',
                                      'nickname': 'I01BU0tFRF9OQU1FIw==',
                                      'oem_id': 'REDACTED_4AF8407B3EF871EACFCECF5',
                                      'on_time': 6817,
                                      'overcurrent_status': 'normal',
                                      'overheat_status': 'normal',
                                      'power_protection_status': 'normal',
                                      'region': 'Europe/Copenhagen',
                                      'rssi': -49,
                                      'signal_level': 3,
                                      'specs': '',
                                      'ssid': 'I01BU0tFRF9TU0lEIw==',
                                      'time_diff': 60,
                                      'type': 'SMART.TAPOPLUG'}},
                          {'error_code': 0,
                           'method': 'get_device_usage',
                           'result': {'power_usage': {'past30': 6536,
                                                      'past7': 2291,
                                                      'today': 56},
                                      'saved_power': {'past30': 0,
                                                      'past7': 0,
                                                      'today': 58},
                                      'time_usage': {'past30': 3560,
                                                     'past7': 1237,
                                                     'today': 114}}},
                          {'error_code': 0,
                           'method': 'get_energy_usage',
                           'result': {'current_power': 29166,
                                      'electricity_charge': [0, 0, 0],
                                      'local_time': '2025-02-24 13:56:31',
                                      'month_energy': 6505,
                                      'month_runtime': 3495,
                                      'today_energy': 56,
                                      'today_runtime': 114}}]}}
DEBUG:kasa.protocols.smartprotocol:192.168.1.173 multi-request-batch-2-of-3 >> '{"method":"multipleRequest","request_time_milis":1740401793529,"terminal_uuid":"4WgaWLKXWDoGImx5PBXiHg==","params":{"requests":[{"method":"get_current_power"},{"method":"get_emeter_data"},{"method":"get_emeter_vgain_igain"},{"method":"get_protection_power"},{"method":"get_max_power"}]}}'
DEBUG:kasa.httpclient:Posting to http://192.168.1.173/app/request
DEBUG:kasa.transports.klaptransport:Device 192.168.1.173 query posted Host is 192.168.1.173, Sequence is -581503167, Response status is 200, Request was {"method":"multipleRequest","request_time_milis":1740401793529,"terminal_uuid":"4WgaWLKXWDoGImx5PBXiHg==","params":{"requests":[{"method":"get_current_power"},{"method":"get_emeter_data"},{"method":"get_emeter_vgain_igain"},{"method":"get_protection_power"},{"method":"get_max_power"}]}}
DEBUG:kasa.transports.klaptransport:Device 192.168.1.173 query response received
DEBUG:kasa.protocols.smartprotocol:192.168.1.173 multi-request-batch-2-of-3 << {'error_code': 0,
 'result': {'responses': [{'error_code': 0,
                           'method': 'get_current_power',
                           'result': {'current_power': 29}},
                          {'error_code': 0,
                           'method': 'get_emeter_data',
                           'result': {'current_ma': 412,
                                      'energy_wh': 22756,
                                      'power_mw': 29166,
                                      'voltage_mv': 230159}},
                          {'error_code': 0,
                           'method': 'get_emeter_vgain_igain',
                           'result': {'igain': 10883, 'vgain': 122273}},
                          {'error_code': 0,
                           'method': 'get_protection_power',
                           'result': {'enabled': False, 'protection_power': 0}},
                          {'error_code': 0,
                           'method': 'get_max_power',
                           'result': {'max_power': 3832}}]}}
DEBUG:kasa.smart.smartdevice:Update completed 192.168.1.173: ['get_device_time', 'get_auto_off_config', 'get_device_info', 'get_device_usage', 'get_energy_usage', 'get_current_power', 'get_emeter_data', 'get_emeter_vgain_igain', 'get_protection_power', 'get_max_power']

The relevant keys are today_runtime and month_runtime.

I've looked at the source for the "usage" module and searched the codebase for "runtime", but it seems the way the P110 device outputs runtime data does not match other devices that support the "usage" module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions