basnijholt / adaptive-lighting

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

Unable to setup through yaml #745

Closed RoboMagus closed 1 year ago

RoboMagus commented 1 year 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: (Got additional data in the debug logging for my own troubleshooting)

    2023-08-13 18:37:33.971 DEBUG (MainThread) [custom_components.adaptive_lighting.switch] Setting up AdaptiveLighting with data: {'e9dc015ec551ed2af75b99c023b6265a': {'undo_update_listener': <function ConfigEntry.add_update_listener.<locals>.<lambda> at 0x7ffacd4f3240>}} and config_entry {'entry_id': 'e9dc015ec551ed2af75b99c023b6265a', 'version': 1, 'domain': 'adaptive_lighting', 'title': 'bank', 'data': mappingproxy({'name': 'bank', 'lights': ['light.ceiling_lights'], 'prefer_rgb_color': False, 'transition': 60.0, 'initial_transition': 2.0, 'interval': 90.0, 'min_brightness': 75, 'max_brightness': 100, 'min_color_temp': 2000, 'max_color_temp': 5800, 'sleep_brightness': 20, 'sleep_color_temp': 2000, 'min_sunrise_time': '06:15:00', 'max_sunrise_time': '07:00:00', 'sunrise_offset': -900.0, 'min_sunset_time': '18:20:00', 'max_sunset_time': '21:15:00', 'sunset_offset': 1800.0, 'brightness_mode': 'tanh', 'brightness_mode_time_dark': 2700.0, 'brightness_mode_time_light': 4500.0, 'take_over_control': True, 'adapt_only_on_bare_turn_on': True, 'detect_non_ha_changes': False, 'only_once': False, 'skip_redundant_commands': True, 'transition_until_sleep': False, 'adapt_delay': 0.0, 'include_config_in_attributes': False, 'autoreset_control_seconds': 0, 'sleep_rgb_color': [255, 56, 0], 'send_split_delay': 0, 'multi_light_intercept': True, 'sleep_transition': 1.0, 'sleep_rgb_or_color_temp': 'color_temp', 'separate_turn_on_commands': False}), 'options': mappingproxy({}), 'unique_id': 'bank', 'supports_unload': True, 'supports_remove_device': False, 'pref_disable_new_entities': False, 'pref_disable_polling': False, 'source': 'import', 'state': <ConfigEntryState.LOADED: 'loaded'>, 'disabled_by': None, '_setup_lock': None, 'update_listeners': [<function async_update_options at 0x7ffac7ae9c60>], 'reason': None, '_async_cancel_retry_setup': None, '_on_unload': None, 'reload_lock': <asyncio.locks.Lock object at 0x7ffafe6fc190 [unlocked]>, '_tasks': set(), '_background_tasks': set()}
    2023-08-13 18:37:33.971 WARNING (MainThread) [custom_components.adaptive_lighting.switch] Deleting AdaptiveLighting switch 'bank' because YAML defined switch has been removed from YAML configuration
  2. Your Adaptive Lighting configuration: Issue reproduces on HA 2023.8.1 with a clean config with demo entities.

demo:

adaptive_lighting:
  - name: "bank"
    lights:
      - light.ceiling_lights
    prefer_rgb_color: false
    transition: 60
    initial_transition: 2
    interval: 90
    min_brightness: 75
    max_brightness: 100
    min_color_temp: 2000
    max_color_temp: 5800
    sleep_brightness: 20
    sleep_color_temp: 2000

    min_sunrise_time: '06:15:00'
    max_sunrise_time: '07:00:00'
    sunrise_offset: -900 # 15 min earlier
    min_sunset_time: '18:20:00'
    max_sunset_time: '21:15:00'
    sunset_offset: 1800 # 30 min later

    brightness_mode: tanh
    brightness_mode_time_dark: 2700
    brightness_mode_time_light: 4500

    take_over_control: true
    adapt_only_on_bare_turn_on: true
    detect_non_ha_changes: false
    only_once: false
    skip_redundant_commands: 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: Cannot get AL to configure through yaml (See initial warning in logs). After encountering on my live config on 2023.7.3, I tried some debugging on a clean 2023.8.1 HA Config with demo entities and it reproduces.

    Create clean HA environment with the provided yaml in the config file and observe the logs for the warning to appear.
  3. Steps to reproduce the behavior: See part 4.

  4. Workaround to get past the warning. After commenting out the lines that cause AL to preemptively stop, the config simply procedes and actually completes. Reverting this change and restarting HA causes the warning to be bypassed somehow as the entities had already been created. All works as expected from there on out... 🤔

basnijholt commented 1 year ago

I have fixed this in #752, thanks a lot for reporting!