home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.69k stars 30.44k forks source link

Emulated hue error since 2023.11.x unable to control via harmony hub #104013

Closed dshokouhi closed 11 months ago

dshokouhi commented 11 months ago

The problem

After updating to HA core 2023.11.x I am unable to control my emulated hue devices via the harmony hub. Even if I attempt to refresh the device list in the harmony app the process fails and says it was not able to retrieve the devices.

When attempting to troubleshoot I noticed that http://192.168.1.48:8300/api/v2/lights gives a 500 error for me and I am not sure where to begin troubleshooting that.

Ths was working fine in 2023.10 and older versions

What version of Home Assistant Core has the issue?

2023.11.x

What was the last working version of Home Assistant Core?

2023.10.x

What type of installation are you running?

Home Assistant Core

Integration causing the issue

emulated_hue

Link to integration documentation on our website

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

Diagnostics information

n/a

Example YAML snippet

emulated_hue:
  exposed_domains:
  - switch
  - light

Anything in the logs that might be useful for us?

Logger: aiohttp.server
Source: /srv/homeassistant3.11/lib/python3.11/site-packages/aiohttp/web_protocol.py:403
First occurred: November 10, 2023 at 9:54:33 AM (7858 occurrences)
Last logged: 8:27:35 PM

Error handling request
Traceback (most recent call last):
  File "/srv/homeassistant3.11/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant3.11/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant3.11/lib/python3.11/site-packages/homeassistant/components/http/view.py", line 150, in handle
    result = handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant3.11/lib/python3.11/site-packages/homeassistant/components/emulated_hue/hue_api.py", line 238, in get
    return self.json(create_list_of_entities(self.config, request))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant3.11/lib/python3.11/site-packages/homeassistant/components/emulated_hue/hue_api.py", line 876, in create_list_of_entities
    json_response[config.entity_id_to_number(entity_id)] = state_to_json(
                                                           ^^^^^^^^^^^^^^
  File "/srv/homeassistant3.11/lib/python3.11/site-packages/homeassistant/components/emulated_hue/hue_api.py", line 761, in state_to_json
    state_dict = get_entity_state_dict(config, state)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant3.11/lib/python3.11/site-packages/homeassistant/components/emulated_hue/hue_api.py", line 655, in get_entity_state_dict
    return _build_entity_state_dict(entity)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant3.11/lib/python3.11/site-packages/homeassistant/components/emulated_hue/hue_api.py", line 687, in _build_entity_state_dict
    data[STATE_BRIGHTNESS] = hass_to_hue_brightness(
                             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/srv/homeassistant3.11/lib/python3.11/site-packages/homeassistant/components/emulated_hue/hue_api.py", line 890, in hass_to_hue_brightness
    return max(1, round((value / 255) * HUE_API_STATE_BRI_MAX))
                         ~~~~~~^~~~~
TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'

Additional information

When I get the 500 error from the API URL I see this error generate. This error has generated thousands of times as well.

home-assistant[bot] commented 11 months ago

Hey there @bdraco, @tho85, mind taking a look at this issue as it has been labeled with an integration (emulated_hue) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `emulated_hue` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign emulated_hue` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


emulated_hue documentation emulated_hue source (message by IssueLinks)

bdraco commented 11 months ago

Thanks for the trace.

Its likely the light platform changes that we had to fix for HomeKit as well

bdraco commented 11 months ago

The fix for homekit was #102290

bdraco commented 11 months ago

The change that likely introduced this issue https://github.com/home-assistant/core/pull/101946