mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Moving updates out of state property (#3966)
This commit is contained in:
parent
c70722dbae
commit
0c0b02eb3d
@ -60,6 +60,7 @@ class NX584Alarm(alarm.AlarmControlPanel):
|
|||||||
# talk to the API and trigger a requests exception for setup_platform()
|
# talk to the API and trigger a requests exception for setup_platform()
|
||||||
# to catch
|
# to catch
|
||||||
self._alarm.list_zones()
|
self._alarm.list_zones()
|
||||||
|
self._state = STATE_UNKNOWN
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
@ -79,16 +80,20 @@ class NX584Alarm(alarm.AlarmControlPanel):
|
|||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
"""Return the state of the device."""
|
"""Return the state of the device."""
|
||||||
|
return self._state
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
"""Process new events from panel."""
|
||||||
try:
|
try:
|
||||||
part = self._alarm.list_partitions()[0]
|
part = self._alarm.list_partitions()[0]
|
||||||
zones = self._alarm.list_zones()
|
zones = self._alarm.list_zones()
|
||||||
except requests.exceptions.ConnectionError as ex:
|
except requests.exceptions.ConnectionError as ex:
|
||||||
_LOGGER.error('Unable to connect to %(host)s: %(reason)s',
|
_LOGGER.error('Unable to connect to %(host)s: %(reason)s',
|
||||||
dict(host=self._url, reason=ex))
|
dict(host=self._url, reason=ex))
|
||||||
return STATE_UNKNOWN
|
self._state = STATE_UNKNOWN
|
||||||
except IndexError:
|
except IndexError:
|
||||||
_LOGGER.error('nx584 reports no partitions')
|
_LOGGER.error('nx584 reports no partitions')
|
||||||
return STATE_UNKNOWN
|
self._state = STATE_UNKNOWN
|
||||||
|
|
||||||
bypassed = False
|
bypassed = False
|
||||||
for zone in zones:
|
for zone in zones:
|
||||||
@ -100,11 +105,11 @@ class NX584Alarm(alarm.AlarmControlPanel):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if not part['armed']:
|
if not part['armed']:
|
||||||
return STATE_ALARM_DISARMED
|
self._state = STATE_ALARM_DISARMED
|
||||||
elif bypassed:
|
elif bypassed:
|
||||||
return STATE_ALARM_ARMED_HOME
|
self._state = STATE_ALARM_ARMED_HOME
|
||||||
else:
|
else:
|
||||||
return STATE_ALARM_ARMED_AWAY
|
self._state = STATE_ALARM_ARMED_AWAY
|
||||||
|
|
||||||
def alarm_disarm(self, code=None):
|
def alarm_disarm(self, code=None):
|
||||||
"""Send disarm command."""
|
"""Send disarm command."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user