Add "autobypass" option when arming AlarmDecoder integration (#30002)

* Initial implementation

* Passing autobypass parameter to constructor, as suggested

* Black formatting

* Removed default value from autobypass parameter of the constructor, as it's redundant
This commit is contained in:
Eleftherios Chamakiotis 2020-01-07 03:17:21 +02:00 committed by Charles Garwood
parent 5ed1f16f25
commit e22742550c
2 changed files with 10 additions and 2 deletions

View file

@ -35,7 +35,7 @@ ALARM_KEYPRESS_SCHEMA = vol.Schema({vol.Required(ATTR_KEYPRESS): cv.string})
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up for AlarmDecoder alarm panels."""
device = AlarmDecoderAlarmPanel()
device = AlarmDecoderAlarmPanel(discovery_info["autobypass"])
add_entities([device])
def alarm_toggle_chime_handler(service):
@ -66,7 +66,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
class AlarmDecoderAlarmPanel(AlarmControlPanel):
"""Representation of an AlarmDecoder-based alarm panel."""
def __init__(self):
def __init__(self, auto_bypass):
"""Initialize the alarm panel."""
self._display = ""
self._name = "Alarm Panel"
@ -80,6 +80,7 @@ class AlarmDecoderAlarmPanel(AlarmControlPanel):
self._programming_mode = None
self._ready = None
self._zone_bypassed = None
self._auto_bypass = auto_bypass
async def async_added_to_hass(self):
"""Register callbacks."""
@ -158,11 +159,15 @@ class AlarmDecoderAlarmPanel(AlarmControlPanel):
def alarm_arm_away(self, code=None):
"""Send arm away command."""
if code:
if self._auto_bypass:
self.hass.data[DATA_AD].send(f"{code!s}6#")
self.hass.data[DATA_AD].send(f"{code!s}2")
def alarm_arm_home(self, code=None):
"""Send arm home command."""
if code:
if self._auto_bypass:
self.hass.data[DATA_AD].send(f"{code!s}6#")
self.hass.data[DATA_AD].send(f"{code!s}3")
def alarm_arm_night(self, code=None):