diff --git a/custom_components/adtpulse/alarm_control_panel.py b/custom_components/adtpulse/alarm_control_panel.py index 29d77d4..7bb7943 100644 --- a/custom_components/adtpulse/alarm_control_panel.py +++ b/custom_components/adtpulse/alarm_control_panel.py @@ -40,8 +40,7 @@ get_alarm_unique_id, get_gateway_unique_id, migrate_entity_name, - zone_open, - zone_trouble, + system_can_be_armed, ) LOG = getLogger(__name__) @@ -138,9 +137,8 @@ def supported_features(self) -> AlarmControlPanelEntityFeature | None: retval = AlarmControlPanelEntityFeature.ARM_CUSTOM_BYPASS if self._site.zones_as_dict is None: return retval - for zone in self._site.zones_as_dict.values(): - if zone_open(zone) or zone_trouble(zone): - return retval + if not system_can_be_armed(self._site): + return retval return ( AlarmControlPanelEntityFeature.ARM_AWAY | AlarmControlPanelEntityFeature.ARM_CUSTOM_BYPASS @@ -190,12 +188,20 @@ async def async_alarm_disarm(self, code: str | None = None) -> None: async def async_alarm_arm_home(self, code: str | None = None) -> None: """Send arm home command.""" + if not system_can_be_armed(self._site): + raise HomeAssistantError( + "Pulse system cannot be armed due to tripped zone" " - use force arm" + ) await self._perform_alarm_action( self._site.async_arm_home(), STATE_ALARM_ARMED_HOME ) async def async_alarm_arm_away(self, code: str | None = None) -> None: """Send arm away command.""" + if not system_can_be_armed(self._site): + raise HomeAssistantError( + "Pulse system cannot be armed due to tripped zone" " - use force arm" + ) await self._perform_alarm_action( self._site.async_arm_away(), STATE_ALARM_ARMED_AWAY ) diff --git a/custom_components/adtpulse/utils.py b/custom_components/adtpulse/utils.py index 513f8e8..bd09c13 100644 --- a/custom_components/adtpulse/utils.py +++ b/custom_components/adtpulse/utils.py @@ -3,6 +3,7 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_registry +from homeassistant.util import slugify from pyadtpulse.const import STATE_OK, STATE_ONLINE from pyadtpulse.site import ADTPulseSite from pyadtpulse.zones import ADTPulseZoneData