core: [BUG] TypeError: 'Status' object is not subscriptable
The problem
While creating a new ZHA Quirk: https://github.com/zigpy/zha-device-handlers/issues/1302#issuecomment-1090904325 this error appeared:
2022-04-06 23:10:57 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140094030063840] 'Status' object is not subscriptable
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 193, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1634, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1671, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
await service.entity_service_call(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 677, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 955, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 714, in _handle_entity_call
await result
File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 504, in async_handle_light_on_service
await light.async_turn_on(**filter_turn_on_params(light, params))
File "/usr/src/homeassistant/homeassistant/components/zha/light.py", line 258, in async_turn_on
if isinstance(result, Exception) or result[1] is not Status.SUCCESS:
TypeError: 'Status' object is not subscriptable
What version of Home Assistant Core has the issue?
core-2022.4.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
ZHA?
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
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 28 (17 by maintainers)
I think there seems to be some slight problem with this implementation that is unrelated to the recent zigpy changes. Is your command being overridden just to prevent the manufacturer code from being sent? If so, I think you don’t need to manually return any status codes or construct any default responses, just
return await super().command(...is enough.Something like this:
@javicalle Ok, now when trying to dimm the log shows this:
The dimmer doesn’t do anything.
Aaaaargh! My fault. Remove the
zcl.. Already fixed in comment.ZHA was explicitly checking
isinstance(rsp, list)to handle some types of responses, which was buggy behavior and masked these errors. The Tuya quirks should be updated to return a ZCL default response instead of just a bareStatusobject.Something like this:
ZHA unit tests should be expanded to include these types of Tuya devices, this bug should have been caught by them.
Issue must be fixed in HA 2022.4.1 I think it is safe to close now.
Thanks @Tropaion
@Tropaion please reopen this issue in case someone else is in the same situation can track the reason.
Thanks.
@javicalle now dimming throws this
@Tropaion could you test one change?
Over your quirk file replace the
NoManufacturerClusterclass definition:You will need to add the
foundationimport:Check if dimm commands get fixed (the on/off must still fail).
It’s late here. I will continue tomorrow.
They should be returning something that matches what normal lights return. For my IKEA lights, it’s a ZCL default response with a successful status code.