Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component failing after HASS update #219

Open
iBobik opened this issue Mar 21, 2023 · 3 comments
Open

Component failing after HASS update #219

iBobik opened this issue Mar 21, 2023 · 3 comments

Comments

@iBobik
Copy link

iBobik commented Mar 21, 2023

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
Copy link
Author

iBobik commented Mar 21, 2023

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
Copy link
Owner

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
Copy link
Author

iBobik commented Mar 24, 2023

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

iBobik added a commit to iBobik/hass-circadian_lighting that referenced this issue Mar 24, 2023
To help debug claytonjn#219 added else branch with debug output and return, so in case of this event it will at least start and allow to recover later (when timestamps will be in ranges).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants