Skip to content
This repository has been archived by the owner on Feb 2, 2024. It is now read-only.

Commit

Permalink
add system_can_be_armed check to non-forced arm home/stay
Browse files Browse the repository at this point in the history
  • Loading branch information
rlippmann committed Oct 11, 2023
1 parent f333afe commit d738bde
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 11 additions & 5 deletions custom_components/adtpulse/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
)
Expand Down
1 change: 1 addition & 0 deletions custom_components/adtpulse/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d738bde

Please sign in to comment.