mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Enable AlarmDecoder arming without security code (#32390)
* set alarmdecoder code_arm_required to False * rm unnecessary f strings * add code_arm_required config option * add self as codeowner :-) * add self as codeowner the right way
This commit is contained in:
parent
f4b3760a1a
commit
40356b4fc5
@ -17,6 +17,7 @@ homeassistant/components/abode/* @shred86
|
||||
homeassistant/components/adguard/* @frenck
|
||||
homeassistant/components/airly/* @bieniu
|
||||
homeassistant/components/airvisual/* @bachya
|
||||
homeassistant/components/alarmdecoder/* @ajschmidt8
|
||||
homeassistant/components/alexa/* @home-assistant/cloud @ochlocracy
|
||||
homeassistant/components/almond/* @gcampax @balloob
|
||||
homeassistant/components/alpha_vantage/* @fabaff
|
||||
|
@ -33,6 +33,7 @@ CONF_ZONE_RFID = "rfid"
|
||||
CONF_ZONES = "zones"
|
||||
CONF_RELAY_ADDR = "relayaddr"
|
||||
CONF_RELAY_CHAN = "relaychan"
|
||||
CONF_CODE_ARM_REQUIRED = "code_arm_required"
|
||||
|
||||
DEFAULT_DEVICE_TYPE = "socket"
|
||||
DEFAULT_DEVICE_HOST = "localhost"
|
||||
@ -42,6 +43,7 @@ DEFAULT_DEVICE_BAUD = 115200
|
||||
|
||||
DEFAULT_AUTO_BYPASS = False
|
||||
DEFAULT_PANEL_DISPLAY = False
|
||||
DEFAULT_CODE_ARM_REQUIRED = True
|
||||
|
||||
DEFAULT_ZONE_TYPE = "opening"
|
||||
|
||||
@ -105,6 +107,9 @@ CONFIG_SCHEMA = vol.Schema(
|
||||
CONF_PANEL_DISPLAY, default=DEFAULT_PANEL_DISPLAY
|
||||
): cv.boolean,
|
||||
vol.Optional(CONF_AUTO_BYPASS, default=DEFAULT_AUTO_BYPASS): cv.boolean,
|
||||
vol.Optional(
|
||||
CONF_CODE_ARM_REQUIRED, default=DEFAULT_CODE_ARM_REQUIRED
|
||||
): cv.boolean,
|
||||
vol.Optional(CONF_ZONES): {vol.Coerce(int): ZONE_SCHEMA},
|
||||
}
|
||||
)
|
||||
@ -121,6 +126,7 @@ def setup(hass, config):
|
||||
device = conf[CONF_DEVICE]
|
||||
display = conf[CONF_PANEL_DISPLAY]
|
||||
auto_bypass = conf[CONF_AUTO_BYPASS]
|
||||
code_arm_required = conf[CONF_CODE_ARM_REQUIRED]
|
||||
zones = conf.get(CONF_ZONES)
|
||||
|
||||
device_type = device[CONF_DEVICE_TYPE]
|
||||
@ -206,7 +212,11 @@ def setup(hass, config):
|
||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, stop_alarmdecoder)
|
||||
|
||||
load_platform(
|
||||
hass, "alarm_control_panel", DOMAIN, {CONF_AUTO_BYPASS: auto_bypass}, config
|
||||
hass,
|
||||
"alarm_control_panel",
|
||||
DOMAIN,
|
||||
{CONF_AUTO_BYPASS: auto_bypass, CONF_CODE_ARM_REQUIRED: code_arm_required},
|
||||
config,
|
||||
)
|
||||
|
||||
if zones:
|
||||
|
@ -21,7 +21,13 @@ from homeassistant.const import (
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
from . import CONF_AUTO_BYPASS, DATA_AD, DOMAIN, SIGNAL_PANEL_MESSAGE
|
||||
from . import (
|
||||
CONF_AUTO_BYPASS,
|
||||
CONF_CODE_ARM_REQUIRED,
|
||||
DATA_AD,
|
||||
DOMAIN,
|
||||
SIGNAL_PANEL_MESSAGE,
|
||||
)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -39,7 +45,8 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
return
|
||||
|
||||
auto_bypass = discovery_info[CONF_AUTO_BYPASS]
|
||||
entity = AlarmDecoderAlarmPanel(auto_bypass)
|
||||
code_arm_required = discovery_info[CONF_CODE_ARM_REQUIRED]
|
||||
entity = AlarmDecoderAlarmPanel(auto_bypass, code_arm_required)
|
||||
add_entities([entity])
|
||||
|
||||
def alarm_toggle_chime_handler(service):
|
||||
@ -70,7 +77,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
class AlarmDecoderAlarmPanel(AlarmControlPanel):
|
||||
"""Representation of an AlarmDecoder-based alarm panel."""
|
||||
|
||||
def __init__(self, auto_bypass):
|
||||
def __init__(self, auto_bypass, code_arm_required):
|
||||
"""Initialize the alarm panel."""
|
||||
self._display = ""
|
||||
self._name = "Alarm Panel"
|
||||
@ -85,6 +92,7 @@ class AlarmDecoderAlarmPanel(AlarmControlPanel):
|
||||
self._ready = None
|
||||
self._zone_bypassed = None
|
||||
self._auto_bypass = auto_bypass
|
||||
self._code_arm_required = code_arm_required
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
"""Register callbacks."""
|
||||
@ -140,6 +148,11 @@ class AlarmDecoderAlarmPanel(AlarmControlPanel):
|
||||
"""Return the list of supported features."""
|
||||
return SUPPORT_ALARM_ARM_HOME | SUPPORT_ALARM_ARM_AWAY | SUPPORT_ALARM_ARM_NIGHT
|
||||
|
||||
@property
|
||||
def code_arm_required(self):
|
||||
"""Whether the code is required for arm actions."""
|
||||
return self._code_arm_required
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
@ -153,6 +166,7 @@ class AlarmDecoderAlarmPanel(AlarmControlPanel):
|
||||
"programming_mode": self._programming_mode,
|
||||
"ready": self._ready,
|
||||
"zone_bypassed": self._zone_bypassed,
|
||||
"code_arm_required": self._code_arm_required,
|
||||
}
|
||||
|
||||
def alarm_disarm(self, code=None):
|
||||
@ -166,6 +180,8 @@ class AlarmDecoderAlarmPanel(AlarmControlPanel):
|
||||
if self._auto_bypass:
|
||||
self.hass.data[DATA_AD].send(f"{code!s}6#")
|
||||
self.hass.data[DATA_AD].send(f"{code!s}2")
|
||||
elif not self._code_arm_required:
|
||||
self.hass.data[DATA_AD].send("#2")
|
||||
|
||||
def alarm_arm_home(self, code=None):
|
||||
"""Send arm home command."""
|
||||
@ -173,11 +189,15 @@ class AlarmDecoderAlarmPanel(AlarmControlPanel):
|
||||
if self._auto_bypass:
|
||||
self.hass.data[DATA_AD].send(f"{code!s}6#")
|
||||
self.hass.data[DATA_AD].send(f"{code!s}3")
|
||||
elif not self._code_arm_required:
|
||||
self.hass.data[DATA_AD].send("#3")
|
||||
|
||||
def alarm_arm_night(self, code=None):
|
||||
"""Send arm night command."""
|
||||
if code:
|
||||
self.hass.data[DATA_AD].send(f"{code!s}7")
|
||||
elif not self._code_arm_required:
|
||||
self.hass.data[DATA_AD].send("#7")
|
||||
|
||||
def alarm_toggle_chime(self, code=None):
|
||||
"""Send toggle chime command."""
|
||||
|
@ -1,10 +1,8 @@
|
||||
{
|
||||
"domain": "alarmdecoder",
|
||||
"name": "AlarmDecoder",
|
||||
"documentation": "https://www.home-assistant.io/integrations/alarmdecoder",
|
||||
"requirements": [
|
||||
"alarmdecoder==1.13.2"
|
||||
],
|
||||
"dependencies": [],
|
||||
"codeowners": []
|
||||
"domain": "alarmdecoder",
|
||||
"name": "AlarmDecoder",
|
||||
"documentation": "https://www.home-assistant.io/integrations/alarmdecoder",
|
||||
"requirements": ["alarmdecoder==1.13.2"],
|
||||
"dependencies": [],
|
||||
"codeowners": ["@ajschmidt8"]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user