From a464189ce07b433416f8a5e7fda52bb967dbf05b Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Sat, 5 Sep 2020 15:02:52 +0200 Subject: [PATCH] Fix case when from_state is None, closes #111 Made this commit on my phone and didn't test it yet. --- custom_components/circadian_lighting/switch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/circadian_lighting/switch.py b/custom_components/circadian_lighting/switch.py index 6887219c..eee3751e 100755 --- a/custom_components/circadian_lighting/switch.py +++ b/custom_components/circadian_lighting/switch.py @@ -382,7 +382,7 @@ class CircadianSwitch(SwitchEntity, RestoreEntity): await asyncio.wait(tasks) async def _light_state_changed(self, entity_id, from_state, to_state): - if to_state.state == "on" and from_state.state != "on": + if to_state.state == "on" and (from_state is None or from_state.state != "on"): _LOGGER.debug(_difference_between_states(from_state, to_state)) await self._force_update_switch(lights=[entity_id])