From 35eed93443ed59085995b7dd811f9af09076b3b6 Mon Sep 17 00:00:00 2001 From: sfam Date: Sat, 19 Sep 2015 17:32:37 +0000 Subject: [PATCH] add a requires_code property on alarm object --- .../components/alarm_control_panel/__init__.py | 13 ++++++++++--- .../components/alarm_control_panel/mqtt.py | 11 ++++++++--- .../components/alarm_control_panel/verisure.py | 11 ++++++++--- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/alarm_control_panel/__init__.py b/homeassistant/components/alarm_control_panel/__init__.py index bf68e35ffe3..a74f268b632 100644 --- a/homeassistant/components/alarm_control_panel/__init__.py +++ b/homeassistant/components/alarm_control_panel/__init__.py @@ -93,16 +93,23 @@ def alarm_arm_away(hass, code, entity_id=None): hass.services.call(DOMAIN, SERVICE_ALARM_ARM_AWAY, data) +# pylint: disable=no-self-use class AlarmControlPanel(Entity): """ ABC for alarm control devices. """ - def alarm_disarm(self, code): + + @property + def requires_code(self): + """ Boolean if alarm requires a code """ + return None + + def alarm_disarm(self, code=None): """ Send disarm command. """ raise NotImplementedError() - def alarm_arm_home(self, code): + def alarm_arm_home(self, code=None): """ Send arm home command. """ raise NotImplementedError() - def alarm_arm_away(self, code): + def alarm_arm_away(self, code=None): """ Send arm away command. """ raise NotImplementedError() diff --git a/homeassistant/components/alarm_control_panel/mqtt.py b/homeassistant/components/alarm_control_panel/mqtt.py index 3317687f2fd..d35d00d3ecd 100644 --- a/homeassistant/components/alarm_control_panel/mqtt.py +++ b/homeassistant/components/alarm_control_panel/mqtt.py @@ -131,17 +131,22 @@ class MqttAlarm(alarm.AlarmControlPanel): """ Returns the state of the device. """ return self._state - def alarm_disarm(self, code): + @property + def requires_code(self): + """ code is not required """ + return False + + def alarm_disarm(self, code=None): """ Send disarm command. """ mqtt.publish(self.hass, self._command_topic, self._payload_disarm, self._qos) - def alarm_arm_home(self, code): + def alarm_arm_home(self, code=None): """ Send arm home command. """ mqtt.publish(self.hass, self._command_topic, self._payload_arm_home, self._qos) - def alarm_arm_away(self, code): + def alarm_arm_away(self, code=None): """ Send arm away command. """ mqtt.publish(self.hass, self._command_topic, self._payload_arm_away, self._qos) diff --git a/homeassistant/components/alarm_control_panel/verisure.py b/homeassistant/components/alarm_control_panel/verisure.py index f19cdc102d2..9889223a0aa 100644 --- a/homeassistant/components/alarm_control_panel/verisure.py +++ b/homeassistant/components/alarm_control_panel/verisure.py @@ -51,6 +51,11 @@ class VerisureAlarm(alarm.AlarmControlPanel): """ Returns the state of the device. """ return self._state + @property + def requires_code(self): + """ code is required """ + return True + def update(self): ''' update alarm status ''' verisure.update() @@ -66,21 +71,21 @@ class VerisureAlarm(alarm.AlarmControlPanel): 'Unknown alarm state %s', verisure.STATUS[self._device][self._id].status) - def alarm_disarm(self, code): + def alarm_disarm(self, code=None): """ Send disarm command. """ verisure.MY_PAGES.set_alarm_status( code, verisure.MY_PAGES.ALARM_DISARMED) _LOGGER.warning('disarming') - def alarm_arm_home(self, code): + def alarm_arm_home(self, code=None): """ Send arm home command. """ verisure.MY_PAGES.set_alarm_status( code, verisure.MY_PAGES.ALARM_ARMED_HOME) _LOGGER.warning('arming home') - def alarm_arm_away(self, code): + def alarm_arm_away(self, code=None): """ Send arm away command. """ verisure.MY_PAGES.set_alarm_status( code,