From d591787077017a16d45154ea2ad204acb10d893b Mon Sep 17 00:00:00 2001 From: Aaron Bach Date: Mon, 19 Sep 2022 13:15:32 -0600 Subject: [PATCH] Guard Guardian switches from redundant on/off calls (#78791) --- homeassistant/components/guardian/switch.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/homeassistant/components/guardian/switch.py b/homeassistant/components/guardian/switch.py index 5471d2471e8..6f5dd4d16b7 100644 --- a/homeassistant/components/guardian/switch.py +++ b/homeassistant/components/guardian/switch.py @@ -146,6 +146,9 @@ class ValveControllerSwitch(ValveControllerEntity, SwitchEntity): async def async_turn_off(self, **kwargs: Any) -> None: """Turn the switch off.""" + if not self._attr_is_on: + return + try: async with self._client: await self.entity_description.off_action(self._client) @@ -159,6 +162,9 @@ class ValveControllerSwitch(ValveControllerEntity, SwitchEntity): async def async_turn_on(self, **kwargs: Any) -> None: """Turn the switch on.""" + if self._attr_is_on: + return + try: async with self._client: await self.entity_description.on_action(self._client)