Merge pull request #905 from Xorso/alarmdotcom_bugfix

Alarmdotcom bugfix
This commit is contained in:
Paulus Schoutsen 2016-01-16 08:48:07 -08:00
commit 7de91a270a

View File

@ -52,6 +52,8 @@ class AlarmDotCom(alarm.AlarmControlPanel):
self._hass = hass self._hass = hass
self._name = name self._name = name
self._code = str(code) if code else None self._code = str(code) if code else None
self._username = username
self._password = password
@property @property
def should_poll(self): def should_poll(self):
@ -82,21 +84,30 @@ class AlarmDotCom(alarm.AlarmControlPanel):
""" Send disarm command. """ """ Send disarm command. """
if not self._validate_code(code, 'arming home'): if not self._validate_code(code, 'arming home'):
return return
self._alarm.disarm() from pyalarmdotcom.pyalarmdotcom import Alarmdotcom
# Open another session to alarm.com to fire off the command
_alarm = Alarmdotcom(self._username, self._password, timeout=10)
_alarm.disarm()
self.update_ha_state() self.update_ha_state()
def alarm_arm_home(self, code=None): def alarm_arm_home(self, code=None):
""" Send arm home command. """ """ Send arm home command. """
if not self._validate_code(code, 'arming home'): if not self._validate_code(code, 'arming home'):
return return
self._alarm.arm_stay() from pyalarmdotcom.pyalarmdotcom import Alarmdotcom
# Open another session to alarm.com to fire off the command
_alarm = Alarmdotcom(self._username, self._password, timeout=10)
_alarm.arm_stay()
self.update_ha_state() self.update_ha_state()
def alarm_arm_away(self, code=None): def alarm_arm_away(self, code=None):
""" Send arm away command. """ """ Send arm away command. """
if not self._validate_code(code, 'arming home'): if not self._validate_code(code, 'arming home'):
return return
self._alarm.arm_away() from pyalarmdotcom.pyalarmdotcom import Alarmdotcom
# Open another session to alarm.com to fire off the command
_alarm = Alarmdotcom(self._username, self._password, timeout=10)
_alarm.arm_away()
self.update_ha_state() self.update_ha_state()
def _validate_code(self, code, state): def _validate_code(self, code, state):