[Custom Component] Tapo P100 Plug Control

I get that message @viciovb and other messages (see below).
I had fishbigger’s Tapo-P100-Control running on my Raspberry, but then decided to test petretiandrea’s tapo integration. With the 1st I used the configuration.yaml ok. With the 2nd I can only get the devices by “Add Integration”; if I put them in the configuration.yaml, I get these errors -
One of these lines per device in the configuration.yaml -

2022-01-24 14:05:31 WARNING (MainThread) [homeassistant.components.switch] Setup of switch platform tapo is taking over 10 seconds.

Then -

2022-01-24 14:05:31 ERROR (MainThread) [custom_components.tapo.common_setup] Error fetching tapo data:

Then a set of these per device -

2022-01-24 14:05:31 ERROR (MainThread) [homeassistant.components.switch] Error while setting up tapo platform for switch
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/tapo/switch.py", line 28, in async_setup_platform
coordinator = await setup_tapo_coordinator_from_dictionary(hass, config)
File "/config/custom_components/tapo/common_setup.py", line 31, in setup_tapo_coordinator_from_dictionary
return await setup_tapo_coordinator(
File "/config/custom_components/tapo/common_setup.py", line 60, in setup_tapo_coordinator
raise Exception("Failed to retrieve first tapo data")
Exception: Failed to retrieve first tapo data

Anyone got any ideas on this?
I will go back to fishbiggers, and see if that works on this test system.

Have exactly the same situation: switched plugins from Fishbigger to Pedro, and now the same errors.

Also some plugs randomly disappearing, which need pulling out and back to reconnect.

Not had a chance to investigate much (still broadly works…), but +1

Can you provide the version of Home Assistant, the model of Raspberry Pi and version of integration. Thanks. @IanD3 @Rahaaas.

Also, if you are using configuration.yml, please post here it and be sure you are using tapo as platform and not tapo_p100_control.

The platform is not tapo_p100_control. If you are using my integration, the platform is tapo. GitHub - petretiandrea/home-assistant-tapo-p100: A custom integration to control Tapo devices from home assistant.

Hi Pedro, I am using the tapo platform, not fishbiggers tapo_p100_control.
My HA is running on an a PC running Virtualbox, in an Ubuntu 20.04 Virtual Machine - that seems to work ok (mostly).
When I look at Integrations, I see “information” :

v1.2.2
@petretiandrea
# Home Assistant Tapo Integration
This is a custom integration to control Tapo devices from home assistant.
The core of the integration is provied by plugp100 python library based on work of @K4CZP3R.

My /HomeAssistant/configuration.yaml contains :

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

# Tapo P100 plugs
switch 1:
    platform: tapo
    ip_address: ipaddress
    email: xxx@yyy
    password: ****************
switch 2:
    platform: tapo
    ip_address: ipaddress
    email: xxx@yyy
    password: ****************

Where :

  • ipaddress is each devices IP address ala 192.n.n.n
  • xxx@yyy is my Tapo email address
  • **************** is my Tapo password

Regards, Ian

Hi Pedro,

Apologies - intending to get a proper GitHub bug report in…

HA 2021.12.10, running on HA OS, on a Pi 4 8GB. Using the frontend integration, and have commented out any other references in the config.

I’m getting a lot of:

Logger: custom_components.tapo.common_setup
Source: helpers/update_coordinator.py:219
Integration: Tapo Controller (documentation, issues)
First occurred: 22 January 2022, 09:33:02 (69 occurrences)
Last logged: 05:30:06

Error fetching tapo data:

…as well as…

Logger: homeassistant.helpers.service
Source: helpers/service.py:129
First occurred: 22 January 2022, 09:33:59 (19 occurrences)
Last logged: 04:06:51

** Unable to find referenced entities switch.tapo_15*
** Unable to find referenced entities light.aquarium_spot_rgbw*
** Unable to find referenced entities switch.lg_tv*
** Unable to find referenced entities media_player.rb_study_sonos*

…and…

Logger: homeassistant.components.switch.reproduce_state
Source: components/switch/reproduce_state.py:38
Integration: Switch (documentation, issues)
First occurred: 12:29:36 (1 occurrences)
Last logged: 12:29:36

Invalid state specified for switch.tapo_01: unavailable

I’ve news regarding “Invalid authentication” error. A GitHub user seems to be found an issue on username capitalization. For more information and how to resolve, please refer to this new issue Invalid authentication · Issue #122 · petretiandrea/home-assistant-tapo-p100 · GitHub.

This message leads me to think of a network problem. Stupid questions:

  • Can you ping your tapo device from virtual machine?
  • Your email contains a capital letter? (see on settings section of Tapo App)
  • Have you try using UI configurator?

I need to see your configuration.yml if you are adding devices without UI setup.

Unable to find referenced

This message suggests to me that there is something of broken in your configuration or something else

To clarify, I’m using the UI configflow, NOT the YAML. I’ll double-check later, but there shouldn’t be any reference in there at all.

Curiously everything is actually working as expected, so wondering if there’s a duplicate entry in the backend. Will investigate that too.

Also noticed that the integration isn’t listed in HACS, as of the latest HACS update. Again, didn’t break anything, and back once I readded it.

Hi Pedro, In answer -

  • Yes I can ping them
  • My email address does not have capitals in it. (gmail does not seem to care if you use caps, and my configuration.yaml has them all in lower case.
  • I had 2 working with the UI, I then deleted them, as 1) they did not show up in the configuration.yaml and 2) I wanted to add them all in the file.
  • After I deleted those two, I think something has got messed up under the covers. If I add them in the UI now, I get -
  • Log entries :
