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

HA 2021.12 - Error while setting up circadian_lighting platform for switch #182

Open
TheGroundZero opened this issue Dec 14, 2021 · 4 comments

Comments

@TheGroundZero
Copy link

Logger: homeassistant.components.switch
Source: custom_components/circadian_lighting/switch.py:285
Integration: Switch (documentation, issues)
First occurred: 14:27:13 (2 occurrences)
Last logged: 14:27:13

    Error adding entities for domain switch with platform circadian_lighting
    Error while setting up circadian_lighting platform for switch

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 613, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 505, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 541, in _async_write_ha_state
    extra_state_attributes = self.extra_state_attributes
  File "/config/custom_components/circadian_lighting/switch.py", line 269, in extra_state_attributes
    return {"hs_color": self._hs_color, "brightness": self._brightness, "colortemp": self._color_temperature()}
  File "/config/custom_components/circadian_lighting/switch.py", line 291, in _color_temperature
    if not self._is_sleep()
  File "/config/custom_components/circadian_lighting/switch.py", line 285, in _is_sleep
    and self.hass.states.get(self._sleep_entity).state in self._sleep_state
AttributeError: 'NoneType' object has no attribute 'state'
@claytonjn
Copy link
Owner

It looks like whatever entity you have configured in CL as sleep_entity is not available at the time CL tries to start up - can you share that configuration?

@TheGroundZero
Copy link
Author

I thought that was an issue with the 2021.12 upgrade, but the issue may actually be on my end?

My media_player sometimes goes unavailable in HA, so this may indeed be the reason of the issue.
The fact that the circadian lighting switch magically seems to have re-appeared, seems to confirm this as well.

# Circadian lighting
# https://github.com/claytonjn/hass-circadian_lighting
- platform: circadian_lighting
  name: Living room circadian
  lights_ct:
    - light.living_lamp_1_level_light_color_on_off
    - light.living_lamp_2_level_light_color_on_off
  sleep_entity: media_player.tv_livingroom
  sleep_state: on
  sleep_brightness: 1
  sleep_colortemp: 10000

@maxoss
Copy link

maxoss commented Dec 15, 2021

Same problem here.
Looks like CL is started before in my case boolean sleep entity which result in the same error

@pakshuang
Copy link

Is there a workaround for this?

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

4 participants