8000 Cannot add Tapo Plug P110 to Home Assistant 2024.2.3 - Error in debug mode · Issue #797 · python-kasa/python-kasa · GitHub
[go: up one dir, main page]

Skip to content

Cannot add Tapo Plug P110 to Home Assistant 2024.2.3 - Error in debug mode #797

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

Closed
pplucky opened this issue Feb 26, 2024 · 6 comments · Fixed by #798
Closed

Cannot add Tapo Plug P110 to Home Assistant 2024.2.3 - Error in debug mode #797

pplucky opened this issue Feb 26, 2024 · 6 comments · Fixed by #798
Labels
bug Something isn't working

Comments

@pplucky
Copy link
pplucky commented Feb 26, 2024

Hello.

Looking at HA documentation, I supposed Tapo Plug P110 should be supported by TP-Link integration using authentication.

Still then, no matter how much I tried, I always get error message 'Failed to connect' after entering user + password (which I already checked to be working properly while logging directly into Tapo Cloud website or Tapo app).

Activating the HA logger level DEBUG, I got the following message which seems related:
[kasa.smartprotocol] Unable to query the device: 172.16.23.73, not retrying: Error querying device: 172.16.23.73: UNKNOWN_METHOD_ERROR(-1002) for method: get_current_power

Running kasa directly in HA docker:
kasa --host 172.16.23.73 --device-family SMART.TAPOPLUG --encrypt-type AES --username my-email@email.com --password my password

I get the following output:

Got error: SmartDeviceException('Error querying device: 172.16.23.73: UNKNOWN_METHOD_ERROR(-1002) for method: 
get_current_power')
ERROR    Unclosed client session                                                                          base_events.py:1805
         client_session: <aiohttp.client.ClientSession object at 0x7faa3ac3b0>                                               
ERROR    Unclosed connector                                                                               base_events.py:1805
         connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x7faa3b42f0>,                                     
         1816182.71097043)]']                                                                                                
         connector: <aiohttp.connector.TCPConnector object at 0x7faa3ac170> 

It is worth mentioning that the plug is currently with firmware version 1.0.7 (update to 1.3.0 is currently proposed via Tapo app), it works properly via Tapo app and it also works in another HA instance using a custom component.

For all this, it seems to me that this may be an issue in the integration.

Can anyone help further? If you need any further logs or additional info, please let me know.

Thanks in advance.

@pplucky pplucky changed the title Cannot add Tapo Plug P110 to Home Assistant 2024.2.4 - Error in debug mode Cannot add Tapo Plug P110 to Home Assistant 2024.2.3 - Error in debug mode Feb 26, 2024
@rytilahti
Copy link
Member
rytilahti commented Feb 26, 2024

Hi,

Your error messages are definitely related, the device is reporting that it doesn't support that command which is used to query the energy meter information. Would you mind trying if it works with the current git master branch? I also have a P110 that I have been using for development, and it is working just fine.

You could also try to run the dump_devinfo devtools script (python -m devtools.dump_devinfo --host 172.16.23.73 inside the checkout directory) to see how it differs from the output from mine which has this method supported - for the release that is used by homeassistant, we used the existence of energy_monitoring to decide if we perform that request.

Was yours marketed with energy monitoring, and is it also working? Do you have a different hw or sw version reported by the cli tool?

@rytilahti rytilahti added the bug Something isn't working label Feb 26, 2024
@pplucky
Copy link
Author
pplucky commented Feb 27, 2024

Hi there.

Would you mind trying if it works with the current git master branch? I also have a P110 that I have been using for development, and it is working just fine.

Running the same command under current git master branch (installed with poetry), I get no error anymore, but instead (redacted personal information):

== Mosquitos Diogo - P110 ==
        Host: 172.16.23.73
        Port: 80
        Device state: False
        == Generic information ==
        Time:         2024-02-26 23:39:44+00:00 (tz: {'timezone': 'Europe/Lisbon'}
        Hardware:     1.0
        Software:     1.0.7 Build 210629 Rel.174901
        MAC (rssi):   AA:BB:CC:DD:EE:FF (-56)
        Location:     {'latitude': 0.0, 'longitude': 0.0}

        == Device specific information ==
        overheated: False
        signal_level: 2
        SSID: MY_SSID

        == Features == 
        Device ID (device_id): MY_DEVICE_ID
        State (state): False
        Signal Level (signal_level): 2
        RSSI (rssi): -56
        SSID (ssid): MY_SSID
        Overheated (overheated): False
        Overheated (overheated): False
        On since (on_since): None
        Cloud connection (cloud_connection): True
        Current consumption (current_consumption): 0.0
        Today's consumption (today's_consumption): 0
        This month's consumption (this_month's_consumption): 0
        Auto update enabled (auto_update_enabled): False
        Update available (update_available): True
        LED (led): False
        Time (time): 2024-02-26 23:39:44+00:00

        == Current State ==
        <EmeterStatus power=0.0 voltage=None current=None total=0>

        == Modules ==
        + <Module CloudModule (cloud_connect) for 172.16.23.73>
        + <Module DeviceModule (device) for 172.16.23.73>
        + <Module EnergyModule (energy_monitoring) for 172.16.23.73>
        + <Module Firmware (firmware) for 172.16.23.73>
        + <Module LedModule (led) for 172.16.23.73>
        + <Module TimeModule (time) for 172.16.23.73>

