JurajNyiri / HomeAssistant-Tapo-Control

Control for Tapo cameras as a Home Assistant component
Apache License 2.0
953 stars 80 forks source link

Startup time too high #543

Closed gilcu3 closed 3 months ago

gilcu3 commented 3 months ago

Description

Recently homeassistant added a way to measure startup time per integration. After checking that, it seems that this integration takes 11s to start in my environment. I have only two cameras, C100 and C200.

Reproduction Steps

  1. Start homeassistant

Expected behavior

Shouldn't it be much faster?

If applicable, add error logs.

Apr 04 17:18:39 rpi5 hass[41830]: 2024-04-04 17:18:39.081 WARNING (MainThread) [homeassistant.components.light] None (<class 'custom_components.tapo_control.light.TapoWhitelight'>) does not set supported color modes, this will stop working in Home Assistant Core 2025.3, please create a bug report at https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/issues
Apr 04 17:18:51 rpi5 hass[41830]: 2024-04-04 17:18:51.452 WARNING (MainThread) [homeassistant.components.select] Setup of select platform tapo_control is taking over 10 seconds.

Device Firmware

1.3.11 Build 231115 Rel.85400n(4555)

Integration Version

5.4.17

Using stream component

Yes

Does camera work via official integrations?

Yes

Camera has all attributes filled out in developer tools

Yes

HASS Environment

core

Search for similar issues

Yes

Additional information

Sometimes I also get this:

