adaptive-lighting: light.turn_on not working anymore after adaptive lighting update

  1. Debug logs captured while the issue occurred. See here for instructions on enabling debug logging:
Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/adaptive_lighting/switch.py:623
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 00:07:08 (1 occurrences)
Last logged: 00:07:08

[139633320724560] 'NoneType' object has no attribute 'data'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 205, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1965, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2005, in _execute_service
    return await cast(
           ^^^^^^^^^^^
  File "/config/custom_components/adaptive_lighting/hass_utils.py", line 46, in service_func_proxy
    await intercept_func(call, data)
  File "/config/custom_components/adaptive_lighting/switch.py", line 1913, in _service_interceptor_turn_on_handler
    adaptive_switch = _switch_with_lights(self.hass, [entity_id])
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/adaptive_lighting/switch.py", line 306, in _switch_with_lights
    switches = _switches_with_lights(hass, lights)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/adaptive_lighting/switch.py", line 290, in _switches_with_lights
    switch._expand_light_groups()
  File "/config/custom_components/adaptive_lighting/switch.py", line 976, in _expand_light_groups
    all_lights = _expand_light_groups(self.hass, self.lights)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/adaptive_lighting/switch.py", line 623, in _expand_light_groups
    manager = hass.data[DOMAIN][ATTR_ADAPTIVE_LIGHTING_MANAGER]
              ^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'data'

The debug logs didn’t give me any further data:

2023-07-24 00:19:14.590 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139904912226256] 'NoneType' object has no attribute 'data'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 205, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1965, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2005, in _execute_service
    return await cast(
           ^^^^^^^^^^^
  File "/config/custom_components/adaptive_lighting/hass_utils.py", line 46, in service_func_proxy
    await intercept_func(call, data)
  File "/config/custom_components/adaptive_lighting/switch.py", line 1913, in _service_interceptor_turn_on_handler
    adaptive_switch = _switch_with_lights(self.hass, [entity_id])
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/adaptive_lighting/switch.py", line 306, in _switch_with_lights
    switches = _switches_with_lights(hass, lights)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/adaptive_lighting/switch.py", line 290, in _switches_with_lights
    switch._expand_light_groups()
  File "/config/custom_components/adaptive_lighting/switch.py", line 976, in _expand_light_groups
    all_lights = _expand_light_groups(self.hass, self.lights)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/adaptive_lighting/switch.py", line 623, in _expand_light_groups
    manager = hass.data[DOMAIN][ATTR_ADAPTIVE_LIGHTING_MANAGER]
              ^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'data'
  1. Your Adaptive Lighting configuration:
- name: AL Schlafzimmer Normal
  lights:
    - light.bett
  detect_non_ha_changes: true
- name: AL Schlafzimmer Gastmodus
  lights:
    - light.bett
  detect_non_ha_changes: true
- name: AL Flur Normal
  lights:
    - light.flurspiegel
    - light.tur
  max_brightness: 100 # 80
  min_brightness: 10
  sunset_offset: '00:45:00'
  sunrise_offset: '00:45:00'
  detect_non_ha_changes: true
- name: AL Flur Gastmodus
  lights:
    - light.flurspiegel
    - light.tur
  sunset_offset: '01:45:00'
  min_brightness: 65
  max_brightness: 100 # 80
  min_color_temp: 3800
  detect_non_ha_changes: true
- name: AL Küche Normal
  lights:
    - light.kuche
  detect_non_ha_changes: true
  sunset_offset: '01:30:00'
  min_brightness: 20
  sleep_brightness: 5
- name: AL Küche Gastmodus
  lights:
    - light.kuche
  min_brightness: 50
  sunset_offset: '01:45:00'
  min_color_temp: 3000
  detect_non_ha_changes: true
  1. Describe the bug and how to reproduce it:

Not using zigbee, hue lights with a hue bridge and a nanoleaf light. All worked well until yesterday when I updated my home assistant core as well as adaptive lighting. Turning a light off works without problems, light_on and toggle throw errors, apparently due to the adaptive liighting integration. The state is also represented basically instant in home assistant when I change themm through the apps or anyhting so it doesnn’t seem it has to do with the connection or anything, but a wrong call. On a sidenote, the automatic light adjustments from adaptive lighting do still work for some reason; manually adjusting any light in the UI gives me an error as well

  1. Steps to reproduce the behavior:

I hav no idea why this happened to me exactly, I haven’t found any further info on this so I thought I’d better post this. Issue is occuring every time to me, also just updated adaptive lighting to 1.17.0, HA OS 10.3 and core version 2023.7.3

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 17 (13 by maintainers)

Commits related to this issue

Most upvoted comments

I merged #669 which make sure that entities are properly removed after removing them from the YAML configuration. 😄

Thanks a lot for reporting your solution!

I suspect that this issue shouldn’t occur with with https://github.com/basnijholt/adaptive-lighting/pull/659 merged (v1.17.3).

However, the root cause is likely, that removing switches from YAML leaves them in the UI. I will see how to fix this.

Oh I actually already see the problem there. rgb_color: (255, 271, 15) which is not possible.

I’ll push a fix soon.