From 4175073e206af31e018dbe831d94b1ea02d2aa3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20C=C3=A1ceres?= Date: Tue, 19 Nov 2024 19:20:00 +0100 Subject: [PATCH] avoiding to emit the off command when the state is off --- custom_components/smartir/light.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/custom_components/smartir/light.py b/custom_components/smartir/light.py index 7d0f2f72..768e5109 100644 --- a/custom_components/smartir/light.py +++ b/custom_components/smartir/light.py @@ -345,9 +345,10 @@ async def async_turn_on(self, **params): self.async_write_ha_state() async def async_turn_off(self): - self._state = STATE_OFF - await self.send_command(CMD_POWER_OFF) - self.async_write_ha_state() + if self._state != STATE_OFF: + self._state = STATE_OFF + await self.send_command(CMD_POWER_OFF) + self.async_write_ha_state() async def async_toggle(self): await (self.async_turn_on() if not self.is_on else self.async_turn_off())