Fix RainMachine bugs (#106231)

This commit is contained in:
kingy444 2023-12-27 22:38:37 +11:00 committed by GitHub
parent c19688e2d2
commit 25f9c5f34b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 45 additions and 7 deletions

View file

@ -20,6 +20,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
from . import RainMachineData, RainMachineEntity, async_update_programs_and_zones
from .const import (
CONF_ALLOW_INACTIVE_ZONES_TO_RUN,
CONF_DEFAULT_ZONE_RUN_TIME,
CONF_DURATION,
CONF_USE_APP_RUN_TIMES,
@ -300,7 +301,10 @@ class RainMachineActivitySwitch(RainMachineBaseSwitch):
The only way this could occur is if someone rapidly turns a disabled activity
off right after turning it on.
"""
if not self.coordinator.data[self.entity_description.uid]["active"]:
if (
not self._entry.options[CONF_ALLOW_INACTIVE_ZONES_TO_RUN]
and not self.coordinator.data[self.entity_description.uid]["active"]
):
raise HomeAssistantError(
f"Cannot turn off an inactive program/zone: {self.name}"
)
@ -314,7 +318,10 @@ 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"]:
if (
not self._entry.options[CONF_ALLOW_INACTIVE_ZONES_TO_RUN]
and not self.coordinator.data[self.entity_description.uid]["active"]
):
self._attr_is_on = False
self.async_write_ha_state()
raise HomeAssistantError(