2022-01-25 11:59:27 ERROR (MainThread) [custom_components.tapo.common_setup] Error fetching tapo data:
2022-01-25 11:59:27 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Lounge brass lamp' for tapo integration not ready yet: None; Retrying in background
2022-01-25 11:59:33 ERROR (MainThread) [custom_components.tapo.common_setup] Error fetching tapo data:
2022-01-25 11:59:44 ERROR (MainThread) [custom_components.tapo.common_setup] Error fetching tapo data:
2022-01-25 12:00:06 ERROR (MainThread) [custom_components.tapo.common_setup] Error fetching tapo data:
  • On the dashboard -
    Clipboard 1

FYI - another hole I fell in…
Just for fun (!?!?!) I have installed the HA os VM (using Virtualbox).
See : https://www.home-assistant.io/installation/linux
Using - haos_ova-7.2.vdi
And after installing HACS, I can not add a custom repository.
This appears to be the issue - https://github.com/hacs/integration/issues/2451
I am getting a little worn out keep bumping into showstoppers with HA… Sigh…
Maybe tomorrow will go better…

and more weirdly, the “custom repository” option is no longer greyed out…
So I added the repo, and installed Tapo Controller. Restarted HA. Edited the configuration.yaml and restarted again…
I am now at the same point on the HA os VM (Virtualbox) as I was with Ubuntu VM :
Errors in the logs as above ("ERROR (MainThread) [custom_components.tapo.common_setup] Error fetching tapo data:").

Can you try this snippet of code? And report the output

import asyncio
from plugp100 import TapoApiClient


async def main():
    # create generic tapo api
    sw = TapoApiClient("<ip>", "<email>", "<passwd>")
    await sw.login()
    print(await sw.get_state())

loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.run_until_complete(asyncio.sleep(0.1))
loop.close()

Hi! I’m reporting the “invalid authentication” issues even with lower case email and 8 digit password.
I also noticed that even if I type in lower case my email, the tapo app shows it with the first capital letter.

is there any check that i can do to correctly integrate these plugs in my HA?

I am also getting this error:
ERROR (MainThread) [custom_components.tapo.common_setup] Error fetching tapo data:

It started when I upgraded the firmware of the Tapo P100 plug. Is it a coincidence or there is a problem with the latest firmware version?

1 Like

If tapo app show your email with a capital letter, seems that the integration won’t work. Follow this issue and the nested one to see how a user has fixed this problem temporary https://github.com/petretiandrea/home-assistant-tapo-p100/issues/122. Spoiler: it create a new account

Which version of firmware do you have?

Hi Pedro, sorry being an HA noob, it took me a while.
I have used pyscript to run the code - I assume that is ok.
I get :

2022-01-27 14:59:40 ERROR (MainThread) [homeassistant] Error doing job: Unclosed client session

2022-01-27 14:59:40 ERROR (MainThread) [custom_components.pyscript.file.tapo-test] Exception in </config/pyscript/tapo-test.py> line 11:

print(await sw.get_state())

^

TypeError: object TapoDeviceState can't be used in 'await' expression

2022-01-27 15:01:20 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140090319703728] Error handling message: Service pyscript:tapo-test does not match format <domain>.<name> for dictionary value @ data['sequence'][0]['service']. Got 'pyscript:tapo-test'

Line 11, as I added a print to try and avoid the “does not match format <domain>.<name>” error - which I think is when the script returns nothing.
I did this after deleting the one device I had added in the UI, and with no tapo devices in the configuration.yaml; and after a restart.
I then added a device using the UI, and I still get the same errors.
The “Unclosed client session” looks a worry !?

I have also now run this from a userid in an Ubuntu terminal window -

f759................................f718
TapoDeviceState(device_id='80224.....................0EC2', mac='C0-06-C3-F5-1D-F4', nickname='lamp 9', model='P100', type='SMART.TAPOPLUG', device_on=False, brightness=None, hue=None, saturation=None, color_temp=None, overheated=False, signal_level=1, rssi=-70, energy_info=None)
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f60131e35b0>

I have put the dots in above, as I was not sure what was coded in those strings…
AGAIN I see a “Unclosed client session” error. That was straight after a reboot too.
Does this help? Cheers, Ian
.

1.4.9 Build 20210621 Rel. 30941