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

Error Message on Startup 2023.10.3

Open enkama opened this issue 8 months ago • 1 comments

Hey!

I am getting this error message on every startup 6 times in my log. What could it be about and can I fix it myself?

home-assistant:2023.10.3 circadian-lightning:2.1.4

2023-10-17 09:49:46.339 ERROR (MainThread) [homeassistant.components.switch] Error adding entities for domain switch with platform circadian_lighting
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1057, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 779, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 879, in _async_write_ha_state
    state, attr = self._async_generate_attributes()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 823, in _async_generate_attributes
    attr.update(self.extra_state_attributes or {})
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/circadian_lighting/switch.py", line 268, 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 290, in _color_temperature
    if not self._is_sleep()
           ^^^^^^^^^^^^^^^^
  File "/config/custom_components/circadian_lighting/switch.py", line 284, in _is_sleep
    and self.hass.states.get(self._sleep_entity).state in self._sleep_state
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'state'

enkama avatar Oct 17 '23 07:10 enkama

My guess is that you have a sleep entity configured and that entity is not available at the time Circadian Lighting tries to start. Off the top of my head I think the best long-term solution would be to have Circadian Lighting create a switch entity that controls sleep mode and then rely on the user to create an automation for controlling that entity. I'm also considering abandoning the integration approach altogether and migrating Circadian Lighting to a blueprint, which I think better aligns with core Home Assistant team vision.

claytonjn avatar Oct 17 '23 22:10 claytonjn