Skip to content

Commit

Permalink
avoiding to emit the off command when the state is off
Browse files Browse the repository at this point in the history
  • Loading branch information
danielcaceresm committed Nov 19, 2024
1 parent 814993a commit 4175073
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions custom_components/smartir/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 4175073

Please sign in to comment.