claytonjn / hass-circadian_lighting

Circadian Lighting custom component for Home Assistant
Apache License 2.0
756 stars 89 forks source link

Component failing after HASS update #219

Open iBobik opened 1 year ago

iBobik commented 1 year ago

I've updated HASS and component can not start:

Home Assistant 2023.3.5 Supervisor 2023.03.1 Operating System 9.5 Frontend 20230309.1 - latest

Logger: homeassistant.setup Source: custom_components/circadian_lighting/init.py:292 Integration: circadian_lighting (documentation, issues) First occurred: 11:26:23 (1 occurrences) Last logged: 11:26:23

Error during setup of component circadian_lighting Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/setup.py", line 256, in _async_setup_component result = await task File "/config/custom_components/circadian_lighting/init.py", line 119, in async_setup await hass.data[DOMAIN]._async_init(interval=conf.get(CONF_INTERVAL)) File "/config/custom_components/circadian_lighting/init.py", line 157, in _async_init self._percent = await self.async_calc_percent() File "/config/custom_components/circadian_lighting/init.py", line 292, in async_calc_percent a = (y - k) / (h - x) ** 2 UnboundLocalError: local variable 'k' referenced before assignment

iBobik commented 1 year ago

Now it started and fluxing sucessfully. 🤷‍♂️

How about to add else branch with some useful debug logging, so we will know more in case it happens?

claytonjn commented 1 year ago

How about to add else branch with some useful debug logging, so we will know more in case it happens?

That's a good idea, will leave this open as a reminder to add this when I have time - or I welcome any pull requests

iBobik commented 1 year ago

It is failing again now. I've added debug output to else branch:

2023-03-24 11:47:34.431 ERROR (MainThread) [custom_components.circadian_lighting] now 2023-03-24 10:47:28.955773+00:00
2023-03-24 11:47:34.445 ERROR (MainThread) [custom_components.circadian_lighting] now_ts 1679654848.955773
2023-03-24 11:47:34.448 ERROR (MainThread) [custom_components.circadian_lighting] today {'sunset': 1679613005.648675, 'sunrise': 1679633342.442474, 'solar_noon': 1679655600.0, 'solar_midnight': 1679698775.0}

This is my config:

circadian_lighting:
  min_colortemp: 2000
  sunset_offset: '6:00:00'
  transition: 1

switch:
  - platform: circadian_lighting
    name: circadian_lighting_very_low_brightness
    initial_transition: 0.2
    min_brightness: 5
    lights_ct:
      - light.hall_light_2
  - platform: circadian_lighting
    name: circadian_lighting_low_brightness
    initial_transition: 0.2
    min_brightness: 50
    lights_ct:
      - light.loznice_svetlo_dolni
      - light.loznice_svetlo_horni
      - light.bedroom_light
      - light.hall_light
      - light.livingroom_light
  - platform: circadian_lighting
    name: circadian_lighting_high_brightness
    disable_brightness_adjust: true
    initial_transition: 0.2
    lights_ct:
      - light.kitchen_light
      - light.bathroom_light_ceiling
      - light.bathroom_light_mirror
      - light.toilet_light
      - light.honza_pracovna_svetlo
      - light.gabka_pracovna_svetlo