Skip to content
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

"'EmberStatus' object is not subscriptable" error when turning on fan light #69893

Closed
LunkwillAndFook opened this issue Apr 12, 2022 · 13 comments · Fixed by zigpy/zha-device-handlers#1515
Assignees

Comments

@LunkwillAndFook
Copy link

LunkwillAndFook commented Apr 12, 2022

The problem

When turning on or off a fan light the following exception occurs...

'EmberStatus' object is not subscriptable

Logger: homeassistant.components.websocket_api.http.connection
Source: components/zha/light.py:343
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 9:57:22 PM (14 occurrences)
Last logged: 10:29:01 PM

What version of Home Assistant Core has the issue?

core-2022.4.2

What was the last working version of Home Assistant Core?

core-2022.3

What type of installation are you running?

Home Assistant OS

Integration causing the issue

zha

Link to integration documentation on our website

https://www.home-assistant.io/integrations/zha

Diagnostics information

Device info
HDC52EastwindFan
by King Of Fans, Inc.
Connected via Zigbee Coordinator
Firmware: 0x0000000f
Zigbee info
IEEE: REDACTED
Nwk: REDACTED
Device Type: EndDevice
LQI: 255
RSSI: -55
Last Seen: 2022-04-11T22:43:26
Power Source: Mains
Quirk: zhaquirks.kof.kof_mr101z.CeilingFan

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2022-04-11 21:57:29 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [546966825232] 'EmberStatus' 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: 'EmberStatus' object is not subscriptable


### Additional information

_No response_
@probot-home-assistant
Copy link

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (websocket_api) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)


websocket_api documentation
websocket_api source
(message by IssueLinks)

@probot-home-assistant
Copy link

zha documentation
zha source
(message by IssueLinks)

@probot-home-assistant
Copy link

Hey there @dmulcahey, @Adminiuga, mind taking a look at this issue as it has been labeled with an integration (zha) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

@Adminiuga
Copy link
Contributor

Are you using light service to turn on/off the fan?

@LunkwillAndFook
Copy link
Author

LunkwillAndFook commented Apr 12, 2022

@Adminiuga No, this uses the light service to turn on/off the fan light. The fan device has two entities of interest: a light and a fan. The fan entity continues to work as expected.
fan

@Adminiuga
Copy link
Contributor

Yep, i forgot it has the light entity. Can you enable debug logging and post the snippet where it calls the light service? Need to see what response comes back.

@Adminiuga
Copy link
Contributor

And was it working with 2022.4.1?

@LunkwillAndFook
Copy link
Author

LunkwillAndFook commented Apr 13, 2022

@Adminiuga I can verify it was working in 2022.3. I can't remember but I may have skipped 2022.4.1 and accidently mislabeled this bug as working in that release, so I have updated the bug to reflect this. It is worth noting also that the light does turn on and off despite the error.

Log:
debug log.txt

@sohighlight
Copy link

I'm having the same issue with the same device. For me it broke with the 2022.4.0 update.

@puddly
Copy link
Contributor

puddly commented Apr 13, 2022

Looks like zigpy returns the radio library-internal request status when expect_reply=False:

https://github.com/zigpy/zigpy/blob/3857bfe3e7bdafffb0850c8171e06598471cdaba/zigpy/device.py#L304-L307

I think wrapping the status in a ZCL Default_Response object may be enough?

@Adminiuga
Copy link
Contributor

There's a quirk for KoF which disables the expect_reply for some of the commands.
IMO the lib itself should not return the wrapped default response. One one hand lib should not return something which is not there, nor the default response is a correct response for all the commands.
This is a peculiarity of this device, as for on/off commands there should be a default response, but since device is not sending anything back, then quirk should?

@puddly
Copy link
Contributor

puddly commented Apr 13, 2022

I agree, fixing it in the quirk seems more correct.

This same codepath is related to another issue found by @TheJulianJES, where the last_seen time seems to be updated for offline devices. Radio libraries return failures as an unsuccessful Status that zigpy never validates, since it implicitly relies on delivery failures to generate exceptions (which seem to happen for timeouts but not for explicit stack failures).

To prevent the radio library status code from being leaked into ZHA in other places, do you think None is an appropriate response type when expect_reply=False? Until the radio libraries are individually updated to just raise exceptions as opposed to returning a status + message tuple, I think zigpy should be internally raising a DeliveryError when the radio library returns an unsuccessful status code.

Zigpy already does this 😄

@nmajin
Copy link

nmajin commented Apr 20, 2022

I have two of these fans and just started seeing this issue recently, probably just a couple releases ago it was working fine. So some update definitely broke this. Light actually still turns on and off and I see status indicator, it just causes an exception in the Lovelace UI and logs every time.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants