mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use builtin constants for Abode alarm_control_panel (#9059)
* Use builtin constants for alarm_control_panel * Made it consistent with other alarm panels * Replaced STATE_UNKNOWN with None
This commit is contained in:
parent
4bb78097a7
commit
bc549e9525
@ -7,16 +7,14 @@ https://home-assistant.io/components/alarm_control_panel.abode/
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.abode import (DATA_ABODE, DEFAULT_NAME)
|
from homeassistant.components.abode import (DATA_ABODE, DEFAULT_NAME)
|
||||||
from homeassistant.const import (STATE_UNKNOWN)
|
from homeassistant.const import (STATE_ALARM_ARMED_AWAY,
|
||||||
|
STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED)
|
||||||
import homeassistant.components.alarm_control_panel as alarm
|
import homeassistant.components.alarm_control_panel as alarm
|
||||||
|
|
||||||
DEPENDENCIES = ['abode']
|
DEPENDENCIES = ['abode']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
ALARM_STATE_HOME = 'home'
|
|
||||||
ALARM_STATE_STANDBY = 'standby'
|
|
||||||
ALARM_STATE_AWAY = 'away'
|
|
||||||
ICON = 'mdi:security'
|
ICON = 'mdi:security'
|
||||||
|
|
||||||
|
|
||||||
@ -54,26 +52,29 @@ class AbodeAlarm(alarm.AlarmControlPanel):
|
|||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
"""Return the state of the device."""
|
"""Return the state of the device."""
|
||||||
status = self._device.mode
|
if self._device.mode == "standby":
|
||||||
|
state = STATE_ALARM_DISARMED
|
||||||
if status in [ALARM_STATE_STANDBY, ALARM_STATE_HOME, ALARM_STATE_AWAY]:
|
elif self._device.mode == "away":
|
||||||
return status
|
state = STATE_ALARM_ARMED_AWAY
|
||||||
|
elif self._device.mode == "home":
|
||||||
return STATE_UNKNOWN
|
state = STATE_ALARM_ARMED_HOME
|
||||||
|
else:
|
||||||
|
state = None
|
||||||
|
return state
|
||||||
|
|
||||||
def alarm_disarm(self, code=None):
|
def alarm_disarm(self, code=None):
|
||||||
"""Send disarm command."""
|
"""Send disarm command."""
|
||||||
self._device.set_mode(mode=ALARM_STATE_STANDBY)
|
self._device.set_standby()
|
||||||
self.schedule_update_ha_state()
|
self.schedule_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."""
|
||||||
self._device.set_mode(mode=ALARM_STATE_HOME)
|
self._device.set_home()
|
||||||
self.schedule_update_ha_state()
|
self.schedule_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."""
|
||||||
self._device.set_mode(mode=ALARM_STATE_AWAY)
|
self._device.set_away()
|
||||||
self.schedule_update_ha_state()
|
self.schedule_update_ha_state()
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user