Skip to content

Commit c15fa17

Browse files
authored
Merge pull request #4 from macros0/patch-1
Error correction in the _on_switch method
2 parents 8899490 + 8451d6f commit c15fa17

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

custom_components/binary_sensor/NooLite.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,10 @@ def _switch_off(self):
126126
self.schedule_update_ha_state()
127127

128128
def _on_switch(self):
129-
self._timer.cancel()
129+
if self._timer is not None:
130+
self._timer.cancel()
130131
self._timer = None
131-
self._switch_on() if self.is_on else self._switch_off()
132+
self._switch_on() if not self.is_on else self._switch_off()
132133
self.schedule_update_ha_state()
133134

134135
def _on_load_preset(self):

0 commit comments

Comments
 (0)