add a requires_code property on alarm object

This commit is contained in:
sfam 2015-09-19 17:32:37 +00:00
parent fc946da5db
commit 35eed93443
3 changed files with 26 additions and 9 deletions

View file

@ -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()

View file

@ -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)

View file

@ -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,