JurajNyiri / HomeAssistant-Tapo-Control

Control for Tapo cameras as a Home Assistant component
Apache License 2.0
1.15k stars 90 forks source link

light.turn_off `all` results in `TypeError: bool object not subscriptable` in tapo_control #693

Closed rct closed 3 weeks ago

rct commented 1 month ago

Description

If light.turn_off is called with entity_id: all, it will generateTypeError: 'bool' object is not subscriptable` in tapo_control

Reproduction Steps

To reproduce, need a tapo camera that has a light entity. Then call light.turn_off from developer tools -> actions

# YAML snippet for Developer Tools -> Actions
action: light.turn_off
data: {}
target:
  entity_id: all

Expected behavior

Tapo controls should not be able to make light.turn_off for all entities fail.

If applicable, add error logs.

Logger: homeassistant.helpers.script.websocket_api_script
Source: helpers/script.py:525
First occurred: 11:31:47 AM (2 occurrences)
Last logged: 11:31:54 AM

websocket_api script: Error executing script. Unexpected error for call_service at pos 1: 'bool' object is not subscriptable
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 525, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 763, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 726, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2761, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2804, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1021, in entity_service_call
    raise result from None
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1610, in async_request_call
    return await coro
           ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1068, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 639, in async_handle_light_off_service
    await light.async_turn_off(**filter_turn_off_params(light, params))
  File "/config/custom_components/tapo_control/light.py", line 95, in async_turn_off
    if str(camData["whitelampStatus"]) == "1":
           ~~~~~~~^^^^^^^^^^^^^^^^^^^
TypeError: 'bool' object is not subscriptable

Device Firmware

1.2.2 Build 240905 Rel.41780n

Integration Version

5.6.3

Using stream component

No

Does camera work via official integrations?

Yes

Camera has all attributes filled out in developer tools

Yes

HASS Environment

Home Assistant OS in VM on x86_64 (KVM)

Search for similar issues

Yes

Additional information

Only cameras connected right now are two C120's with the same firmware version.

rct commented 4 weeks ago

Some notes from additional testing. I get the same TypeError: 'bool' object is not subscriptable error when trying to turn the light entity on for one of my C120's. The light entity for the other C120 works correctly.

JurajNyiri commented 3 weeks ago

Fixed in https://github.com/JurajNyiri/HomeAssistant-Tapo-Control/releases/tag/5.7.2