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
69.97k stars 29.05k forks source link

Error when adding Hue contact sensor to Hue Bridge #117316

Open mvdwetering opened 2 months ago

mvdwetering commented 2 months ago

The problem

I noticed the following error in the Home Assistant logs after adding a new contact sensor to my bridge.

It looks like it is accessing a none existing contact report. I guess there is no report yet, because it is freshly installed?

(edit: checked the Hue API specs and the report is not required, so it is optional, probably needs a check)

2024-05-12 16:41:36.854 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.12/site-packages/aiohue/v2/controllers/base.py", line 247, in _handle_event
callback(evt_type, cur_item)
File "/usr/src/homeassistant/homeassistant/components/hue/v2/entity.py", line 138, in _handle_event
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1009, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1132, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1067, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1015, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/binary_sensor/__init__.py", line 296, in state
if (is_on := self.is_on) is None:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/hue/v2/binary_sensor.py", line 150, in is_on
return self.resource.contact_report.state != ContactState.CONTACT
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'

What version of Home Assistant Core has the issue?

core-2024.5.3

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

hue

Link to integration documentation on our website

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

Diagnostics information

config_entry-hue-c910e678422e20511210d1e4da62e569.json

Example YAML snippet

n.a.

Anything in the logs that might be useful for us?

Already pasted in the description

Additional information

No response

home-assistant[bot] commented 2 months ago

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

Code owner commands Code owners of `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 hue` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


hue documentation hue source (message by IssueLinks)