add a requires_code property on alarm object
This commit is contained in:
parent
fc946da5db
commit
35eed93443
3 changed files with 26 additions and 9 deletions
|
@ -93,16 +93,23 @@ def alarm_arm_away(hass, code, entity_id=None):
|
||||||
hass.services.call(DOMAIN, SERVICE_ALARM_ARM_AWAY, data)
|
hass.services.call(DOMAIN, SERVICE_ALARM_ARM_AWAY, data)
|
||||||
|
|
||||||
|
|
||||||
|
# pylint: disable=no-self-use
|
||||||
class AlarmControlPanel(Entity):
|
class AlarmControlPanel(Entity):
|
||||||
""" ABC for alarm control devices. """
|
""" 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. """
|
""" Send disarm command. """
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def alarm_arm_home(self, code):
|
def alarm_arm_home(self, code=None):
|
||||||
""" Send arm home command. """
|
""" Send arm home command. """
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def alarm_arm_away(self, code):
|
def alarm_arm_away(self, code=None):
|
||||||
""" Send arm away command. """
|
""" Send arm away command. """
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
|
@ -131,17 +131,22 @@ class MqttAlarm(alarm.AlarmControlPanel):
|
||||||
""" Returns the state of the device. """
|
""" Returns the state of the device. """
|
||||||
return self._state
|
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. """
|
""" Send disarm command. """
|
||||||
mqtt.publish(self.hass, self._command_topic, self._payload_disarm,
|
mqtt.publish(self.hass, self._command_topic, self._payload_disarm,
|
||||||
self._qos)
|
self._qos)
|
||||||
|
|
||||||
def alarm_arm_home(self, code):
|
def alarm_arm_home(self, code=None):
|
||||||
""" Send arm home command. """
|
""" Send arm home command. """
|
||||||
mqtt.publish(self.hass, self._command_topic, self._payload_arm_home,
|
mqtt.publish(self.hass, self._command_topic, self._payload_arm_home,
|
||||||
self._qos)
|
self._qos)
|
||||||
|
|
||||||
def alarm_arm_away(self, code):
|
def alarm_arm_away(self, code=None):
|
||||||
""" Send arm away command. """
|
""" Send arm away command. """
|
||||||
mqtt.publish(self.hass, self._command_topic, self._payload_arm_away,
|
mqtt.publish(self.hass, self._command_topic, self._payload_arm_away,
|
||||||
self._qos)
|
self._qos)
|
||||||
|
|
|
@ -51,6 +51,11 @@ class VerisureAlarm(alarm.AlarmControlPanel):
|
||||||
""" Returns the state of the device. """
|
""" Returns the state of the device. """
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
|
@property
|
||||||
|
def requires_code(self):
|
||||||
|
""" code is required """
|
||||||
|
return True
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
''' update alarm status '''
|
''' update alarm status '''
|
||||||
verisure.update()
|
verisure.update()
|
||||||
|
@ -66,21 +71,21 @@ class VerisureAlarm(alarm.AlarmControlPanel):
|
||||||
'Unknown alarm state %s',
|
'Unknown alarm state %s',
|
||||||
verisure.STATUS[self._device][self._id].status)
|
verisure.STATUS[self._device][self._id].status)
|
||||||
|
|
||||||
def alarm_disarm(self, code):
|
def alarm_disarm(self, code=None):
|
||||||
""" Send disarm command. """
|
""" Send disarm command. """
|
||||||
verisure.MY_PAGES.set_alarm_status(
|
verisure.MY_PAGES.set_alarm_status(
|
||||||
code,
|
code,
|
||||||
verisure.MY_PAGES.ALARM_DISARMED)
|
verisure.MY_PAGES.ALARM_DISARMED)
|
||||||
_LOGGER.warning('disarming')
|
_LOGGER.warning('disarming')
|
||||||
|
|
||||||
def alarm_arm_home(self, code):
|
def alarm_arm_home(self, code=None):
|
||||||
""" Send arm home command. """
|
""" Send arm home command. """
|
||||||
verisure.MY_PAGES.set_alarm_status(
|
verisure.MY_PAGES.set_alarm_status(
|
||||||
code,
|
code,
|
||||||
verisure.MY_PAGES.ALARM_ARMED_HOME)
|
verisure.MY_PAGES.ALARM_ARMED_HOME)
|
||||||
_LOGGER.warning('arming home')
|
_LOGGER.warning('arming home')
|
||||||
|
|
||||||
def alarm_arm_away(self, code):
|
def alarm_arm_away(self, code=None):
|
||||||
""" Send arm away command. """
|
""" Send arm away command. """
|
||||||
verisure.MY_PAGES.set_alarm_status(
|
verisure.MY_PAGES.set_alarm_status(
|
||||||
code,
|
code,
|
||||||
|
|
Loading…
Add table
Reference in a new issue