mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
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:
parent
5ed1f16f25
commit
e22742550c
@ -24,6 +24,7 @@ CONF_DEVICE_BAUD = "baudrate"
|
|||||||
CONF_DEVICE_PATH = "path"
|
CONF_DEVICE_PATH = "path"
|
||||||
CONF_DEVICE_PORT = "port"
|
CONF_DEVICE_PORT = "port"
|
||||||
CONF_DEVICE_TYPE = "type"
|
CONF_DEVICE_TYPE = "type"
|
||||||
|
CONF_AUTO_BYPASS = "autobypass"
|
||||||
CONF_PANEL_DISPLAY = "panel_display"
|
CONF_PANEL_DISPLAY = "panel_display"
|
||||||
CONF_ZONE_NAME = "name"
|
CONF_ZONE_NAME = "name"
|
||||||
CONF_ZONE_TYPE = "type"
|
CONF_ZONE_TYPE = "type"
|
||||||
@ -39,6 +40,7 @@ DEFAULT_DEVICE_PORT = 10000
|
|||||||
DEFAULT_DEVICE_PATH = "/dev/ttyUSB0"
|
DEFAULT_DEVICE_PATH = "/dev/ttyUSB0"
|
||||||
DEFAULT_DEVICE_BAUD = 115200
|
DEFAULT_DEVICE_BAUD = 115200
|
||||||
|
|
||||||
|
DEFAULT_AUTO_BYPASS = False
|
||||||
DEFAULT_PANEL_DISPLAY = False
|
DEFAULT_PANEL_DISPLAY = False
|
||||||
|
|
||||||
DEFAULT_ZONE_TYPE = "opening"
|
DEFAULT_ZONE_TYPE = "opening"
|
||||||
@ -102,6 +104,7 @@ CONFIG_SCHEMA = vol.Schema(
|
|||||||
vol.Optional(
|
vol.Optional(
|
||||||
CONF_PANEL_DISPLAY, default=DEFAULT_PANEL_DISPLAY
|
CONF_PANEL_DISPLAY, default=DEFAULT_PANEL_DISPLAY
|
||||||
): cv.boolean,
|
): cv.boolean,
|
||||||
|
vol.Optional(CONF_AUTO_BYPASS, default=DEFAULT_AUTO_BYPASS): cv.boolean,
|
||||||
vol.Optional(CONF_ZONES): {vol.Coerce(int): ZONE_SCHEMA},
|
vol.Optional(CONF_ZONES): {vol.Coerce(int): ZONE_SCHEMA},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -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):
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
"""Set up for AlarmDecoder alarm panels."""
|
"""Set up for AlarmDecoder alarm panels."""
|
||||||
device = AlarmDecoderAlarmPanel()
|
device = AlarmDecoderAlarmPanel(discovery_info["autobypass"])
|
||||||
add_entities([device])
|
add_entities([device])
|
||||||
|
|
||||||
def alarm_toggle_chime_handler(service):
|
def alarm_toggle_chime_handler(service):
|
||||||
@ -66,7 +66,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
class AlarmDecoderAlarmPanel(AlarmControlPanel):
|
class AlarmDecoderAlarmPanel(AlarmControlPanel):
|
||||||
"""Representation of an AlarmDecoder-based alarm panel."""
|
"""Representation of an AlarmDecoder-based alarm panel."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, auto_bypass):
|
||||||
"""Initialize the alarm panel."""
|
"""Initialize the alarm panel."""
|
||||||
self._display = ""
|
self._display = ""
|
||||||
self._name = "Alarm Panel"
|
self._name = "Alarm Panel"
|
||||||
@ -80,6 +80,7 @@ class AlarmDecoderAlarmPanel(AlarmControlPanel):
|
|||||||
self._programming_mode = None
|
self._programming_mode = None
|
||||||
self._ready = None
|
self._ready = None
|
||||||
self._zone_bypassed = None
|
self._zone_bypassed = None
|
||||||
|
self._auto_bypass = auto_bypass
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Register callbacks."""
|
"""Register callbacks."""
|
||||||
@ -158,11 +159,15 @@ class AlarmDecoderAlarmPanel(AlarmControlPanel):
|
|||||||
def alarm_arm_away(self, code=None):
|
def alarm_arm_away(self, code=None):
|
||||||
"""Send arm away command."""
|
"""Send arm away command."""
|
||||||
if code:
|
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")
|
self.hass.data[DATA_AD].send(f"{code!s}2")
|
||||||
|
|
||||||
def alarm_arm_home(self, code=None):
|
def alarm_arm_home(self, code=None):
|
||||||
"""Send arm home command."""
|
"""Send arm home command."""
|
||||||
if code:
|
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")
|
self.hass.data[DATA_AD].send(f"{code!s}3")
|
||||||
|
|
||||||
def alarm_arm_night(self, code=None):
|
def alarm_arm_night(self, code=None):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user