Apr 04 17:33:58 rpi5 hass[42256]: 2024-04-04 17:33:58.015 WARNING (MainThread) [homeassistant.components.select] Setup of select platform tapo_control is taking over 10 seconds.
Apr 04 17:33:59 rpi5 hass[42256]: 2024-04-04 17:33:59.219 ERROR (MainThread) [custom_components.tapo_control] Unable to connect to Tapo: Cameras Control controller: cannot access local variable 'responseJSON' wh
Apr 04 17:34:08 rpi5 hass[42256]: 2024-04-04 17:34:08.382 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry tapo_c100 for camera
Apr 04 17:34:08 rpi5 hass[42256]: Traceback (most recent call last):
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/config_entries.py", line 551, in async_setup
Apr 04 17:34:08 rpi5 hass[42256]:     result = await component.async_setup_entry(hass, self)
Apr 04 17:34:08 rpi5 hass[42256]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/components/camera/__init__.py", line 470, in async_setup_entry
Apr 04 17:34:08 rpi5 hass[42256]:     return await component.async_setup_entry(entry)
Apr 04 17:34:08 rpi5 hass[42256]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/helpers/entity_component.py", line 187, in async_setup_entry
Apr 04 17:34:08 rpi5 hass[42256]:     raise ValueError("Config entry has already been setup!")
Apr 04 17:34:08 rpi5 hass[42256]: ValueError: Config entry has already been setup!
Apr 04 17:34:08 rpi5 hass[42256]: 2024-04-04 17:34:08.384 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry tapo_c100 for switch
Apr 04 17:34:08 rpi5 hass[42256]: Traceback (most recent call last):
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/config_entries.py", line 551, in async_setup
Apr 04 17:34:08 rpi5 hass[42256]:     result = await component.async_setup_entry(hass, self)
Apr 04 17:34:08 rpi5 hass[42256]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/components/switch/__init__.py", line 100, in async_setup_entry
Apr 04 17:34:08 rpi5 hass[42256]:     return await component.async_setup_entry(entry)
Apr 04 17:34:08 rpi5 hass[42256]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/helpers/entity_component.py", line 187, in async_setup_entry
Apr 04 17:34:08 rpi5 hass[42256]:     raise ValueError("Config entry has already been setup!")
Apr 04 17:34:08 rpi5 hass[42256]: ValueError: Config entry has already been setup!
Apr 04 17:34:08 rpi5 hass[42256]: 2024-04-04 17:34:08.388 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry tapo_c100 for button
Apr 04 17:34:08 rpi5 hass[42256]: Traceback (most recent call last):
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/config_entries.py", line 551, in async_setup
Apr 04 17:34:08 rpi5 hass[42256]:     result = await component.async_setup_entry(hass, self)
Apr 04 17:34:08 rpi5 hass[42256]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/components/button/__init__.py", line 73, in async_setup_entry
Apr 04 17:34:08 rpi5 hass[42256]:     return await component.async_setup_entry(entry)
Apr 04 17:34:08 rpi5 hass[42256]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/helpers/entity_component.py", line 187, in async_setup_entry
Apr 04 17:34:08 rpi5 hass[42256]:     raise ValueError("Config entry has already been setup!")
Apr 04 17:34:08 rpi5 hass[42256]: ValueError: Config entry has already been setup!
Apr 04 17:34:08 rpi5 hass[42256]: 2024-04-04 17:34:08.389 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry tapo_c100 for light
Apr 04 17:34:08 rpi5 hass[42256]: Traceback (most recent call last):
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/config_entries.py", line 551, in async_setup
Apr 04 17:34:08 rpi5 hass[42256]:     result = await component.async_setup_entry(hass, self)
Apr 04 17:34:08 rpi5 hass[42256]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/components/light/__init__.py", line 679, in async_setup_entry
Apr 04 17:34:08 rpi5 hass[42256]:     return await component.async_setup_entry(entry)
Apr 04 17:34:08 rpi5 hass[42256]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/helpers/entity_component.py", line 187, in async_setup_entry
Apr 04 17:34:08 rpi5 hass[42256]:     raise ValueError("Config entry has already been setup!")
Apr 04 17:34:08 rpi5 hass[42256]: ValueError: Config entry has already been setup!
Apr 04 17:34:08 rpi5 hass[42256]: 2024-04-04 17:34:08.391 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry tapo_c100 for number
Apr 04 17:34:08 rpi5 hass[42256]: Traceback (most recent call last):
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/config_entries.py", line 551, in async_setup
Apr 04 17:34:08 rpi5 hass[42256]:     result = await component.async_setup_entry(hass, self)
Apr 04 17:34:08 rpi5 hass[42256]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/components/number/__init__.py", line 120, in async_setup_entry
Apr 04 17:34:08 rpi5 hass[42256]:     return await component.async_setup_entry(entry)
Apr 04 17:34:08 rpi5 hass[42256]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/helpers/entity_component.py", line 187, in async_setup_entry
Apr 04 17:34:08 rpi5 hass[42256]:     raise ValueError("Config entry has already been setup!")
Apr 04 17:34:08 rpi5 hass[42256]: ValueError: Config entry has already been setup!
Apr 04 17:34:08 rpi5 hass[42256]: 2024-04-04 17:34:08.393 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry tapo_c100 for select
Apr 04 17:34:08 rpi5 hass[42256]: Traceback (most recent call last):
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/config_entries.py", line 551, in async_setup
Apr 04 17:34:08 rpi5 hass[42256]:     result = await component.async_setup_entry(hass, self)
Apr 04 17:34:08 rpi5 hass[42256]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/components/select/__init__.py", line 110, in async_setup_entry
Apr 04 17:34:08 rpi5 hass[42256]:     return await component.async_setup_entry(entry)
Apr 04 17:34:08 rpi5 hass[42256]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/helpers/entity_component.py", line 187, in async_setup_entry
Apr 04 17:34:08 rpi5 hass[42256]:     raise ValueError("Config entry has already been setup!")
Apr 04 17:34:08 rpi5 hass[42256]: ValueError: Config entry has already been setup!
Apr 04 17:34:08 rpi5 hass[42256]: 2024-04-04 17:34:08.394 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry tapo_c100 for siren
Apr 04 17:34:08 rpi5 hass[42256]: Traceback (most recent call last):
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/config_entries.py", line 551, in async_setup
Apr 04 17:34:08 rpi5 hass[42256]:     result = await component.async_setup_entry(hass, self)
Apr 04 17:34:08 rpi5 hass[42256]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/components/siren/__init__.py", line 154, in async_setup_entry
Apr 04 17:34:08 rpi5 hass[42256]:     return await component.async_setup_entry(entry)
Apr 04 17:34:08 rpi5 hass[42256]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/helpers/entity_component.py", line 187, in async_setup_entry
Apr 04 17:34:08 rpi5 hass[42256]:     raise ValueError("Config entry has already been setup!")
Apr 04 17:34:08 rpi5 hass[42256]: ValueError: Config entry has already been setup!
Apr 04 17:34:08 rpi5 hass[42256]: 2024-04-04 17:34:08.396 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry tapo_c100 for update
Apr 04 17:34:08 rpi5 hass[42256]: Traceback (most recent call last):
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/config_entries.py", line 551, in async_setup
Apr 04 17:34:08 rpi5 hass[42256]:     result = await component.async_setup_entry(hass, self)
Apr 04 17:34:08 rpi5 hass[42256]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/components/update/__init__.py", line 123, in async_setup_entry
Apr 04 17:34:08 rpi5 hass[42256]:     return await component.async_setup_entry(entry)
Apr 04 17:34:08 rpi5 hass[42256]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/helpers/entity_component.py", line 187, in async_setup_entry
Apr 04 17:34:08 rpi5 hass[42256]:     raise ValueError("Config entry has already been setup!")
Apr 04 17:34:08 rpi5 hass[42256]: ValueError: Config entry has already been setup!
Apr 04 17:34:08 rpi5 hass[42256]: 2024-04-04 17:34:08.397 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry tapo_c100 for binary_sensor
Apr 04 17:34:08 rpi5 hass[42256]: Traceback (most recent call last):
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/config_entries.py", line 551, in async_setup
Apr 04 17:34:08 rpi5 hass[42256]:     result = await component.async_setup_entry(hass, self)
Apr 04 17:34:08 rpi5 hass[42256]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/components/binary_sensor/__init__.py", line 239, in async_setup_entry
Apr 04 17:34:08 rpi5 hass[42256]:     return await component.async_setup_entry(entry)
Apr 04 17:34:08 rpi5 hass[42256]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/helpers/entity_component.py", line 187, in async_setup_entry
Apr 04 17:34:08 rpi5 hass[42256]:     raise ValueError("Config entry has already been setup!")
Apr 04 17:34:08 rpi5 hass[42256]: ValueError: Config entry has already been setup!
Apr 04 17:34:08 rpi5 hass[42256]: 2024-04-04 17:34:08.399 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry tapo_c100 for sensor
Apr 04 17:34:08 rpi5 hass[42256]: Traceback (most recent call last):
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/config_entries.py", line 551, in async_setup
Apr 04 17:34:08 rpi5 hass[42256]:     result = await component.async_setup_entry(hass, self)
Apr 04 17:34:08 rpi5 hass[42256]:              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/components/sensor/__init__.py", line 139, in async_setup_entry
Apr 04 17:34:08 rpi5 hass[42256]:     return await component.async_setup_entry(entry)
Apr 04 17:34:08 rpi5 hass[42256]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Apr 04 17:34:08 rpi5 hass[42256]:   File "/home/homeassistant/.homeassistant/venv312/lib/python3.12/site-packages/homeassistant/helpers/entity_component.py", line 187, in async_setup_entry
Apr 04 17:34:08 rpi5 hass[42256]:     raise ValueError("Config entry has already been setup!")
Apr 04 17:34:08 rpi5 hass[42256]: ValueError: Config entry has already been setup!
JurajNyiri commented 3 months ago

Startup time depends on camera and also onvif communication initiation.

gilcu3 commented 3 months ago

Startup time depends on camera and also onvif communication initiation.

I have both connected to the same local network. Does your answer mean that this is kinda normal behavior, or is there anything to do to improve it?

JurajNyiri commented 3 months ago

Yes it is normal behaviour. There might be space to refactor and improve but that is very low priority at this point.