Skip to content

Commit

Permalink
Add alarmdecoder brand specific arming sequences (#36692)
Browse files Browse the repository at this point in the history
* add adext

* rm new config parameter

* update adext
  • Loading branch information
ajschmidt8 authored Jun 15, 2020
1 parent b15caf3 commit 9a867cb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 deletions.
8 changes: 4 additions & 4 deletions homeassistant/components/alarmdecoder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from datetime import timedelta
import logging

from alarmdecoder import AlarmDecoder
from adext import AdExt
from alarmdecoder.devices import SerialDevice, SocketDevice, USBDevice
from alarmdecoder.util import NoDeviceError
import voluptuous as vol
Expand Down Expand Up @@ -189,13 +189,13 @@ def handle_rel_message(sender, message):
if device_type == "socket":
host = device[CONF_HOST]
port = device[CONF_DEVICE_PORT]
controller = AlarmDecoder(SocketDevice(interface=(host, port)))
controller = AdExt(SocketDevice(interface=(host, port)))
elif device_type == "serial":
path = device[CONF_DEVICE_PATH]
baud = device[CONF_DEVICE_BAUD]
controller = AlarmDecoder(SerialDevice(interface=path))
controller = AdExt(SerialDevice(interface=path))
elif device_type == "usb":
AlarmDecoder(USBDevice.find())
AdExt(USBDevice.find())
return False

controller.on_message += handle_message
Expand Down
31 changes: 15 additions & 16 deletions homeassistant/components/alarmdecoder/alarm_control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,28 +178,27 @@ def alarm_disarm(self, code=None):

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")
elif not self._code_arm_required:
self.hass.data[DATA_AD].send("#2")
self.hass.data[DATA_AD].arm_away(
code=code,
code_arm_required=self._code_arm_required,
auto_bypass=self._auto_bypass,
)

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")
elif not self._code_arm_required:
self.hass.data[DATA_AD].send("#3")
self.hass.data[DATA_AD].arm_home(
code=code,
code_arm_required=self._code_arm_required,
auto_bypass=self._auto_bypass,
)

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")
self.hass.data[DATA_AD].arm_night(
code=code,
code_arm_required=self._code_arm_required,
auto_bypass=self._auto_bypass,
)

def alarm_toggle_chime(self, code=None):
"""Send toggle chime command."""
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/alarmdecoder/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"domain": "alarmdecoder",
"name": "AlarmDecoder",
"documentation": "https://www.home-assistant.io/integrations/alarmdecoder",
"requirements": ["alarmdecoder==1.13.2"],
"requirements": ["adext==0.3"],
"codeowners": ["@ajschmidt8"]
}
6 changes: 3 additions & 3 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ adafruit-circuitpython-mcp230xx==2.2.2
# homeassistant.components.androidtv
adb-shell==0.1.3

# homeassistant.components.alarmdecoder
adext==0.3

# homeassistant.components.adguard
adguardhome==0.4.2

Expand Down Expand Up @@ -235,9 +238,6 @@ airly==0.0.2
# homeassistant.components.aladdin_connect
aladdin_connect==0.3

# homeassistant.components.alarmdecoder
alarmdecoder==1.13.2

# homeassistant.components.alpha_vantage
alpha_vantage==2.2.0

Expand Down

0 comments on commit 9a867cb

Please sign in to comment.