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.66k stars 29.52k forks source link

Hue integration generates AttributeError: 'NoneType' object has no attribute 'last_event' errors #62250

Closed stalakerob closed 2 years ago

stalakerob commented 2 years ago

The problem

Hue integration generates AttributeError: 'NoneType' object has no attribute 'last_event' errors home-assistant | 2021-12-18 08:56:03 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved home-assistant | Traceback (most recent call last): home-assistant | File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/base.py", line 183, in _handle_event home-assistant | callback(type, cur_item) home-assistant | File "/usr/src/homeassistant/homeassistant/components/hue/v2/hue_event.py", line 47, in handle_button_event home-assistant | CONF_TYPE: hue_resource.button.last_event.value, home-assistant | AttributeError: 'NoneType' object has no attribute 'last_event'

What version of Home Assistant Core has the issue?

2021.12.3

What was the last working version of Home Assistant Core?

2021.11.x

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Philips Hue

Link to integration documentation on our website

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

`home-assistant   | 2021-12-18 08:56:03 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
home-assistant   | Traceback (most recent call last):
home-assistant   |   File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/base.py", line 183, in _handle_event
home-assistant   |     callback(type, cur_item)
home-assistant   |   File "/usr/src/homeassistant/homeassistant/components/hue/v2/hue_event.py", line 47, in handle_button_event
home-assistant   |     CONF_TYPE: hue_resource.button.last_event.value,
home-assistant   | AttributeError: 'NoneType' object has no attribute 'last_event'

Additional information

No response

breakthestatic commented 2 years ago

I'm seeing this somewhat frequently as well (45 instances within an 8 hr period.) I haven't been able to pinpoint a specific cause/correlated event but will add that info if I'm able to determine a way to reliably reproduce the error.

breakthestatic commented 2 years ago

Tagging @marcelveldt, as I'm able to reliably reproduce this now. There might be more ways to reproduce, but (for me) it starts happening exactly one hour after making a light.toggle service call. My specific use-case performs a toggle of a hue light group when pushing a secondary button on one of my z-wave switches:

alias: Master Bedroom Lights Switch Control
description: Toggle master bedroom lights via zwave scene
trigger:
  - platform: device
    device_id: XXXXXXX
    domain: zwave_js
    type: event.value_notification.central_scene
    property: scene
    property_key: '003'
    endpoint: 0
    command_class: 91
    subtype: Endpoint 0 Scene 003
condition: []
action:
  - service: light.toggle
    target:
      entity_id: light.master_bedroom_lights
    data:
      brightness_pct: 100
mode: single

The automation and service call work correctly, but exactly one hour after the service call, I start seeing the errors noted in the description.

Initial toggle call in the logs at 12:52:15 local time:

2021-12-19 12:52:15 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=light, service=toggle, service_data=brightness_pct=100, entity_id=['light.master_bedroom_lights']>
2021-12-19 12:52:15 DEBUG (MainThread) [homeassistant.components.hue.bridge.light] Received status update for light.jennys_lamp
2021-12-19 12:52:15 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=light.jennys_lamp, old_state=<state light.jennys_lamp=on; supported_color_modes=['brightness'], color_mode=brightness, brightness=255, mode=normal, dynamics=none, icon=mdi:floor-lamp, friendly_name=Jenny's Lamp, supported_features=40 @ 2021-12-19T12:52:00.558332-08:00>, new_state=<state light.jennys_lamp=off; supported_color_modes=['brightness'], mode=normal, dynamics=none, icon=mdi:floor-lamp, friendly_name=Jenny's Lamp, supported_features=40 @ 2021-12-19T12:52:15.198922-08:00>>
2021-12-19 12:52:15 DEBUG (MainThread) [homeassistant.components.hue.bridge.grouped_light] Received status update for light.master_bedroom_lights
2021-12-19 12:52:15 DEBUG (MainThread) [homeassistant.components.google_assistant.report_state] Scheduling report state for light.jennys_lamp: {'online': True, 'brightness': 0, 'on': False}
2021-12-19 12:52:15 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.new_automation, old_state=<state automation.new_automation=on; last_triggered=2021-12-19T12:52:15.150704-08:00, mode=single, current=1, id=1633729115120, friendly_name=Master Bedroom Lights Switch Control @ 2021-12-19T12:50:47.784240-08:00>, new_state=<state automation.new_automation=on; last_triggered=2021-12-19T12:52:15.150704-08:00, mode=single, current=0, id=1633729115120, friendly_name=Master Bedroom Lights Switch Control @ 2021-12-19T12:50:47.784240-08:00>>
2021-12-19 12:52:16 DEBUG (MainThread) [homeassistant.components.hue.bridge.light] Received status update for light.chris_lamp
2021-12-19 12:52:16 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=light.chris_lamp, old_state=<state light.chris_lamp=on; min_mireds=153, max_mireds=500, supported_color_modes=['color_temp', 'xy'], color_mode=color_temp, brightness=255, color_temp=333, hs_color=(27.82, 56.814), rgb_color=(255, 177, 110), xy_color=(0.496, 0.383), mode=normal, dynamics=none, icon=mdi:lamp, friendly_name=Chris' Lamp, supported_features=40 @ 2021-12-19T12:52:01.596773-08:00>, new_state=<state light.chris_lamp=off; min_mireds=153, max_mireds=500, supported_color_modes=['color_temp', 'xy'], mode=normal, dynamics=none, icon=mdi:lamp, friendly_name=Chris' Lamp, supported_features=40 @ 2021-12-19T12:52:16.213152-08:00>>
2021-12-19 12:52:16 DEBUG (MainThread) [homeassistant.components.hue.bridge.grouped_light] Received status update for light.master_bedroom_lights
2021-12-19 12:52:16 DEBUG (MainThread) [homeassistant.components.hue.bridge.grouped_light] Received status update for light.master_bedroom_lights

Error in logs ~ one hour later (13:52:16 local time):

2021-12-19 13:52:16 DEBUG (MainThread) [aiohue.v2[10.10.18.20].events] Disconnected from EventStream - Reconnect will be attempted in 2 seconds
2021-12-19 13:52:18 DEBUG (MainThread) [aiohue.v2[10.10.18.20].events] Connected to EventStream
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.light] Received status update for light.chris_lamp
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.light] Received status update for light.valentinas_lamp
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event device_registry_updated[L]: action=update, device_id=3b060f2b78c8ff174000b089bf3a33aa>
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.light] Received status update for light.jennys_lamp
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.light] Received status update for light.nicos_star_lamp
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.grouped_light] Received status update for light.living_room_lights
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.grouped_light] Received status update for light.kitchen_lights
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.light] Received status update for light.chris_lamp
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.grouped_light] Received status update for light.master_bedroom_lights
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.grouped_light] Received status update for light.kitchen_lights
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.grouped_light] Received status update for light.living_room_lights
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.grouped_light] Received status update for light.kitchen_lights
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.light] Received status update for light.valentinas_lamp
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.grouped_light] Received status update for light.kitchen_lights
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.grouped_light] Received status update for light.living_room_lights
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.grouped_light] Received status update for light.kitchen_lights
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.grouped_light] Received status update for light.kitchen_lights
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.light] Received status update for light.jennys_lamp
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.grouped_light] Received status update for light.master_bedroom_lights
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.light] Received status update for light.nicos_star_lamp
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.light] Received status update for light.chris_lamp
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.light] Received status update for light.valentinas_lamp
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.light] Received status update for light.jennys_lamp
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.light] Received status update for light.nicos_star_lamp
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.kitchen_concentrate_in_the_kitchen
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.living_room_bright
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.master_bedroom_arctic_aurora
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.master_bedroom_bright
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.master_bedroom_tropical_twilight
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.living_room_arctic_aurora
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.kitchen_dimmed
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.master_bedroom_nightlight
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.master_bedroom_concentrate
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.master_bedroom_read
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.living_room_nightlight
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.master_bedroom_dimmed
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.master_bedroom_energize
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.master_bedroom_savanna_sunset
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.master_bedroom_spring_blossom
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.master_bedroom_relax
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.kitchen_bright_in_the_kitchen
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.living_room_dimmed
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.grouped_light] Received status update for light.living_room_lights
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.grouped_light] Received status update for light.master_bedroom_lights
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.grouped_light] Received status update for light.kitchen_lights
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.v2.hue_event] Received button event: Button(id='A', type=<ResourceTypes.BUTTON: 'button'>, id_v1='/sensors/29', metadata=SwitchInputMetadata(control_id=1), button=None)
2021-12-19 13:52:18 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/base.py", line 183, in _handle_event
    callback(type, cur_item)
  File "/usr/src/homeassistant/homeassistant/components/hue/v2/hue_event.py", line 47, in handle_button_event
    CONF_TYPE: hue_resource.button.last_event.value,
AttributeError: 'NoneType' object has no attribute 'last_event'
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.v2.hue_event] Received button event: Button(id='B', type=<ResourceTypes.BUTTON: 'button'>, id_v1='/sensors/29', metadata=SwitchInputMetadata(control_id=2), button=ButtonFeature(last_event=<ButtonEvent.SHORT_RELEASE: 'short_release'>))
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event hue_event[L]: id=kitchen_switch_button, device_id=C, unique_id=B, type=short_release, subtype=2>
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.v2.hue_event] Received button event: Button(id='D', type=<ResourceTypes.BUTTON: 'button'>, id_v1='/sensors/29', metadata=SwitchInputMetadata(control_id=3), button=None)
2021-12-19 13:52:18 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/base.py", line 183, in _handle_event
    callback(type, cur_item)
  File "/usr/src/homeassistant/homeassistant/components/hue/v2/hue_event.py", line 47, in handle_button_event
    CONF_TYPE: hue_resource.button.last_event.value,
AttributeError: 'NoneType' object has no attribute 'last_event'
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.v2.hue_event] Received button event: Button(id='E', type=<ResourceTypes.BUTTON: 'button'>, id_v1='/sensors/29', metadata=SwitchInputMetadata(control_id=4), button=None)
2021-12-19 13:52:18 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/base.py", line 183, in _handle_event
    callback(type, cur_item)
  File "/usr/src/homeassistant/homeassistant/components/hue/v2/hue_event.py", line 47, in handle_button_event
    CONF_TYPE: hue_resource.button.last_event.value,
AttributeError: 'NoneType' object has no attribute 'last_event'
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.v2.hue_event] Received button event: Button(id='F', type=<ResourceTypes.BUTTON: 'button'>, id_v1='/sensors/40', metadata=SwitchInputMetadata(control_id=1), button=ButtonFeature(last_event=<ButtonEvent.SHORT_RELEASE: 'short_release'>))
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event hue_event[L]: id=living_room_switch_button, device_id=G, unique_id=F, type=short_release, subtype=1>
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.v2.hue_event] Received button event: Button(id='H', type=<ResourceTypes.BUTTON: 'button'>, id_v1='/sensors/40', metadata=SwitchInputMetadata(control_id=2), button=None)
2021-12-19 13:52:18 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/base.py", line 183, in _handle_event
    callback(type, cur_item)
  File "/usr/src/homeassistant/homeassistant/components/hue/v2/hue_event.py", line 47, in handle_button_event
    CONF_TYPE: hue_resource.button.last_event.value,
AttributeError: 'NoneType' object has no attribute 'last_event'
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.v2.hue_event] Received button event: Button(id='I', type=<ResourceTypes.BUTTON: 'button'>, id_v1='/sensors/40', metadata=SwitchInputMetadata(control_id=3), button=None)
2021-12-19 13:52:18 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/base.py", line 183, in _handle_event
    callback(type, cur_item)
  File "/usr/src/homeassistant/homeassistant/components/hue/v2/hue_event.py", line 47, in handle_button_event
    CONF_TYPE: hue_resource.button.last_event.value,
AttributeError: 'NoneType' object has no attribute 'last_event'
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.v2.hue_event] Received button event: Button(id='J', type=<ResourceTypes.BUTTON: 'button'>, id_v1='/sensors/40', metadata=SwitchInputMetadata(control_id=4), button=None)
2021-12-19 13:52:18 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohue/v2/controllers/base.py", line 183, in _handle_event
    callback(type, cur_item)
  File "/usr/src/homeassistant/homeassistant/components/hue/v2/hue_event.py", line 47, in handle_button_event
    CONF_TYPE: hue_resource.button.last_event.value,
AttributeError: 'NoneType' object has no attribute 'last_event'
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.grouped_light] Received status update for light.living_room_lights
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.living_room_bright
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.living_room_arctic_aurora
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.living_room_nightlight
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.living_room_dimmed
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.grouped_light] Received status update for light.master_bedroom_lights
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.master_bedroom_arctic_aurora
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.master_bedroom_bright
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.master_bedroom_tropical_twilight
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.master_bedroom_nightlight
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.master_bedroom_concentrate
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.master_bedroom_read
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.master_bedroom_dimmed
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.master_bedroom_energize
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.master_bedroom_savanna_sunset
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.master_bedroom_spring_blossom
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.master_bedroom_relax
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.grouped_light] Received status update for light.kitchen_lights
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.kitchen_concentrate_in_the_kitchen
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.kitchen_dimmed
2021-12-19 13:52:18 DEBUG (MainThread) [homeassistant.components.hue.bridge.scene] Received status update for scene.kitchen_bright_in_the_kitchen

This will then repeat at an hourly interval until either another light service call is made at a different time (or HA/integration reloads). I've removed the uuids and some log items that didn't pertain to the hue integration.

Also just wanted to clarify that I did not touch any of my Hue switches at all. I see that the logs indicate button events. I'm not sure if that is just part of the event stream reconnecting, but I wanted to make it totally clear that no manual actions or subsequent service calls have been performed for my Philips Hue switches (or any devices for that matter.)

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)


hue documentation hue source (message by IssueLinks)