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
70.6k stars 29.5k forks source link

KeyError in Hue integration after updating to 2022.2.7 - Hue does not startup anymore #66636

Closed zigomatichub closed 2 years ago

zigomatichub commented 2 years ago

The problem

Hello, I get an issue after upgrade with hue integration where the bridge can't connect anymore. I try first a restart but nothing helped, so I do a rollback and it's ok. Probably something added in this latest version.

See logs for more details

I'm in latest bridge version (last week, there was an update to 1.49.1949203030)

Thank you, Zigomatic

What version of Home Assistant Core has the issue?

core-2022.2.7

What was the last working version of Home Assistant Core?

core-2022.2.6

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Philips Hue

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2022-02-16 09:56:01 ERROR (MainThread) [homeassistant.components.hue.bridge] Unknown error connecting to Hue bridge
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/hue/bridge.py", line 75, in async_initialize_bridge
    await self.api.initialize()
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/__init__.py", line 103, in initialize
    await self.fetch_full_state()
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/__init__.py", line 241, in fetch_full_state
    await asyncio.gather(
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/base.py", line 306, in initialize
    await resource_control.initialize(initial_data)
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/base.py", line 80, in initialize
    resource: CLIPResource = dataclass_from_dict(self.item_cls, item)
  File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 206, in dataclass_from_dict
    **{
  File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 207, in <dictcomp>
    field.name: _parse_value(
  File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 144, in _parse_value
    return dataclass_from_dict(value_type, value)
  File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 206, in dataclass_from_dict
    **{
  File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 207, in <dictcomp>
    field.name: _parse_value(
  File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 178, in _parse_value
    raise KeyError(f"`{name}` of type `{value_type}` is required.")
KeyError: "`MotionSensingFeature.motion` of type `<class 'bool'>` is required."

Additional information

No response

probot-home-assistant[bot] commented 2 years ago

hue documentation hue source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years 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! (message by CodeOwnersMention)

marcelveldt commented 2 years ago

Strange, looks like your bridge is outputting data that isn't conform their own datamodel. It's choking on the motion sensor btw...

Can you check in the Hue app what firmware version you're running on the bridge ?

One other check is perhaps see if the motion sensor is enabled and up to date with updates?

marcelveldt commented 2 years ago

OK, I've managed to reproduce it. It happens when the motion sensor is disabled. I will adjust our code for that but in fact this is an error in the Signify API

SeraphimSerapis commented 2 years ago

@marcelveldt I run into the same issue, too. Please let me know if you need additional data.

My Hue hub is on FW: 1.50.1950049000 and from what I can see, all my devices are up to date. Currently, none of my Hue devices are functional and I'll have to rollback to 2022.2.6 for now.

marcelveldt commented 2 years ago

@SeraphimSerapis just enable the sensors from the Hue app and it will work again.

zigomatichub commented 2 years ago

Indeed, I have one motion sensor with motion switch is off. I'm using a lot in automation since it's available in V2 ;) Also in 2022.2.6, I get this 2022-02-16 10:08:30 WARNING (MainThread) [aiohue.util] Value {} of type <class 'dict'> is invalid for Device.identify, expected value of type typing.Optional[aiohue.v2.models.feature.IdentifyFeature]

marcelveldt commented 2 years ago

@zigomatichub the error you mention is fixed in the 2022.2.7 hotfix

zigomatichub commented 2 years ago

My bridge is BSB0002 1949203030 where with hue app or Hue essentials app is mentionned at latest after click on check for latest version. All my 34 devices attached are also uptodate. Region: Europe - Belgium

marcelveldt commented 2 years ago

Like I said, we will provide a fix soon but to workaround it simply enable any disabled sensors in the Hue app and it will work again.

Mariusthvdb commented 2 years ago

Like I said, we will provide a fix soon but to workaround it simply enable any disabled sensors in the Hue app and it will work again.

this doesnt work in my config unfortunately, running dev20220216 with all motion sensors on both of my Bridges enabled in the app.. still returning that exact same error. hmm, another go and it worked. nvm/.

marcelveldt commented 2 years ago

reopened issue as reference for others until a new HA hotfix is released

marcelveldt commented 2 years ago

For everyone hit by this issue: Just enable any disabled Hue motion sensors with the Hue app and restart HA. A fix will be provided in an upcoming HA bugfix release

johnwalk61 commented 2 years ago

I have 2 motion sensors and they are both enabled, but I still cannot control any of my 30+ lights after 2022.2.7 update.

marcelveldt commented 2 years ago

I have 2 motion sensors and they are both enabled, but I still cannot control any of my 30+ lights after 2022.2.7 update.

Did you restart HA after re-enabling all sensors ?

johnwalk61 commented 2 years ago

Yes sir several times

marcelveldt commented 2 years ago

Yes sir several times

Can you check your HA logfile for errors please because you might have an issue that is unrelated to the one mentioned in this issue report.

johnwalk61 commented 2 years ago

Here's the log error: Logger: homeassistant.components.hue.bridge Source: components/hue/bridge.py:75 Integration: Philips Hue (documentation, issues) First occurred: 10:50:00 AM (1 occurrences) Last logged: 10:50:00 AM

Unknown error connecting to Hue bridge Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/hue/bridge.py", line 75, in async_initialize_bridge await self.api.initialize() File "/usr/local/lib/python3.9/site-packages/aiohue/v2/init.py", line 103, in initialize await self.fetch_full_state() File "/usr/local/lib/python3.9/site-packages/aiohue/v2/init.py", line 241, in fetch_full_state await asyncio.gather( File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/base.py", line 306, in initialize await resource_control.initialize(initial_data) File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/base.py", line 80, in initialize resource: CLIPResource = dataclass_from_dict(self.item_cls, item) File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 206, in dataclass_from_dict { File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 207, in field.name: _parse_value( File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 144, in _parse_value return dataclass_from_dict(value_type, value) File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 206, in dataclass_from_dict { File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 207, in field.name: _parse_value( File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 178, in _parse_value raise KeyError(f"{name} of type {value_type} is required.") KeyError: "MotionSensingFeature.motion of type <class 'bool'> is required."

marcelveldt commented 2 years ago

@johnwalk61 you still have Motion sensors that are disabled or you must make sure to have motion once after enabling them.

johnwalk61 commented 2 years ago

Thanks for the reply, when I look at the entity it says they are enabled. Thanks Marcel for looking at this.

zigomatichub commented 2 years ago

FYI; I switched ON the motion sensor in HA 2012.2.6 and do upgrade. Everything is working fine in 2012.2.7.

johnwalk61 commented 2 years ago

I have 2 motion sensors and just checked again and the enable toggle is on

marcelveldt commented 2 years ago

After enabling them it MIGHT be required that you make sure motion is detected just once, e.g. walk towards the sensor(s). The KeyError: "MotionSensingFeature.motion of type <class 'bool'> is required." is really caused by disabled motion sensors so enabling them is the (temporary) fix.

johnwalk61 commented 2 years ago

I looked at all the entities for motion and zigbee was disabled, I enabled for both and will restart and test

johnwalk61 commented 2 years ago

after restart still getting this error: Logger: homeassistant.components.hue.bridge Source: components/hue/bridge.py:75 Integration: Philips Hue (documentation, issues) First occurred: 10:58:11 AM (1 occurrences) Last logged: 10:58:11 AM

Unknown error connecting to Hue bridge Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/hue/bridge.py", line 75, in async_initialize_bridge await self.api.initialize() File "/usr/local/lib/python3.9/site-packages/aiohue/v2/init.py", line 103, in initialize await self.fetch_full_state() File "/usr/local/lib/python3.9/site-packages/aiohue/v2/init.py", line 241, in fetch_full_state await asyncio.gather( File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/base.py", line 306, in initialize await resource_control.initialize(initial_data) File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/base.py", line 80, in initialize resource: CLIPResource = dataclass_from_dict(self.item_cls, item) File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 206, in dataclass_from_dict { File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 207, in field.name: _parse_value( File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 144, in _parse_value return dataclass_from_dict(value_type, value) File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 206, in dataclass_from_dict { File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 207, in field.name: _parse_value( File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 178, in _parse_value raise KeyError(f"{name} of type {value_type} is required.") KeyError: "MotionSensingFeature.motion of type <class 'bool'> is required."

johnwalk61 commented 2 years ago

should I remove hue integration and re-add it?

zigomatichub commented 2 years ago

@johnwalk61 Check into Hue App and also check that you are in latest version of bridge. It might be a desync between HA and Hue. You have to be sure that is in Hue App that all motion sensors are on enable mode

marcelveldt commented 2 years ago

@johnwalk61 No, you should look again for motion sensors and enable them in the Hue App. Official Hue app --> Settings --> Accessoires --> Make sure the toggles next to motion sensors are in enabled state.

johnwalk61 commented 2 years ago

Marcel thanks for all the help. Looks like the batteries in the sensors were low. I replaced them and all is working now. Much appreciated.

mehdic commented 2 years ago

I dont have any Philips Hue motion sensors, and yet my philips hue broke. I even updated to the 2022.2.8, and still the same problem. I rolled back to the 2022.2.6 for now.

Any advice on how to fix this ?

zigomatichub commented 2 years ago

mehdic, What are connected to your bridge ?

mehdic commented 2 years ago

Lights and Buttons only

mehdic commented 2 years ago

here is my error:

Logger: homeassistant.components.hue.bridge Source: components/hue/bridge.py:75 Integration: Philips Hue (documentation, issues) First occurred: 12:25:43 PM (2 occurrences) Last logged: 12:32:58 PM

Unknown error connecting to Hue bridge

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/hue/bridge.py", line 75, in async_initialize_bridge await self.api.initialize() File "/usr/local/lib/python3.9/site-packages/aiohue/v2/init.py", line 104, in initialize await self.fetch_full_state() File "/usr/local/lib/python3.9/site-packages/aiohue/v2/init.py", line 242, in fetch_full_state await asyncio.gather( File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/base.py", line 312, in initialize await resource_control.initialize(initial_data) File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/base.py", line 80, in initialize resource: CLIPResource = dataclass_from_dict(self.item_cls, item) File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 206, in dataclass_from_dict { File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 207, in field.name: _parse_value( File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 144, in _parse_value return dataclass_from_dict(value_type, value) File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 206, in dataclass_from_dict { File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 207, in field.name: _parse_value( File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 147, in _parse_value return [ File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 148, in _parse_value(name, subval, get_args(value_type)[0]) File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 144, in _parse_value return dataclass_from_dict(value_type, value) File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 206, in dataclass_from_dict { File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 207, in field.name: _parse_value( File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 147, in _parse_value return [ File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 148, in _parse_value(name, subval, get_args(value_type)[0]) File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 144, in _parse_value return dataclass_from_dict(value_type, value) File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 206, in dataclass_from_dict { File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 207, in field.name: _parse_value( File "/usr/local/lib/python3.9/site-packages/aiohue/util.py", line 184, in _parse_value raise TypeError( TypeError: Value 1 of type <class 'int'> is invalid for Position.y, expected value of type <class 'float'>

marcelveldt commented 2 years ago

@mehdic please do not hijack (closed) issues. Your issue seems to be a bit similar to the earlier issue with motion sensors but in fact different. From the top of my head this might be caused by any entertainment zones as those use the position schema.

Can you please create a new issue report with all details filled in, including a properly formatted version of your error ? Thanks!

mehdic commented 2 years ago

Alright will do that. Thanks