hass-circadian_lighting icon indicating copy to clipboard operation
hass-circadian_lighting copied to clipboard

TypeError: '<' not supported between instances of 'NoneType' and 'int'

Open mouth4war opened this issue 5 years ago • 8 comments

Traceback (most recent call last):
  File "/home/homeassistant/.homeassistant/custom_components/circadian_lighting/switch.py", line 245, in update_switch
    self._hs_color = self.calc_hs()
  File "/home/homeassistant/.homeassistant/custom_components/circadian_lighting/switch.py", line 228, in calc_hs
    return color_xy_to_hs(*self.calc_xy())
  File "/home/homeassistant/.homeassistant/custom_components/circadian_lighting/switch.py", line 225, in calc_xy
    return color_RGB_to_xy(*self.calc_rgb())
  File "/home/homeassistant/.homeassistant/custom_components/circadian_lighting/switch.py", line 220, in calc_rgb
    return color_temperature_to_rgb(self._attributes['sleep_colortemp'])
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/util/color.py", line 453, in color_temperature_to_rgb
    if color_temperature_kelvin < 1000:
TypeError: '<' not supported between instances of 'NoneType' and 'int'

Got this when turning CL switch on.

mouth4war avatar Apr 08 '19 21:04 mouth4war

One of the lights_ct was offline, if it means anything.

Config:

    name: Living Room
    lights_xy:
      - light.console_backlight
    lights_ct:
      - light.floor_lamp
      - light.living_wall_lamps
    # disable_entity: media_player.living_room_media_player
    # disable_state: 'on'
    sleep_entity: sensor.living_avr_source
    sleep_state: 'Shield'
    # sleep_colortemp: 4100
    sleep_brightness: 1
    # disable_brightness_adjust: True

mouth4war avatar Apr 08 '19 21:04 mouth4war

It's because it's trying to set based on sleep mode but doesn't know what color temperature to use because you commented it out.

claytonjn avatar Apr 08 '19 22:04 claytonjn

Unfortunately the configuration validation doesn't have a way (that I know of) for conditional requirements (i.e. if sleep_entity is defined, all sleep_XXX options must be set).

I suppose I could write my own logic to check for this, throw a more descriptive error, and not try to utilize sleep mode if not properly configured.

claytonjn avatar Apr 08 '19 23:04 claytonjn

Yup, that fixed it. Feel free to close or keep it open if you want to keep track of config validation improvements.

mouth4war avatar Apr 09 '19 10:04 mouth4war

I'll keep it open, thanks for reporting!

claytonjn avatar Apr 09 '19 14:04 claytonjn

Thanks for keeping this open - this bug bit me as well, and I was able to fix my issue by defining the missing sleep variables. +1 for the config logic checker.

geoffdavis avatar Jan 13 '20 05:01 geoffdavis

+1

I was going to open a new issue and then this showed up in the search.

@claytonjn - I don't know if you've considered how to address lights that are only brightness adjustable. I made a few groups with only lights_brightness but it seems like this value was still required.

poldim avatar Jan 13 '20 16:01 poldim

I just ran into this issue as well. At the very least could the Wiki be updated to state that all sleep settings have to be configured for it to work?

techguydave avatar Mar 26 '21 21:03 techguydave