home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.97k stars 30.52k forks source link

Incorrect power info for TP-link P110 plug #123651

Open L0bit0 opened 2 months ago

L0bit0 commented 2 months ago

The problem

Hi

Since last issues fixed on july release power info for this device is not updated correctly. It take a lot of time to be updated: now, last update is 22 hours ago.

more info:

What version of Home Assistant Core has the issue?

core-2024.8.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 2 months ago

Hey there @rytilahti, @bdraco, @sdb9696, mind taking a look at this issue as it has been labeled with an integration (tplink) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `tplink` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign tplink` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


tplink documentation tplink source (message by IssueLinks)

L0bit0 commented 2 months ago

@rytilahti, @bdraco, @sdb9696 any help here? or anyone can have an idea? thanks

josephduchesne commented 2 months ago

I've seen something very similar on a TP-Link KP125M plug, using the old TP-Link Smart Home integration (since the matter version doesn't seem to have power consumption at all).

I'm hoping that TP-Link updates the KP125M plug to support matter 1.3 (which includes energy monitoring, finally).

rytilahti commented 2 months ago

You could try to use the kasa tool shipped with python-kasa to check if that's what the device is reporting to homeassistant. If so, it there isn't really anything we can do at homeassistant's end as it's a firmware bug.

L0bit0 commented 2 months ago

Hi

do you have more details about how to use this Kasa python tool? i have not connected my device to Kasa tool, my native app is Tapo from tplink.

thanks in advance

rytilahti commented 2 months ago

Hi,

you can follow the instructions in https://python-kasa.readthedocs.io/en/stable/#getting-started to do that. Shortly:

virtualenv venv
source venv/bin/activate
pip install python-kasa
kasa --username <tapo email address> --password <password> discover

If your devices are a separate network, you need to add --target to the end of the discover command: kasa --username <username> --psasword <password> discover --target <network broadcast address, for example 192.168.0.255 for 192.168.0.0 network>.

If you already know the IP address of the device, you can avoid discovery and just pass --host like shown in https://python-kasa.readthedocs.io/en/stable/#feature-interface .

You can also request a single feature like this to make it easier to check for changes, e.g., the current consumption on my P110 (hardware version 1.0, firmware 1.2.3 Build 230425 Rel.142542):

kasa --host 192.168.123.123 feature current_consumption
Current consumption (current_consumption): 0.0 W
BettySwallocks commented 2 months ago

Apologies, as you will probably be able to tell, my Linux and Python skills are fairly basic.

I've hit a block trying to get the kasa library installed again. FYI - I'm using an existing Python 3.51 that was already there on my Windows machine. Some example terminal output:

(kasa) PS C:\Users\Bob> pip install python-kasa Collecting python-kasa Could not find a version that satisfies the requirement python-kasa (from versions: ) No matching distribution found for python-kasa (kasa) PS C:\Users\Bob> kasa --host 192.168.0.71 --type smart -e KLAP kasa : The term 'kasa' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1

rytilahti commented 2 months ago

That python version is unfortunately too old, thus the error Could not find a version that satisfies the requirement python-kasa (from versions: ) and it never gets installed.

If you manage to install a newer python version (and re-create the virtualenv after that), do not forget to pass the --username <your email> --password <your password> to the command.

BettySwallocks commented 2 months ago

Yeah, just found that out and upgraded. Still some challenges:

PS C:\Users\Bob> kasa --host 192.168.0.71 --type smart -e KLAP
Raised error: Server response doesn't match our challenge on ip 192.168.0.71
Run with --debug enabled to see stacktrace
PS C:\Users\Bob> kasa --host 192.168.0.71 --type smart -e AES
Raised error: Unable to complete handshake: 192.168.0.71: TRANSPORT_UNKNOWN_CREDENTIALS_ERROR(1003) (error_code=TRANSPORT_UNKNOWN_CREDENTIALS_ERROR)
Run with --debug enabled to see stacktrace
PS C:\Users\Bob> kasa --host 192.168.0.59 --type smart -e KLAP
Raised error: Server response doesn't match our challenge on ip 192.168.0.59
Run with --debug enabled to see stacktrace
PS C:\Users\Bob> kasa --host 192.168.0.59 --type smart -e AES
Raised error: Unable to complete handshake: 192.168.0.59: TRANSPORT_UNKNOWN_CREDENTIALS_ERROR(1003) (error_code=TRANSPORT_UNKNOWN_CREDENTIALS_ERROR)
Run with --debug enabled to see stacktrace

When trying a more basic 'kasa discover':

Discovering devices on 255.255.255.255 for 5 seconds
== Authentication failed for device ==
        == Discovery Result ==
        Device Type:        SMART.TAPOBULB
        Device Model:       L610(EU)
        IP:                 192.168.0.48
        MAC:                AC-15-A2-E1-86-B4
        Device Id (hash):   407ef6d9cb9955f3a7414bcd3b977b76
        Owner (hash):       A6239CDED0B57178234D930F7063182A
        HW Ver:             None
        Supports IOT Cloud: True
        OBD Src:            tplink
        Factory Default:    False
        Encrypt Type:       KLAP
        Supports HTTPS:     False
        HTTP Port:          80
        LV (Login Level):   2

== Authentication failed for device ==
        == Discovery Result ==
        Device Type:        SMART.TAPOBULB
        Device Model:       L510B(EU)
        IP:                 192.168.0.59
        MAC:                3C-52-A1-B7-42-7B
        Device Id (hash):   7e356175be58a935edcd8705d56c318c
        Owner (hash):       A6239CDED0B57178234D930F7063182A
        HW Ver:             None
        Supports IOT Cloud: True
        OBD Src:            tplink
        Factory Default:    False
        Encrypt Type:       KLAP
        Supports HTTPS:     False
        HTTP Port:          80
        LV (Login Level):   2

== Authentication failed for device ==
        == Discovery Result ==
        Device Type:        SMART.TAPOBULB
        Device Model:       L510E(EU)
        IP:                 192.168.0.72
        MAC:                5C-E9-31-AF-DA-82
        Device Id (hash):   72ea1d35cf9364640876f9cc5197c6d2
        Owner (hash):       A6239CDED0B57178234D930F7063182A
        HW Ver:             None
        Supports IOT Cloud: True
        OBD Src:            tplink
        Factory Default:    False
        Encrypt Type:       KLAP
        Supports HTTPS:     False
        HTTP Port:          80
        LV (Login Level):   2

== Authentication failed for device ==
        == Discovery Result ==
        Device Type:        SMART.TAPOBULB
        Device Model:       L900-5(EU)
        IP:                 192.168.0.92
        MAC:                AC-15-A2-F5-53-E4
        Device Id (hash):   bc0d701a4db6d95fa97f3d4d82342b29
        Owner (hash):       A6239CDED0B57178234D930F7063182A
        HW Ver:             None
        Supports IOT Cloud: True
        OBD Src:            tplink
        Factory Default:    False
        Encrypt Type:       KLAP
        Supports HTTPS:     False
        HTTP Port:          80
        LV (Login Level):   2

== TP-LINK_Power Strip_B11D - KP303(UK) ==
Host: 192.168.0.14
Port: 9999
Device state: True
Time:         2024-08-16 16:11:13 (tz: {'index': 39, 'err_code': 0}
Hardware:     1.0
Software:     1.0.5 Build 210428 Rel.144721
MAC (rssi):   60:32:B1:20:B1:1D (-57)

== Primary features ==
State (state): True

== Information ==
On since (on_since): 2024-08-14 21:00:20+01:00
Cloud connection (cloud_connection): True

== Configuration ==
LED (led): False

== Debug ==
RSSI (rssi): -57 dBm
Reboot (reboot): <Action>

== Children ==

        == Plug 1 (Socket for KP303(UK)) ==

        == Primary features ==
        State (state): True

        == Information ==
        On since (on_since): 2024-08-15 01:42:35+01:00

        == Configuration ==

        == Debug ==

        == Plug 2 (Socket for KP303(UK)) ==

        == Primary features ==
        State (state): True

        == Information ==
        On since (on_since): 2024-08-14 21:00:20+01:00

        == Configuration ==

        == Debug ==

        == Plug 3 (Socket for KP303(UK)) ==

        == Primary features ==
        State (state): False

        == Information ==
        On since (on_since): None

        == Configuration ==

        == Debug ==

== Authentication failed for device ==
        == Discovery Result ==
        Device Type:        SMART.TAPOBULB
        Device Model:       L510B(EU)
        IP:                 192.168.0.61
        MAC:                3C-52-A1-B7-43-1D
        Device Id (hash):   eafdb9c4d63fa022207e1abce2a7adcf
        Owner (hash):       A6239CDED0B57178234D930F7063182A
        HW Ver:             None
        Supports IOT Cloud: True
        OBD Src:            tplink
        Factory Default:    False
        Encrypt Type:       KLAP
        Supports HTTPS:     False
        HTTP Port:          80
        LV (Login Level):   2

== Authentication failed for device ==
        == Discovery Result ==
        Device Type:        SMART.TAPOPLUG
        Device Model:       P100(UK)
        IP:                 192.168.0.9
        MAC:                54-AF-97-43-A2-CB
        Device Id (hash):   a12d4cd3bf35e53b67587b1c7a5abcdd
        Owner (hash):       A6239CDED0B57178234D930F7063182A
        HW Ver:             None
        Supports IOT Cloud: True
        OBD Src:            tplink
        Factory Default:    False
        Encrypt Type:       KLAP
        Supports HTTPS:     False
        HTTP Port:          80
        LV (Login Level):   2

== Authentication failed for device ==
        == Discovery Result ==
        Device Type:        SMART.TAPOBULB
        Device Model:       L510 Series
        IP:                 192.168.0.71
        MAC:                00-31-92-CA-B1-8F
        Device Id (hash):   4187dbf32fae069f733a4f39057d9dc4
        Owner (hash):       a6239cded0b57178234d930f7063182a
        HW Ver:             None
        Supports IOT Cloud: True
        OBD Src:            None
        Factory Default:    False
        Encrypt Type:       KLAP
        Supports HTTPS:     False
        HTTP Port:          80
        LV (Login Level):   None

== Authentication failed for device ==
        == Discovery Result ==
        Device Type:        SMART.TAPOPLUG
        Device Model:       P100(UK)
        IP:                 192.168.0.8
        MAC:                54-AF-97-43-B4-ED
        Device Id (hash):   a85d828da455810cf9f42a76d3a770ea
        Owner (hash):       A6239CDED0B57178234D930F7063182A
        HW Ver:             None
        Supports IOT Cloud: True
        OBD Src:            tplink
        Factory Default:    False
        Encrypt Type:       KLAP
        Supports HTTPS:     False
        HTTP Port:          80
        LV (Login Level):   2

== Authentication failed for device ==
        == Discovery Result ==
        Device Type:        SMART.TAPOBULB
        Device Model:       L900-5(EU)
        IP:                 192.168.0.43
        MAC:                AC-15-A2-EB-71-DA
        Device Id (hash):   a2caaa88c236cf0d1952745c8fe72ed4
        Owner (hash):       A6239CDED0B57178234D930F7063182A
        HW Ver:             None
        Supports IOT Cloud: True
        OBD Src:            tplink
        Factory Default:    False
        Encrypt Type:       KLAP
        Supports HTTPS:     False
        HTTP Port:          80
        LV (Login Level):   2

== Authentication failed for device ==
        == Discovery Result ==
        Device Type:        SMART.TAPOBULB
        Device Model:       L610(EU)
        IP:                 192.168.0.49
        MAC:                AC-15-A2-E1-D2-0D
        Device Id (hash):   cb7738b0b969254cdb0b07800e053413
        Owner (hash):       A6239CDED0B57178234D930F7063182A
        HW Ver:             None
        Supports IOT Cloud: True
        OBD Src:            tplink
        Factory Default:    False
        Encrypt Type:       KLAP
        Supports HTTPS:     False
        HTTP Port:          80
        LV (Login Level):   2

== Unsupported device ==
        Unable to parse discovery from device: 192.168.0.6: 1 validation error for DiscoveryResult
mgt_encrypt_schm
  field required (type=value_error.missing)

== Unsupported device ==
        Unable to parse discovery from device: 192.168.0.23: 1 validation error for DiscoveryResult
mgt_encrypt_schm
  field required (type=value_error.missing)

== Unsupported device ==
        Unable to parse discovery from device: 192.168.0.17: 1 validation error for DiscoveryResult
mgt_encrypt_schm
  field required (type=value_error.missing)

Found 1 devices
Found 3 unsupported devices
Found 10 devices that failed to authenticate
BettySwallocks commented 2 months ago

Just redone the kasa command with credentials for the non-working L510 bulb:

WARNING:kasa.smart.smartdevice:Error processing Firmware for device 192.168.0.59, module will be unavailable: get_latest_fw for Firmware (error_code=CLOUD_FAILED_ERROR)
== Hall Lamp - L510 ==
Host: 192.168.0.59
Port: 80
Device state: False
Time:         2024-08-16 15:15:14+00:00 (tz: {'timezone': 'Europe/London'}
Hardware:     3.0
Software:     1.1.8 Build 240510 Rel.103956
MAC (rssi):   3C:52:A1:B7:42:7B (-51)

== Primary features ==
State (state): False
Brightness (brightness): 50 (range: 0-100)

== Information ==
Signal Level (signal_level): 2
Overheated (overheated): False
Cloud connection (cloud_connection): False
Update available (update_available): None

== Configuration ==
Unable to read value (auto_update_enabled): get_latest_fw for Firmware (error_code=CLOUD_FAILED_ERROR)
Light preset (light_preset): Not set Brightness preset 1 Brightness preset 2 *Brightness preset 3* Brightness preset 4 Brightness preset 5
Smooth transition on (smooth_transition_on): 0 (range: 0-60)
Smooth transition off (smooth_transition_off): 0 (range: 0-60)

== Debug ==
Device ID (device_id): 8023DAC782C560CA7D3C2B985E631C3121AB092C
RSSI (rssi): -51 dBm
SSID (ssid): Epsilon
Reboot (reboot): <Action>
Current firmware version (current_firmware_version): 1.1.8 Build 240510 Rel.103956
Available firmware version (available_firmware_version): None
Device time (device_time): 2024-08-16 15:15:14+00:00

And the working .71 L510:

== Porch Study Side - L510 Series ==
Host: 192.168.0.71
Port: 80
Device state: False
Time:         2024-08-16 15:17:54+00:00 (tz: {'timezone': 'Europe/London'}
Hardware:     1.0
Software:     1.3.1 Build 20240630 Rel. 64117
MAC (rssi):   00:31:92:CA:B1:8F (-52)

== Primary features ==
State (state): False
Brightness (brightness): 50 (range: 0-100)

== Information ==
Signal Level (signal_level): 2
Overheated (overheated): False
Cloud connection (cloud_connection): True
Update available (update_available): False

== Configuration ==
Light preset (light_preset): Not set Brightness preset 1 Brightness preset 2 *Brightness preset 3* Brightness preset 4 Brightness preset 5

== Debug ==
Device ID (device_id): 8023363E843224458A4C51EC9340376D1E2CB1A8
RSSI (rssi): -52 dBm
SSID (ssid): Epsilon
On since (on_since): None
Reboot (reboot): <Action>
Current firmware version (current_firmware_version): 1.3.1 Build 20240630 Rel. 64117
Available firmware version (available_firmware_version): 1.3.1 Build 20240630 Rel. 64117
Device time (device_time): 2024-08-16 15:17:54+00:00
rytilahti commented 2 months ago

Okay, that's very helpful! Please do discover again and add --debug to the flags, locate the discovery response part for the 192.168.0.17, and paste it here.

This is the error that is causing the discovery to fail and thus not updating the config entry, I'd guess:

        Unable to parse discovery from device: 192.168.0.17: 1 validation error for DiscoveryResult
mgt_encrypt_schm
  field required (type=value_error.missing)

and it will require us to do changes in the library code to make it work.

BettySwallocks commented 2 months ago

No --debug available on the discover apparently:

PS C:\Users\Bob> kasa discover --help
Usage: kasa discover [OPTIONS]

  Discover devices in the network.

Options:
  --help  Show this message and exit.
PS C:\Users\Bob> kasa discover --debug
Usage: kasa discover [OPTIONS]
Try 'kasa discover --help' for help.

Error: No such option: --debug
rytilahti commented 2 months ago

It's an option for the kasa command (and not the discover sub-command), so you need to type kasa --debug discover :-) If you prefer, we can also debug this together on the homeassistant's discord server, I'm there with the same handle as here.

BettySwallocks commented 2 months ago

I think this is the .17 output you requested from the discover:

DEBUG:kasa.discover:Unable to parse discovery from device 192.168.0.17: {'error_code': 0,
 'result': {'channel_2g': '1',
            'channel_5g': '36',
            'device_id': 'REDACTED_9c5a77972ab992fdc89a93e',
            'device_model': 'S4',
            'device_type': 'HOMEWIFISYSTEM',
            'factory_default': False,
            'group_id': '95ab9b8e78395942a3f29beabda22d5c',
            'group_name': 'RXBzaWxvbg==',
            'hardware_version': '2.0',
            'ip': '192.168.0.17',
            'mac': '78:8C:B5:00:00:00',
            'master_device_id': '1dca819595b9786731663419ed4691a3',
            'need_account_digest': True,
            'owner': 'REDACTED_0b57178234d930f7063182a',
            'role': 'slave',
            'tmp_port': [20001]}}
DEBUG:kasa.discover:Unsupported device found at 192.168.0.17 << Unable to parse discovery from device: 192.168.0.17: 1 validation error for DiscoveryResult
mgt_encrypt_schm
  field required (type=value_error.missing)
== Unsupported device ==
        Unable to parse discovery from device: 192.168.0.17: 1 validation error for DiscoveryResult
mgt_encrypt_schm
  field required (type=value_error.missing)

I'll have to stay on here in text mode as I'm doing this in the background, while 'working'. ;-)

rytilahti commented 2 months ago

Okay, no worries. Ohh, that .17 is something completely else what we haven't seen before (HOMEWIFISYSTEM), so it's should not be relevant for P110.. I assume those two other (.6, .23) are also similar.

So am I understanding it correctly, you can control the device with the kasa tool just fine, but it just doesn't work in homeassistant? This is the .59, right? If you take a look into its discover response, how does it look like? Do you see the klap mentioned in it?

BettySwallocks commented 2 months ago

This is the .59 non-working L510 bulb from discover debug:

PS C:\Users\Bob> kasa --debug discover
Discovering devices on 255.255.255.255 for 5 seconds
DEBUG:kasa.discover:[DISCOVERY] 255.255.255.255 >> {'system': {'get_sysinfo': None}}
DEBUG:kasa.discover:Waiting 5 seconds for responses...
DEBUG:kasa.klaptransport:Created KLAP transport for 192.168.0.59
DEBUG:kasa.discover:[DISCOVERY] 192.168.0.59 << {'error_code': 0,
 'result': {'device_id': 'REDACTED_e58a935edcd8705d56c318c',
            'device_model': 'L510B(EU)',
            'device_type': 'SMART.TAPOBULB',
            'factory_default': False,
            'ip': '192.168.0.59',
            'is_support_iot_cloud': True,
            'mac': '3C-52-A1-00-00-00',
            'mgt_encrypt_schm': {'encrypt_type': 'KLAP',
                                 'http_port': 80,
                                 'is_support_https': False,
                                 'lv': 2},
            'obd_src': 'tplink',
            'owner': 'REDACTED_0B57178234D930F7063182A',
            'protocol_version': 1}}
DEBUG:kasa.device:Initializing 192.168.0.59 of type <class 'kasa.smart.smartdevice.SmartDevice'>
DEBUG:kasa.smartprotocol:192.168.0.59 multi-request-batch-1-of-1 >> '{"method":"multipleRequest","request_time_milis":1723821884412,"terminal_uuid":"d0rHmXcYKUpWGvCvL6zWVg==","params":{"requests":[{"method":"component_nego"},{"method":"get_device_info"},{"method":"get_connect_cloud_state"}]}}'
DEBUG:kasa.klaptransport:Starting handshake with 192.168.0.59
DEBUG:kasa.httpclient:Posting to http://192.168.0.59:80/app/handshake1
DEBUG:kasa.klaptransport:Handshake1 posted at 2024-08-16 16:24:44.441847. Host is 192.168.0.59, Responsestatus is 200, Request was 9fbe7b5757b41232bd7a8f0926f9446c
DEBUG:kasa.klaptransport:Handshake1 success at 2024-08-16 16:24:44.441847. Host is 192.168.0.59, Server remote_seed is: 0f4b1fea03f28d9fc7fa8fb9b9f4d19c, server hash is: 4d8d7541209ebf2b425b95e997ad85e596940b2952b9f192f9247703fb2b4244
DEBUG:kasa.klaptransport:Server response doesn't match our challenge on ip 192.168.0.59
DEBUG:kasa.smartprotocol:Unable to authenticate with 192.168.0.59, not retrying: Server response doesn't match our challenge on ip 192.168.0.59
== Authentication failed for device ==
        == Discovery Result ==
        Device Type:        SMART.TAPOBULB
        Device Model:       L510B(EU)
        IP:                 192.168.0.59
        MAC:                3C-52-A1-B7-42-7B
        Device Id (hash):   7e356175be58a935edcd8705d56c318c
        Owner (hash):       A6239CDED0B57178234D930F7063182A
        HW Ver:             None
        Supports IOT Cloud: True
        OBD Src:            tplink
        Factory Default:    False
        Encrypt Type:       KLAP
        Supports HTTPS:     False
        HTTP Port:          80
        LV (Login Level):   2

Thanks very much for all the help by the way - it's very much appreciated.

rytilahti commented 2 months ago

Sure thing! Okay, so it sounds to me that the username & the password are not correct in this case. If you didn't set the environment variables, you need to pass --username and --password also for the discovery to make it work, otherwise it will try to use hardcoded default credentials.

BettySwallocks commented 2 months ago

OK, discover with debug and credentials used. For non-working .59 L510 bulb:

DEBUG:kasa.klaptransport:Created KLAP transport for 192.168.0.59
DEBUG:kasa.discover:[DISCOVERY] 192.168.0.59 << {'error_code': 0,
 'result': {'device_id': 'REDACTED_e58a935edcd8705d56c318c',
            'device_model': 'L510B(EU)',
            'device_type': 'SMART.TAPOBULB',
            'factory_default': False,
            'ip': '192.168.0.59',
            'is_support_iot_cloud': True,
            'mac': '3C-52-A1-00-00-00',
            'mgt_encrypt_schm': {'encrypt_type': 'KLAP',
                                 'http_port': 80,
                                 'is_support_https': False,
                                 'lv': 2},
            'obd_src': 'tplink',
            'owner': 'REDACTED_0B57178234D930F7063182A',
            'protocol_version': 1}}
DEBUG:kasa.device:Initializing 192.168.0.59 of type <class 'kasa.smart.smartdevice.SmartDevice'>

And for working .71 L510 bulb:

DEBUG:kasa.smartprotocol:192.168.0.71 multi-request-batch-1-of-1 >> '{"method":"multipleRequest","request_time_milis":1723824455868,"terminal_uuid":"UWivlduPUwmVRVPeYtWWrg==","params":{"requests":[{"method":"component_nego"},{"method":"get_device_info"},{"method":"get_connect_cloud_state"}]}}'
DEBUG:kasa.klaptransport:Starting handshake with 192.168.0.71
DEBUG:kasa.httpclient:Posting to http://192.168.0.71:80/app/handshake1
DEBUG:kasa.klaptransport:Handshake1 posted at 2024-08-16 17:07:35.916415. Host is 192.168.0.71, Responsestatus is 200, Request was 7f0e903837a8b906e950d910950ccad2
DEBUG:kasa.klaptransport:Handshake1 success at 2024-08-16 17:07:35.916415. Host is 192.168.0.71, Server remote_seed is: 980d4651c459465190774651be5d4651, server hash is: 58c7d106f7da17df1fb7339796f3459aeca982ad6ef200009d66b2df56cb3508
DEBUG:kasa.klaptransport:handshake1 hashes match with expected credentials
DEBUG:kasa.httpclient:Posting to http://192.168.0.71:80/app/handshake2
DEBUG:kasa.klaptransport:Handshake2 posted 2024-08-16 17:07:35.935928.  Host is 192.168.0.71, Response status is 200, Request was 07b886d65c0c2b3469bae1d9b5c9b30cf9a6bb362cc4640bd3d91e35d34e9374
DEBUG:kasa.klaptransport:Handshake with 192.168.0.71 complete
DEBUG:kasa.httpclient:Posting to http://192.168.0.71:80/app/request
BettySwallocks commented 2 months ago

Sorry - there's more for .71:

DEBUG:kasa.klaptransport:Device 192.168.0.71 query posted Host is 192.168.0.71, Sequence is 1935767482, Response status is 200, Request was {"method":"multipleRequest","request_time_milis":1723824455868,"terminal_uuid":"UWivlduPUwmVRVPeYtWWrg==","params":{"requests":[{"method":"component_nego"},{"method":"get_device_info"},{"method":"get_connect_cloud_state"}]}}
DEBUG:kasa.klaptransport:Device 192.168.0.71 query response received
DEBUG:kasa.smartprotocol:192.168.0.71 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': 1},
                                                         {'id': 'quick_setup',
                                                          'ver_code': 3},
                                                         {'id': 'inherit',
                                                          'ver_code': 1},
                                                         {'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': 'brightness',
                                                          'ver_code': 1},
                                                         {'id': 'cloud_connect',
                                                          'ver_code': 1},
                                                         {'id': 'default_states',
                                                          'ver_code': 1},
                                                         {'id': 'preset',
                                                          'ver_code': 1},
                                                         {'id': 'bulb_quick_control',
                                                          'ver_code': 1}]}},
                          {'error_code': 0,
                           'method': 'get_device_info',
                           'result': {'avatar': 'bulb',
                                      'brightness': 50,
                                      'default_states': {'brightness': {'type': 'last_states',
                                                                        'value': 50}},
                                      'device_id': 'REDACTED_43224458A4C51EC9340376D1E2CB1A8',
                                      'device_on': False,
                                      'fw_id': '7BECA9DC454565672FEC87D1104F9972',
                                      'fw_ver': '1.3.1 Build 20240630 Rel. '
                                                '64117',
                                      'has_set_location_info': True,
                                      'hw_id': '93F94D88DA9499F43B929DD38EBDF09A',
                                      'hw_ver': '1.0',
                                      'ip': '192.168.0.71',
                                      'lang': 'en_US',
                                      'latitude': 0,
                                      'longitude': 0,
                                      'mac': '00-31-92-00-00-00',
                                      'model': 'L510 Series',
                                      'nickname': 'I01BU0tFRF9OQU1FIw==',
                                      'oem_id': 'REDACTED_CE8019B59D9E81CEDD371BD',
                                      'on_time': 0,
                                      'overheated': False,
                                      'region': 'Europe/London',
                                      'rssi': -49,
                                      'signal_level': 3,
                                      'specs': 'EU',
                                      'ssid': 'I01BU0tFRF9TU0lEIw=',
                                      'time_diff': 0,
                                      'type': 'SMART.TAPOBULB'}},
                          {'error_code': 0,
                           'method': 'get_connect_cloud_state',
                           'result': {'status': 0}}]}}
DEBUG:kasa.smart.smartdevice:Device 192.168.0.71, found required brightness, adding Brightness to modules.
DEBUG:kasa.smart.smartdevice:Device 192.168.0.71, found required cloud_connect, adding Cloud to modules.
DEBUG:kasa.smart.smartdevice:Device 192.168.0.71, found required device, adding DeviceModule to modules.
DEBUG:kasa.smart.smartdevice:Device 192.168.0.71, found required firmware, adding Firmware to modules.
DEBUG:kasa.smart.smartdevice:Device 192.168.0.71, found required preset, adding LightPreset to modules.
DEBUG:kasa.smart.smartdevice:Device 192.168.0.71, found required time, adding Time to modules.
DEBUG:kasa.smart.smartdevice:Querying 192.168.0.71 for modules: Firmware, LightPreset, Time
DEBUG:kasa.smartprotocol:192.168.0.71 multi-request-batch-1-of-1 >> '{"method":"multipleRequest","request_time_milis":1723824455998,"terminal_uuid":"UWivlduPUwmVRVPeYtWWrg==","params":{"requests":[{"method":"get_latest_fw"},{"method":"get_preset_rules"},{"method":"get_device_time"}]}}'
DEBUG:kasa.httpclient:Posting to http://192.168.0.71:80/app/request
BettySwallocks commented 2 months ago

And, more for .59:

DEBUG:kasa.smartprotocol:192.168.0.59 multi-request-batch-1-of-1 >> '{"method":"multipleRequest","request_time_milis":1723824457088,"terminal_uuid":"2k/p40gc/vFl2JJsvQ8TMg==","params":{"requests":[{"method":"component_nego"},{"method":"get_device_info"},{"method":"get_connect_cloud_state"}]}}'
DEBUG:kasa.klaptransport:Starting handshake with 192.168.0.59
DEBUG:kasa.httpclient:Posting to http://192.168.0.59:80/app/handshake1
DEBUG:kasa.klaptransport:Handshake1 posted at 2024-08-16 17:07:37.148197. Host is 192.168.0.59, Responsestatus is 200, Request was 97a41ab25c96f806865efca971f4d001
DEBUG:kasa.klaptransport:Handshake1 success at 2024-08-16 17:07:37.148197. Host is 192.168.0.59, Server remote_seed is: dc9c0adff06f9c70443a6679893c9097, server hash is: 89eb0bb9ea1c28321fa8df1c640755f9c3418d0e0f72a9f3cc153c2c1926fc6b
DEBUG:kasa.klaptransport:handshake1 hashes match with expected credentials
DEBUG:kasa.httpclient:Posting to http://192.168.0.59:80/app/handshake2
DEBUG:kasa.klaptransport:Handshake2 posted 2024-08-16 17:07:37.182067.  Host is 192.168.0.59, Response status is 200, Request was cb8b89498efdcfaa6561129937926cf2183dbcfc26ff4880be6c4bbca86184e0
DEBUG:kasa.klaptransport:Handshake with 192.168.0.59 complete
DEBUG:kasa.httpclient:Posting to http://192.168.0.59:80/app/request
DEBUG:kasa.klaptransport:Device 192.168.0.59 query posted Host is 192.168.0.59, Sequence is -1835272888, Response status is 200, Request was {"method":"multipleRequest","request_time_milis":1723824457088,"terminal_uuid":"2k/p40gc/vFl2JJsvQ8TMg==","params":{"requests":[{"method":"component_nego"},{"method":"get_device_info"},{"method":"get_connect_cloud_state"}]}}
DEBUG:kasa.klaptransport:Device 192.168.0.59 query response received
DEBUG:kasa.smartprotocol:192.168.0.59 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': 'inherit',
                                                          'ver_code': 1},
                                                         {'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': 'brightness',
                                                          'ver_code': 1},
                                                         {'id': 'cloud_connect',
                                                          'ver_code': 1},
                                                         {'id': 'default_states',
                                                          'ver_code': 1},
                                                         {'id': 'preset',
                                                          'ver_code': 1},
                                                         {'id': 'device_local_time',
                                                          'ver_code': 1},
                                                         {'id': 'iot_cloud',
                                                          'ver_code': 1},
                                                         {'id': 'bulb_quick_control',
                                                          'ver_code': 1},
                                                         {'id': 'on_off_gradually',
                                                          'ver_code': 3},
                                                         {'id': 'localSmart',
                                                          'ver_code': 1}]}},
                          {'error_code': 0,
                           'method': 'get_device_info',
                           'result': {'avatar': 'table_lamp_1',
                                      'brightness': 50,
                                      'color_temp_range': [2700, 2700],
                                      'default_states': {'brightness': {'type': 'last_states',
                                                                        'value': 50},
                                                         're_power_type': 'always_on'},
                                      'device_id': 'REDACTED_2C560CA7D3C2B985E631C3121AB092C',
                                      'device_on': False,
                                      'fw_id': '00000000000000000000000000000000',
                                      'fw_ver': '1.1.8 Build 240510 Rel.103956',
                                      'has_set_location_info': True,
                                      'hw_id': 'DEEB4A91620D147F373193A0A8215ACB',
                                      'hw_ver': '3.0',
                                      'ip': '192.168.0.59',
                                      'lang': 'en_US',
                                      'latitude': 0,
                                      'longitude': 0,
                                      'mac': '3C-52-A1-00-00-00',
                                      'model': 'L510',
                                      'music_rhythm_enable': False,
                                      'music_rhythm_mode': 'single_lamp',
                                      'nickname': 'I01BU0tFRF9OQU1FIw==',
                                      'oem_id': 'REDACTED_0FC0973513219EAE1861FDC',
                                      'overheated': False,
                                      'region': 'Europe/London',
                                      'rssi': -52,
                                      'signal_level': 2,
                                      'specs': '',
                                      'ssid': 'I01BU0tFRF9TU0lEIw=',
                                      'time_diff': 0,
                                      'type': 'SMART.TAPOBULB'}},
                          {'error_code': 0,
                           'method': 'get_connect_cloud_state',
                           'result': {'status': 1}}]}}
DEBUG:kasa.smart.smartdevice:Device 192.168.0.59, found required brightness, adding Brightness to modules.
DEBUG:kasa.smart.smartdevice:Device 192.168.0.59, found required cloud_connect, adding Cloud to modules.
DEBUG:kasa.smart.smartdevice:Device 192.168.0.59, found required device, adding DeviceModule to modules.
DEBUG:kasa.smart.smartdevice:Device 192.168.0.59, found required firmware, adding Firmware to modules.
DEBUG:kasa.smart.smartdevice:Device 192.168.0.59, found required preset, adding LightPreset to modules.
DEBUG:kasa.smart.smartdevice:Device 192.168.0.59, found required on_off_gradually, adding LightTransition to modules.
DEBUG:kasa.smart.smartdevice:Device 192.168.0.59, found required time, adding Time to modules.
DEBUG:kasa.smart.smartdevice:Querying 192.168.0.59 for modules: Firmware, LightPreset, LightTransition, Time
DEBUG:kasa.smartprotocol:192.168.0.59 multi-request-batch-1-of-2 >> '{"method":"multipleRequest","request_time_milis":1723824457351,"terminal_uuid":"2k/p40gc/vFl2JJsvQ8TMg==","params":{"requests":[{"method":"get_latest_fw"},{"method":"get_auto_update_info"},{"method":"get_preset_rules"},{"method":"get_on_off_gradually_info"},{"method":"get_device_time"}]}}'
DEBUG:kasa.httpclient:Posting to http://192.168.0.59:80/app/request
DEBUG:kasa.klaptransport:Device 192.168.0.59 query posted Host is 192.168.0.59, Sequence is -1835272887, Response status is 200, Request was {"method":"multipleRequest","request_time_milis":1723824457351,"terminal_uuid":"2k/p40gc/vFl2JJsvQ8TMg==","params":{"requests":[{"method":"get_latest_fw"},{"method":"get_auto_update_info"},{"method":"get_preset_rules"},{"method":"get_on_off_gradually_info"},{"method":"get_device_time"}]}}
DEBUG:kasa.klaptransport:Device 192.168.0.59 query response received
DEBUG:kasa.smartprotocol:192.168.0.59 multi-request-batch-1-of-2 << {'error_code': 0,
 'result': {'responses': [{'error_code': -1007, 'method': 'get_latest_fw'},
                          {'error_code': 0,
                           'method': 'get_auto_update_info',
                           'result': {'enable': True,
                                      'random_range': 120,
                                      'time': 180}},
                          {'error_code': 0,
                           'method': 'get_preset_rules',
                           'result': {'brightness': [1, 25, 50, 75, 100]}},
                          {'error_code': 0,
                           'method': 'get_on_off_gradually_info',
                           'result': {'off_state': {'duration': 2,
                                                    'enable': False,
                                                    'max_duration': 60},
                                      'on_state': {'duration': 2,
                                                   'enable': False,
                                                   'max_duration': 60}}},
                          {'error_code': 0,
                           'method': 'get_device_time',
                           'result': {'region': 'Europe/London',
                                      'time_diff': 0,
                                      'timestamp': 1723824462}}]}}
WARNING:kasa.smart.smartdevice:Error processing Firmware for device 192.168.0.59, module will be unavailable: get_latest_fw for Firmware (error_code=CLOUD_FAILED_ERROR)
DEBUG:kasa.smart.smartdevice:Update completed 192.168.0.59: ['component_nego', 'get_device_info', 'get_connect_cloud_state', 'get_latest_fw', 'get_auto_update_info', 'get_preset_rules', 'get_on_off_gradually_info', 'get_device_time']
== Hall Lamp - L510 ==
Host: 192.168.0.59
Port: 80
Device state: False
Time:         2024-08-16 16:07:42+00:00 (tz: {'timezone': 'Europe/London'}
Hardware:     3.0
Software:     1.1.8 Build 240510 Rel.103956
MAC (rssi):   3C:52:A1:B7:42:7B (-52)

== Primary features ==
State (state): False
Brightness (brightness): 50 (range: 0-100)

== Information ==
Signal Level (signal_level): 2
Overheated (overheated): False
Cloud connection (cloud_connection): False
Update available (update_available): None

== Configuration ==
Unable to read value (auto_update_enabled): get_latest_fw for Firmware (error_code=CLOUD_FAILED_ERROR)
Light preset (light_preset): Not set Brightness preset 1 Brightness preset 2 *Brightness preset 3* Brightness preset 4 Brightness preset 5
Smooth transition on (smooth_transition_on): 0 (range: 0-60)
Smooth transition off (smooth_transition_off): 0 (range: 0-60)

== Debug ==
Device ID (device_id): 8023DAC782C560CA7D3C2B985E631C3121AB092C
RSSI (rssi): -52 dBm
SSID (ssid): Epsilon
Reboot (reboot): <Action>
Current firmware version (current_firmware_version): 1.1.8 Build 240510 Rel.103956
Available firmware version (available_firmware_version): None
Device time (device_time): 2024-08-16 16:07:42+00:00

I hadn't realised the discovery would now return stuff so spread out across it's output.

rytilahti commented 2 months ago

The rest of the output is caused by the tool requesting the state of the device. So how I'm reading it is that it is working just fine using the tool, but not inside homeassistant. What I find odd is that the error was from the klap handshake which is now succeeding just fine? Are you using the same credentials for both homeassistant and for the tool?

BettySwallocks commented 2 months ago

Yes, same creds. In HA the tp-link Smart integration device page currently looks like this:

image

Each of the 'discovered; items fails with the same error after trying the configure button and entering the correct creds:

Connection error: Device 192.168.0.59 responded with unexpected klap response b'

200 OK
' to handshake1

BettySwallocks commented 2 months ago

I have just updated to HA 2024.8.2 and can confirm no change after that. I did see most of my Tapo products appear in a discovery and all bar 2 seemed to then load and connect in HA. Of the two that don't one is an L510 bulb the other is an L900-5 strip. They both continue to come up in discovery but then will never individually configure and produce the same error:

Connection error: Device 192.168.0.43 responded with unexpected klap response b'<html><body><center>200 OK</center></body></html>' to handshake1

Also I can reproduce the error with any of my working devices. If I choose to delete them and then re-discover, they will pop up in the list OK but then any further attempt to connect to them starts producing the above connection error. I have to reboot HA and allow it to re-discover them from scratch to get them to start working again,

L0bit0 commented 2 months ago

Hi

Sorry, I had a work peak and can not dedicate time to this on my last days.

Thanks, @BettySwallocks and @rytilahti to keep this.

I will try to get sometime during the week to do the phyton tool, but i do not have experience, so it will take me some time.

Meantime my two cents: I relaize the consumption data is updated only when HA start, then it is never updated til the next system restart:

image

Thanks

BettySwallocks commented 1 month ago

As a temporary solution I've routed all my TP-link Tapo lights via Samsung SmartThings. They connected fairly easily and work now in HA, but it's an extra hop in the solution that I'd like to avoid. I think it confirms that the issues I've had are to do with the tplink integration, my individual device firmware levels and possibly the AES/klap protocol changes.

L0bit0 commented 3 weeks ago

Hi

Any update here? this still not working since months and no clue if anyone is reviewing or fixing.

For me, this is an important functionality we have lost.. Any idea or recommendation?

Thanks

sdb9696 commented 2 weeks ago

@L0bit0 what kind of device is plugged into this P110? It looks to me like the earlier values prior to July are the more suspect ones. It seems the consumption jumps between <100W up to nearly 500W.

L0bit0 commented 1 week ago

hi

It is a refrigerator.

Anyway, I have some other devices, and it is happening the same: from around July 17th, power consumption is not updated: image NOTE: data changes after the issue are on HA restart, as it looks when HA restart is able to get consumption this time, then, it is not updated anymore.

NOTE2: not sure about the change of measures between May and June. I see two options, I changed form HACS integration to Tapo for the Official one, or is caused by HA historical data. Anyway, I don't care about this metrics anymore.

Thanks