Skip to content

Commit

Permalink
Merge pull request #148 from raducotescu/issue/140
Browse files Browse the repository at this point in the history
fix #140: Add support for triggering the alarm via the alarm_trigger service
  • Loading branch information
tahvane1 authored Jan 7, 2023
2 parents bc8dc7e + 64d3a2a commit dfa4981
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions custom_components/jablotron80/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ def _check_code(code: Optional[str]) -> Optional[str]:
@property
def supported_features(self) -> int:
if self._cu.mode == JA80CentralUnit.SYSTEM_MODE_UNSPLIT:
return SUPPORT_ALARM_ARM_AWAY
return SUPPORT_ALARM_ARM_AWAY | SUPPORT_ALARM_TRIGGER
elif self._cu.mode == JA80CentralUnit.SYSTEM_MODE_PARTIAL:
return SUPPORT_ALARM_ARM_AWAY|SUPPORT_ALARM_ARM_HOME|SUPPORT_ALARM_ARM_NIGHT
return SUPPORT_ALARM_ARM_AWAY|SUPPORT_ALARM_ARM_HOME|SUPPORT_ALARM_ARM_NIGHT | SUPPORT_ALARM_TRIGGER
elif self._cu.mode == JA80CentralUnit.SYSTEM_MODE_SPLIT:
return SUPPORT_ALARM_ARM_AWAY | SUPPORT_ALARM_ARM_HOME
return SUPPORT_ALARM_ARM_AWAY
return SUPPORT_ALARM_ARM_AWAY | SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_TRIGGER
return SUPPORT_ALARM_ARM_AWAY | SUPPORT_ALARM_TRIGGER

@property
def code_arm_required(self) -> bool:
Expand Down Expand Up @@ -161,8 +161,11 @@ async def async_alarm_arm_night(self, code=None) -> None:
if self._cu.mode == JA80CentralUnit.SYSTEM_MODE_PARTIAL:
self._cu.arm(code,"B")

async def async_alarm_trigger(self, code=None) -> None:
raise NotImplementedError()
async def async_alarm_trigger(self, code=None) -> None:
if self.state == STATE_ALARM_DISARMED:
self._cu.send_keypress_sequence("*7" + self._cu._master_code, b'\xa1')
else:
self._cu.send_keypress_sequence("*7" + self._cu._master_code, b'\xa2')

async def async_alarm_arm_custom_bypass(self, code=None) -> None:
raise NotImplementedError()
Expand Down Expand Up @@ -294,4 +297,4 @@ async def async_added_to_hass(self) -> None:
async def async_will_remove_from_hass(self) -> None:
"""Entity being removed from hass."""
for zone in self._zones:
zone.remove_callback(self.async_write_ha_state)
zone.remove_callback(self.async_write_ha_state)

0 comments on commit dfa4981

Please sign in to comment.