Satel integra monitor outputs (#19149)

* Adjusted api for new library version.

* Added support for output monitoring. Added initial status check for the alarm.

* Added default values to the configuration as per review notes.
This commit is contained in:
c-soft 2018-12-18 00:28:41 +01:00 committed by Charles Garwood
parent f1005d37a7
commit 6c8ed86f3e
3 changed files with 44 additions and 17 deletions

View file

@ -8,9 +8,11 @@ import logging
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.satel_integra import (CONF_ZONES,
CONF_OUTPUTS,
CONF_ZONE_NAME,
CONF_ZONE_TYPE,
SIGNAL_ZONES_UPDATED)
SIGNAL_ZONES_UPDATED,
SIGNAL_OUTPUTS_UPDATED)
from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -32,7 +34,17 @@ async def async_setup_platform(hass, config, async_add_entities,
for zone_num, device_config_data in configured_zones.items():
zone_type = device_config_data[CONF_ZONE_TYPE]
zone_name = device_config_data[CONF_ZONE_NAME]
device = SatelIntegraBinarySensor(zone_num, zone_name, zone_type)
device = SatelIntegraBinarySensor(zone_num, zone_name, zone_type,
SIGNAL_ZONES_UPDATED)
devices.append(device)
configured_outputs = discovery_info[CONF_OUTPUTS]
for zone_num, device_config_data in configured_outputs.items():
zone_type = device_config_data[CONF_ZONE_TYPE]
zone_name = device_config_data[CONF_ZONE_NAME]
device = SatelIntegraBinarySensor(zone_num, zone_name, zone_type,
SIGNAL_OUTPUTS_UPDATED)
devices.append(device)
async_add_entities(devices)
@ -41,17 +53,18 @@ async def async_setup_platform(hass, config, async_add_entities,
class SatelIntegraBinarySensor(BinarySensorDevice):
"""Representation of an Satel Integra binary sensor."""
def __init__(self, zone_number, zone_name, zone_type):
def __init__(self, device_number, device_name, zone_type, react_to_signal):
"""Initialize the binary_sensor."""
self._zone_number = zone_number
self._name = zone_name
self._device_number = device_number
self._name = device_name
self._zone_type = zone_type
self._state = 0
self._react_to_signal = react_to_signal
async def async_added_to_hass(self):
"""Register callbacks."""
async_dispatcher_connect(
self.hass, SIGNAL_ZONES_UPDATED, self._zones_updated)
self.hass, self._react_to_signal, self._devices_updated)
@property
def name(self):
@ -80,9 +93,9 @@ class SatelIntegraBinarySensor(BinarySensorDevice):
return self._zone_type
@callback
def _zones_updated(self, zones):
def _devices_updated(self, zones):
"""Update the zone's state, if needed."""
if self._zone_number in zones \
and self._state != zones[self._zone_number]:
self._state = zones[self._zone_number]
if self._device_number in zones \
and self._state != zones[self._device_number]:
self._state = zones[self._device_number]
self.async_schedule_update_ha_state()