mirror of
https://github.com/home-assistant/core.git
synced 2025-07-31 19:25:12 +02:00
Guard Guardian switches from redundant on/off calls (#78791)
This commit is contained in:
@@ -146,6 +146,9 @@ class ValveControllerSwitch(ValveControllerEntity, SwitchEntity):
|
|||||||
|
|
||||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn the switch off."""
|
"""Turn the switch off."""
|
||||||
|
if not self._attr_is_on:
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with self._client:
|
async with self._client:
|
||||||
await self.entity_description.off_action(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:
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||||
"""Turn the switch on."""
|
"""Turn the switch on."""
|
||||||
|
if self._attr_is_on:
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with self._client:
|
async with self._client:
|
||||||
await self.entity_description.on_action(self._client)
|
await self.entity_description.on_action(self._client)
|
||||||
|
Reference in New Issue
Block a user