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

AttributeError: 'NoneType' object has no attribute 'state'

Open johnnyletrois opened this issue 5 years ago • 6 comments

Get this error on startup:

2019-04-06 17:10:30 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved Traceback (most recent call last): File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/circadian_lighting/switch.py", line 335, in sleep_state_changed if to_state.state == self._attributes['sleep_state'] or from_state.state == self._attributes['sleep_state']: AttributeError: 'NoneType' object has no attribute 'state'

johnnyletrois avatar Apr 07 '19 00:04 johnnyletrois

What does your switch configuration look like?

claytonjn avatar Apr 07 '19 04:04 claytonjn

` - platform: circadian_lighting name: CT lights_ct: - light.bed_sconces

  • platform: circadian_lighting name: Brightness lights_brightness:
    • light.attic_bathroom_sconce_level
    • light.attic_bedroom_ceiling_level
    • light.attic_stairs_level min_brightness: 1 max_brightness: 50 sleep_entity: input_boolean.circadian_sleepmode sleep_state: "on" sleep_brightness: 1 `

and I have input boolean:

circadian_sleepmode: initial: off

johnnyletrois avatar Apr 08 '19 03:04 johnnyletrois

Do you only get the error on initial startup of Home Assistant, and everything works after that (including sleep mode)? I'm guessing what's happening is that CL is being initialized before the input_boolean, so CL doesn't think it exists yet. If that's a case you can ignore the error and I can put that section of code in a try block to better handle the issue.

claytonjn avatar Apr 08 '19 15:04 claytonjn

After update to HA version 0.98.5 I get this error. I have not seen it before. It comes whenever I turn ON the switch for the Circadian Lighting.

______________ CONFIG __________________ circadian_lighting: min_colortemp: 2000 max_colortemp: 6536 interval: 180 transition: 10 sunrise_offset: 00:30:00 sunset_offset: -00:30:00 switch:

  • platform: circadian_lighting name: Auto-Color lights_ct:

    • light.kok_tak
    • light.badrum_tak min_brightness: 2 max_brightness: 100 sleep_entity: sensor.circadian_sleep sleep_state: true sleep_colortemp: 1000 #1000 - 10000 sleep_brightness: 2 # 1 - 100

    disable_entity: sensor.circadian_disable disable_state: true

  • platform: circadian_lighting name: Auto-Color2 lights_ct:

    • light.sovrum_bank lights_rgb:
    • light.sovrum_sang disable_brightness_adjust: true min_brightness: 2 max_brightness: 100 sleep_entity: sensor.circadian_sleep sleep_state: true sleep_colortemp: 2000 sleep_brightness: 2 disable_entity: sensor.circadian_disable disable_state: true

LOG____________________________ 2019-09-10 16:13:10 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140222422584912] 'NoneType' object has no attribute 'state'

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_serviceconnection.context(msg), File "/usr/src/homeassistant/homeassistant/core.py", line 1235, in async_callawait asyncio.shield(self._execute_service(handler, service_call)) File "/usr/src/homeassistant/homeassistant/core.py", line 1260, in _execute_serviceawait handler.func(service_call) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 210, in handle_serviceself._platforms.values(), func, call, service_name, required_features File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 349, in entity_service_callfuture.result() # pop exception if have File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 371, in _handle_service_platform_callawait getattr(entity, func)(**data) File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in runresult = self.fn(*self.args, **self.kwargs) File "/config/custom_components/circadian_lighting/switch.py", line 198, in turn_onself.update_switch(DEFAULT_INITIAL_TRANSITION) File "/config/custom_components/circadian_lighting/switch.py", line 253, in update_switchself.adjust_lights(self._lights, transition) File "/config/custom_components/circadian_lighting/switch.py", line 269, in adjust_lightsif self.should_adjust(): File "/config/custom_components/circadian_lighting/switch.py", line 262, in should_adjustelif self._disable_entity is not None and self.hass.states.get(self._disable_entity).state == self._disable_state:

AttributeError: 'NoneType' object has no attribute 'state'

T-h-o-m-a-s avatar Sep 10 '19 14:09 T-h-o-m-a-s

Is there a problem with your sensor.circadian_disable entity?

claytonjn avatar Sep 10 '19 14:09 claytonjn

Yes, you are right. It was. When corrected it now works again. Sorry for the fuzz. But, it might help someone else troubleshooting.

T-h-o-m-a-s avatar Sep 10 '19 15:09 T-h-o-m-a-s