hass-circadian_lighting: Error after 2.0.1b upgrade

I am getting errors after the second restart of HA everything seemed ok after the upgrade the system booted with no errors but I noticed lights were not changing so I ended up rebooting again for a different reason and got these errors

Screenshot_20200906-204550.png

Log Details (ERROR)

Logger: homeassistant.setup
Source: custom_components/circadian_lighting/__init__.py:295
First occurred: 8:45:11 PM (1 occurrences)
Last logged: 8:45:11 PM

Error during setup of component circadian_lightingTraceback (most recent call last): 
File "/usr/src/homeassistant/homeassistant/setup.py", line 191, in _async_setup_component result = await task 
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) 
File "/config/custom_components/circadian_lighting/__init__.py", line 107, in setup hass.data[DOMAIN] = CircadianLighting( 
File "/config/custom_components/circadian_lighting/__init__.py", line 156, in __init__ self._percent = self.calc_percent() 
File "/config/custom_components/circadian_lighting/__init__.py", line 295, in calc_percent a = (y - k) / (h - x) ** 2 

UnboundLocalError: local variable 'k' referenced before assignment

Here is my config

circadian_lighting:
  min_colortemp: 2000
  max_colortemp: 6535
  sunrise_offset: +01:00:00
  sunset_offset: +01:00:00

And switch

# Circadian Lighting
  - platform: circadian_lighting
    name: Circadian House
    lights_ct:
      - light.mommy_s_light
      - light.daddy_s_light
      - light.kitchen_lights
      - light.dining_lights
      - light.entry_lights
      - light.bar_light
      - light.living_room
    lights_brightness:
      - light.kids_room_light
    min_brightness: 5
    max_brightness: 100

  - platform: circadian_lighting
    name: Circadian Bathrooms
    lights_ct:
      - light.master_bath_lights
      - light.downstairs_bath
      - light.hallway_lights
      - light.master_closet_2
    lights_brightness:
      - light.kids_bathroom_lights
      - light.laundry_light
    min_brightness: 30
    max_brightness: 100
      
  - platform: circadian_lighting
    name: Circadian Utilities
    lights_ct:
      - light.porch
      - light.back_porch
    disable_brightness_adjust: true

Screenshot_20200906-205405.png

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (9 by maintainers)

Commits related to this issue

Most upvoted comments

I was waiting to close until I do a stable release, but I guess since the issue was introduced in beta and fixed in beta it makes more sense to close now 😃

I didn’t get notifications of these issues, but now I’ve turned it on. It is indeed that

today[SUN_EVENT_SUNRISE] < now_ts < today[SUN_EVENT_SUNSET] is False

and

today[SUN_EVENT_SUNSET] < now_ts < today[SUN_EVENT_SUNRISE] is False

I am looking into it now! And I agree that some more logging would be useful 😉