You could also try to run the dump_devinfo devtools script (python -m devtools.dump_devinfo --host 172.16.23.73 inside the checkout directory) to see how it differs from the output from mine which has this method supported - for the release that is used by homeassistant, we used the existence of energy_monitoring to decide if we perform that request.

Here is mine:
P110(EU)_1.0_1.0.7.json

There are definitely quite some differences, some eventually caused by the fw version in each? If needed, I have a spare (another) P110, which I can upgrade to latest fw version (1.3.0), to check if it works better.

Was yours marketed with energy monitoring, and is it also working? Do you have a different hw or sw version reported by the cli tool?

Yes, definitely supporting energy monitoring, and data is showing in Tapo app (even though 0).
telegram-cloud-photo-size-4-5974388947591217326-y

Hardware and Software versions in Tapo app fit exactly what is reported (above) by cli
telegram-cloud-photo-size-4-5974388947591217321-y

Please let me know if you need anything else.

@sdb9696
Copy link
Collaborator
sdb9696 commented Feb 27, 2024

I think there are a couple of issues here:

  1. get_current_power is supported by the power_protection component rather than the energy_monitoring component so we shouldn't be calling it in the energy module.
  2. The latest master version of the library is a bit more robust than 0.6.2.1 so it doesn't completely fail if one query fails. However the device stops responding to requests that come after errors, so I'm not sure how the cli output above was achieved at all. When I tested my P110 with an invalid method name the cli failed because the time component had not been initialised.
  3. @pplucky are you querying the actual energy results in the cli vs the Tapo app? They look the same to me as I think the app just display zeros as <1 in the energy usage and current power columns.

@rytilahti
Copy link
Member
rytilahti commented Feb 27, 2024

Thanks for the fixture file, @pplucky, that's really helpful, and we should add it to our fixture collection! You could definitely try to perform a firmware update, that should fix it for you, but we should also fix this in the library.

@sdb9696

get_current_power is supported by the power_protection component rather than the energy_monitoring component so we shouldn't be calling it in the energy module.

I think get_max_power and get_protection_power are likely for power_protection, no? Looking at the diff (diff P110.EU._1.0_1.0.7.json P110\(EU\)_1.0_1.2.3.json), the older firmware has energy_monitoring version 1 where-as the newer reports 2, so maybe we should just check for the version like we are doing for gradual on/off?

rytilahti added a commit that referenced this issue Feb 27, 2024
@pplucky
Copy link
Author
pplucky commented Feb 27, 2024
  1. The latest master version of the library is a bit more robust than 0.6.2.1 so it doesn't completely fail if one query fails. However the device stops responding to requests that come after errors, so I'm not sure how the cli output above was achieved at all. When I tested my P110 with an invalid method name the cli failed because the time component had not been initialised.

Beats me, also. The fact is that when using kasa from the latest master (installed via poetry after git clone), I managed to get that output.

  1. @pplucky are you querying the actual energy results in the cli vs the Tapo app? They look the same to me as I think the app just display zeros as <1 in the energy usage and current power columns.

I plugged something that would actually consume energy and here is output from Tapo app:
image

and the cli output:

Current consumption (current_consumption): 0.0
Today's consumption (today's_consumption): 0.387
This month's consumption (this_month's_consumption): 0.387

or when calling emeter command:

== Emeter ==
Current: None A
Voltage: None V
Power: 0.0 W
Total consumption: 0.387 kWh
Today: 0.387 kWh
This month: 0.387 kWh

Btw, is it normal that the Current and Voltage are both None?

This also seems to happen for the other P110 plug I have (which is in 1.1.5 and had no issues in being added to HA). In HA, no current and voltage sensors exist.

Now that I notice, I also didn't have these in the previous Tapo custom component, but just out of curiosity, I had 2 additional sensors:
image

image

These were probably obtained from device info properties overheated and rssi.

Please let me know if there's anything else you need/want me to check for this 1.0.7 plug before I upgrade its firmware ;-).

@rytilahti
Copy link
Member

Btw, is it normal that the Current and Voltage are both None?

Yes, the device doesn't report this information. We are moving to a more dynamic approach for presenting the available information (see below) so this can be ignored for now.

These were probably obtained from device info properties overheated and rssi.

Yes they are. We are moving towards supporting more devices and more features directly out-of-the-box but it involves lots of changes, targeting currently homeassistant 2024.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
0