mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Added support for triggered state on NX584 alarm. (#19524)
* Added support for triggered state on NX584 alarm. * Minor update
This commit is contained in:
parent
b80bed64f5
commit
4d62e77049
@ -13,7 +13,7 @@ import homeassistant.components.alarm_control_panel as alarm
|
|||||||
from homeassistant.components.alarm_control_panel import PLATFORM_SCHEMA
|
from homeassistant.components.alarm_control_panel import PLATFORM_SCHEMA
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST, CONF_NAME, CONF_PORT, STATE_ALARM_ARMED_AWAY,
|
CONF_HOST, CONF_NAME, CONF_PORT, STATE_ALARM_ARMED_AWAY,
|
||||||
STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED, STATE_UNKNOWN)
|
STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED, STATE_ALARM_TRIGGERED)
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
REQUIREMENTS = ['pynx584==0.4']
|
REQUIREMENTS = ['pynx584==0.4']
|
||||||
@ -43,7 +43,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
add_entities([NX584Alarm(hass, url, name)])
|
add_entities([NX584Alarm(hass, url, name)])
|
||||||
except requests.exceptions.ConnectionError as ex:
|
except requests.exceptions.ConnectionError as ex:
|
||||||
_LOGGER.error("Unable to connect to NX584: %s", str(ex))
|
_LOGGER.error("Unable to connect to NX584: %s", str(ex))
|
||||||
return False
|
return
|
||||||
|
|
||||||
|
|
||||||
class NX584Alarm(alarm.AlarmControlPanel):
|
class NX584Alarm(alarm.AlarmControlPanel):
|
||||||
@ -60,7 +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
|
self._state = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -85,11 +85,11 @@ class NX584Alarm(alarm.AlarmControlPanel):
|
|||||||
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))
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
zones = []
|
zones = []
|
||||||
except IndexError:
|
except IndexError:
|
||||||
_LOGGER.error("NX584 reports no partitions")
|
_LOGGER.error("NX584 reports no partitions")
|
||||||
self._state = STATE_UNKNOWN
|
self._state = None
|
||||||
zones = []
|
zones = []
|
||||||
|
|
||||||
bypassed = False
|
bypassed = False
|
||||||
@ -107,6 +107,10 @@ class NX584Alarm(alarm.AlarmControlPanel):
|
|||||||
else:
|
else:
|
||||||
self._state = STATE_ALARM_ARMED_AWAY
|
self._state = STATE_ALARM_ARMED_AWAY
|
||||||
|
|
||||||
|
for flag in part['condition_flags']:
|
||||||
|
if flag == "Siren on":
|
||||||
|
self._state = STATE_ALARM_TRIGGERED
|
||||||
|
|
||||||
def alarm_disarm(self, code=None):
|
def alarm_disarm(self, code=None):
|
||||||
"""Send disarm command."""
|
"""Send disarm command."""
|
||||||
self._alarm.disarm(code)
|
self._alarm.disarm(code)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user