basnijholt / adaptive-lighting

Adaptive Lighting custom component for Home Assistant
https://basnijholt.github.io/adaptive-lighting/
Apache License 2.0
1.7k stars 127 forks source link

Adaptive lighting configuration using YAML broken in 1.21.0 #973

Closed djurny closed 2 months ago

djurny commented 2 months ago

Home Assistant Adaptive Lighting Issue Template

Bug Reports

If you need help with using or configuring Adaptive Lighting, please open a Q&A discussion thread here instead.

Before submitting a bug report, please follow these troubleshooting steps:

Please confirm that you have completed the following steps:

Required information for bug reports:

Please include the following information in your issue.

Issues missing this information may not be addressed.

  1. Debug logs captured while the issue occurred. See here for instructions on enabling debug logging:
2024-04-08 15:58:57.519 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Setting up AdaptiveLighting with data: {'__yaml__': {'Hallway', 'Family room', 'Living room', 'Guest room', 'Work room', 'Entrance'}, '99345a49473b464ea6aedfd6d6478116': {'undo_update_listener': <function ConfigEntry.add_update_listener.<locals>.<lambda> at 0xffff657193a0>, 'sleep_mode_switch': <entity switch.adaptive_lighting_sleep_mode_hallway=off>, 'adapt_color_switch': <entity switch.adaptive_lighting_adapt_color_hallway=on>, 'adapt_brightness_switch': <entity switch.adaptive_lighting_adapt_brightness_hallway=off>, 'switch': <entity switch.adaptive_lighting_hallway=unknown>}, 'fd87be11ae6cd8b3f4b189ca473e30b3': {'undo_update_listener': <function ConfigEntry.add_update_listener.<locals>.<lambda> at 0xffff6570f420>, 'sleep_mode_switch': <entity switch.adaptive_lighting_sleep_mode_entrance=off>, 'adapt_color_switch': <entity switch.adaptive_lighting_adapt_color_entrance=on>, 'adapt_brightness_switch': <entity switch.adaptive_lighting_adapt_brightness_entrance=on>, 'switch': <entity switch.adaptive_lighting_entrance=unknown>}, 'bea334d2ffde1a79f325b1b473ce5883': {'undo_update_listener': <function ConfigEntry.add_update_listener.<locals>.<lambda> at 0xffff657198a0>, 'sleep_mode_switch': <entity switch.adaptive_lighting_sleep_mode_guest_room=off>, 'adapt_color_switch': <entity switch.adaptive_lighting_adapt_color_guest_room=on>, 'adapt_brightness_switch': <entity switch.adaptive_lighting_adapt_brightness_guest_room=off>, 'switch': <entity switch.adaptive_lighting_guest_room=unknown>}, '13f17ecb82bec729ffb072c507b38fe2': {'undo_update_listener': <function ConfigEntry.add_update_listener.<locals>.<lambda> at 0xffff65719940>, 'sleep_mode_switch': <entity switch.adaptive_lighting_sleep_mode_work_room=off>, 'adapt_color_switch': <entity switch.adaptive_lighting_adapt_color_work_room=on>, 'adapt_brightness_switch': <entity switch.adaptive_lighting_adapt_brightness_work_room=on>, 'switch': <entity switch.adaptive_lighting_work_room=unknown>}, 'bad28b7039c7178e2dec7b6980e8114f': {'undo_update_listener': <function ConfigEntry.add_update_listener.<locals>.<lambda> at 0xffff657199e0>, 'sleep_mode_switch': <entity unknown.unknown=unknown>, 'adapt_color_switch': <entity unknown.unknown=unknown>, 'adapt_brightness_switch': <entity unknown.unknown=unknown>, 'switch': <entity unknown.unknown=unknown>}, 'dfba2cac6be1cb8f8be7ddf0da9eaa79': {'undo_update_listener': <function ConfigEntry.add_update_listener.<locals>.<lambda> at 0xffff65719a80>, 'sleep_mode_switch': <entity unknown.unknown=unknown>, 'adapt_color_switch': <entity unknown.unknown=unknown>, 'adapt_brightness_switch': <entity unknown.unknown=unknown>, 'switch': <entity unknown.unknown=unknown>}, '6f0c0a4e4a671d929ec078bb00c24cf0': {'undo_update_listener': <function ConfigEntry.add_update_listener.<locals>.<lambda> at 0xffff65719260>}, 'manager': <custom_components.adaptive_lighting.switch.AdaptiveLightingManager object at 0xffff6429c980>} and config_entry <ConfigEntry entry_id=6f0c0a4e4a671d929ec078bb00c24cf0 version=1 domain=adaptive_lighting title=jjj state=ConfigEntryState.LOADED unique_id=jjj>
2024-04-08 15:58:57.526 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] jjj: Set switch settings for lights '[]'. now using data: '{'lights': [], 'interval': datetime.timedelta(seconds=90), 'transition': 45.0, 'initial_transition': 1.0, 'min_brightness': 1, 'max_brightness': 100, 'min_color_temp': 2000, 'max_color_temp': 5500, 'prefer_rgb_color': False, 'sleep_brightness': 1, 'sleep_rgb_or_color_temp': 'color_temp', 'sleep_color_temp': 1000, 'sleep_rgb_color': [255, 56, 0], 'sleep_transition': 1.0, 'transition_until_sleep': False, 'sunrise_time': None, 'min_sunrise_time': None, 'max_sunrise_time': None, 'sunrise_offset': datetime.timedelta(0), 'sunset_time': None, 'min_sunset_time': None, 'max_sunset_time': None, 'sunset_offset': datetime.timedelta(0), 'brightness_mode': 'default', 'brightness_mode_time_dark': datetime.timedelta(seconds=900), 'brightness_mode_time_light': datetime.timedelta(seconds=3600), 'take_over_control': True, 'detect_non_ha_changes': False, 'autoreset_control_seconds': 0, 'only_once': False, 'adapt_only_on_bare_turn_on': False, 'separate_turn_on_commands': False, 'send_split_delay': 0, 'adapt_delay': 0.0, 'skip_redundant_commands': False, 'intercept': True, 'multi_light_intercept': True, 'include_config_in_attributes': False, 'name': 'jjj'}'
2024-04-08 15:58:57.526 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] jjj: Setting up with '[]', config_entry.data: '{'name': 'jjj'}', config_entry.options: '{'lights': [], 'interval': 90, 'transition': 45.0, 'initial_transition': 1.0, 'min_brightness': 1, 'max_brightness': 100, 'min_color_temp': 2000, 'max_color_temp': 5500, 'prefer_rgb_color': False, 'sleep_brightness': 1, 'sleep_rgb_or_color_temp': 'color_temp', 'sleep_color_temp': 1000, 'sleep_rgb_color': [255, 56, 0], 'sleep_transition': 1.0, 'transition_until_sleep': False, 'sunrise_time': 'None', 'min_sunrise_time': 'None', 'max_sunrise_time': 'None', 'sunrise_offset': 0, 'sunset_time': 'None', 'min_sunset_time': 'None', 'max_sunset_time': 'None', 'sunset_offset': 0, 'brightness_mode': 'default', 'brightness_mode_time_dark': 900, 'brightness_mode_time_light': 3600, 'take_over_control': True, 'detect_non_ha_changes': False, 'autoreset_control_seconds': 0, 'only_once': False, 'adapt_only_on_bare_turn_on': False, 'separate_turn_on_commands': False, 'send_split_delay': 0, 'adapt_delay': 0.0, 'skip_redundant_commands': False, 'intercept': True, 'multi_light_intercept': True, 'include_config_in_attributes': False}', converted to '{'lights': [], 'interval': datetime.timedelta(seconds=90), 'transition': 45.0, 'initial_transition': 1.0, 'min_brightness': 1, 'max_brightness': 100, 'min_color_temp': 2000, 'max_color_temp': 5500, 'prefer_rgb_color': False, 'sleep_brightness': 1, 'sleep_rgb_or_color_temp': 'color_temp', 'sleep_color_temp': 1000, 'sleep_rgb_color': [255, 56, 0], 'sleep_transition': 1.0, 'transition_until_sleep': False, 'sunrise_time': None, 'min_sunrise_time': None, 'max_sunrise_time': None, 'sunrise_offset': datetime.timedelta(0), 'sunset_time': None, 'min_sunset_time': None, 'max_sunset_time': None, 'sunset_offset': datetime.timedelta(0), 'brightness_mode': 'default', 'brightness_mode_time_dark': datetime.timedelta(seconds=900), 'brightness_mode_time_light': datetime.timedelta(seconds=3600), 'take_over_control': True, 'detect_non_ha_changes': False, 'autoreset_control_seconds': 0, 'only_once': False, 'adapt_only_on_bare_turn_on': False, 'separate_turn_on_commands': False, 'send_split_delay': 0, 'adapt_delay': 0.0, 'skip_redundant_commands': False, 'intercept': True, 'multi_light_intercept': True, 'include_config_in_attributes': False, 'name': 'jjj'}'.
2024-04-08 15:58:57.536 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Adaptive Lighting Sleep Mode: Family room: last state is <state switch.adaptive_lighting_sleep_mode_family_room=off; icon=mdi:sleep, friendly_name=Adaptive Lighting Sleep Mode: Family room @ 2024-04-08T15:21:18.006054-07:00>
2024-04-08 15:58:57.537 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Adaptive Lighting Sleep Mode: Family room: Turning off
2024-04-08 15:58:57.538 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Adaptive Lighting Adapt Color: Family room: last state is <state switch.adaptive_lighting_adapt_color_family_room=on; icon=mdi:sun-thermometer, friendly_name=Adaptive Lighting Adapt Color: Family room @ 2024-04-08T15:21:18.007859-07:00>
2024-04-08 15:58:57.539 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Adaptive Lighting Adapt Color: Family room: Turning on
2024-04-08 15:58:57.541 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Adaptive Lighting Adapt Brightness: Family room: last state is <state switch.adaptive_lighting_adapt_brightness_family_room=on; icon=mdi:brightness-4, friendly_name=Adaptive Lighting Adapt Brightness: Family room @ 2024-04-08T15:21:18.009720-07:00>
2024-04-08 15:58:57.541 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Adaptive Lighting Adapt Brightness: Family room: Turning on
2024-04-08 15:58:57.543 ERROR (MainThread) [homeassistant.components.switch] Error adding entities for domain switch with platform adaptive_lighting
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 533, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 782, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1324, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/config/custom_components/adaptive_lighting/switch.py", line 952, in async_added_to_hass
    self.hass.bus.async_listen_once(
TypeError: EventBus.async_listen_once() got an unexpected keyword argument 'run_immediately'
2024-04-08 15:58:57.568 ERROR (MainThread) [homeassistant.components.switch] Error while setting up adaptive_lighting platform for switch
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 352, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 533, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 782, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1324, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/config/custom_components/adaptive_lighting/switch.py", line 952, in async_added_to_hass
    self.hass.bus.async_listen_once(
TypeError: EventBus.async_listen_once() got an unexpected keyword argument 'run_immediately'
  1. Your Adaptive Lighting configuration:
- name: Family room
  lights:
    - light.family_room
  interval:                     30
  transition:                   4
  initial_transition:           2
  min_brightness:               70
  max_brightness:               100
  min_color_temp:               2700
  max_color_temp:               4000
  prefer_rgb_color:             false
  sleep_brightness:             1
  sleep_rgb_or_color_temp:      color_temp
  sleep_color_temp:             2000
  #sleep_rgb_color:
  sleep_transition:             30
  transition_until_sleep:       false
  #sunrise_time:
  min_sunrise_time:             07:00:00
  #max_sunrise_time:
  #sunrise_offset:
  #sunset_time:
  #min_sunset_time:
  #max_sunset_time:
  sunset_offset:                3600
  brightness_mode:              tanh
  brightness_mode_time_dark:    7200
  brightness_mode_time_light:   0
  take_over_control:            True
  detect_non_ha_changes:        True
  autoreset_control_seconds:    0
  only_once:                    false
  adapt_only_on_bare_turn_on:   false
  separate_turn_on_commands:    True
  send_split_delay:             1
  adapt_delay:                  0
  skip_redundant_commands:      false
  intercept:                    False
  multi_light_intercept:        False
  include_config_in_attributes: True
  1. (If using Zigbee2MQTT), provide your configuration files (remove all personal information before posting):

    • devices.yaml
    • groups.yaml
    • configuration.yaml ⚠️; Warning REMOVE ALL of the PERSONAL INFORMATION BELOW before posting ⚠️;
      • mqtt: server:
      • mqtt: user:
      • mqtt: password:
      • advanced: pan_id:
      • advanced: network_key:
      • anything in log_syslog if you use this
    • Brand and model number of problematic light(s)
      N/A
  2. Describe the bug and how to reproduce it: Using HASS Core 2024.2.2 and Frontend 20240207.1, running on Docker.

On AL v1.20.0 the configuration YAML is read and the following switches are available in HASS:

switch.adaptive_lighting_adapt_brightness_AREA
switch.adaptive_lighting_adapt_color_AREA
switch.adaptive_lighting_AREA

After upgrading to version 1.21.0 using the same configuration YAML, the following switches are available in HASS:

switch.adaptive_lighting_adapt_brightness_AREA
switch.adaptive_lighting_adapt_color_AREA

However, the "overall" switch switch.adaptive_lighting_AREA is not available. The following log entries seem related:

2024-04-08 15:58:57.543 ERROR (MainThread) [homeassistant.components.switch] Error adding entities for domain switch with platform adaptive_lighting
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 533, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 782, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1324, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/config/custom_components/adaptive_lighting/switch.py", line 952, in async_added_to_hass
    self.hass.bus.async_listen_once(
TypeError: EventBus.async_listen_once() got an unexpected keyword argument 'run_immediately'
2024-04-08 15:58:57.568 ERROR (MainThread) [homeassistant.components.switch] Error while setting up adaptive_lighting platform for switch
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 352, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 533, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 782, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1324, in add_to_platform_finish
    await self.async_added_to_hass()
  File "/config/custom_components/adaptive_lighting/switch.py", line 952, in async_added_to_hass
    self.hass.bus.async_listen_once(
TypeError: EventBus.async_listen_once() got an unexpected keyword argument 'run_immediately'

When adding a new adaptive lighting entity, jjj using the GUI, the "overall" switch for jjj is appearing as expected.

  1. Steps to reproduce the behavior: Update from v1.20.0 to v1.21.0 and restart HASS.
basnijholt commented 2 months ago

Thanks for reporting!

Should be fixed in https://github.com/basnijholt/adaptive-lighting/releases/tag/1.21.1.