Ensure that inactive RainMachine switch that is toggled on is toggled back off (#60959)

This commit is contained in:
Aaron Bach 2021-12-03 21:05:01 -07:00 committed by GitHub
parent 68ca0a05c8
commit 566716d697
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -277,6 +277,8 @@ class RainMachineActivitySwitch(RainMachineBaseSwitch):
async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the switch on."""
if not self.coordinator.data[self.entity_description.uid]["active"]:
self._attr_is_on = False
self.async_write_ha_state()
raise HomeAssistantError(
f"Cannot turn on an inactive program/zone: {self.name}"
)