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:
parent
f1005d37a7
commit
6c8ed86f3e
3 changed files with 44 additions and 17 deletions
|
@ -19,7 +19,7 @@ from homeassistant.helpers import config_validation as cv
|
|||
from homeassistant.helpers.discovery import async_load_platform
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
|
||||
REQUIREMENTS = ['satel_integra==0.1.0']
|
||||
REQUIREMENTS = ['satel_integra==0.2.0']
|
||||
|
||||
DEFAULT_ALARM_NAME = 'satel_integra'
|
||||
DEFAULT_PORT = 7094
|
||||
|
@ -40,6 +40,7 @@ CONF_ARM_HOME_MODE = 'arm_home_mode'
|
|||
CONF_ZONE_NAME = 'name'
|
||||
CONF_ZONE_TYPE = 'type'
|
||||
CONF_ZONES = 'zones'
|
||||
CONF_OUTPUTS = 'outputs'
|
||||
|
||||
ZONES = 'zones'
|
||||
|
||||
|
@ -49,6 +50,7 @@ SIGNAL_PANEL_ARM_HOME = 'satel_integra.panel_arm_home'
|
|||
SIGNAL_PANEL_DISARM = 'satel_integra.panel_disarm'
|
||||
|
||||
SIGNAL_ZONES_UPDATED = 'satel_integra.zones_updated'
|
||||
SIGNAL_OUTPUTS_UPDATED = 'satel_integra.outputs_updated'
|
||||
|
||||
ZONE_SCHEMA = vol.Schema({
|
||||
vol.Required(CONF_ZONE_NAME): cv.string,
|
||||
|
@ -62,7 +64,10 @@ CONFIG_SCHEMA = vol.Schema({
|
|||
default=DEFAULT_DEVICE_PARTITION): cv.positive_int,
|
||||
vol.Optional(CONF_ARM_HOME_MODE,
|
||||
default=DEFAULT_CONF_ARM_HOME_MODE): vol.In([1, 2, 3]),
|
||||
vol.Optional(CONF_ZONES): {vol.Coerce(int): ZONE_SCHEMA},
|
||||
vol.Optional(CONF_ZONES,
|
||||
default={}): {vol.Coerce(int): ZONE_SCHEMA},
|
||||
vol.Optional(CONF_OUTPUTS,
|
||||
default={}): {vol.Coerce(int): ZONE_SCHEMA},
|
||||
}),
|
||||
}, extra=vol.ALLOW_EXTRA)
|
||||
|
||||
|
@ -72,13 +77,14 @@ async def async_setup(hass, config):
|
|||
conf = config.get(DOMAIN)
|
||||
|
||||
zones = conf.get(CONF_ZONES)
|
||||
outputs = conf.get(CONF_OUTPUTS)
|
||||
host = conf.get(CONF_DEVICE_HOST)
|
||||
port = conf.get(CONF_DEVICE_PORT)
|
||||
partition = conf.get(CONF_DEVICE_PARTITION)
|
||||
|
||||
from satel_integra.satel_integra import AsyncSatel, AlarmState
|
||||
|
||||
controller = AsyncSatel(host, port, zones, hass.loop, partition)
|
||||
controller = AsyncSatel(host, port, hass.loop, zones, outputs, partition)
|
||||
|
||||
hass.data[DATA_SATEL] = controller
|
||||
|
||||
|
@ -101,7 +107,8 @@ async def async_setup(hass, config):
|
|||
|
||||
task_zones = hass.async_create_task(
|
||||
async_load_platform(hass, 'binary_sensor', DOMAIN,
|
||||
{CONF_ZONES: zones}, config))
|
||||
{CONF_ZONES: zones, CONF_OUTPUTS: outputs}, config)
|
||||
)
|
||||
|
||||
await asyncio.wait([task_control_panel, task_zones], loop=hass.loop)
|
||||
|
||||
|
@ -134,16 +141,23 @@ async def async_setup(hass, config):
|
|||
@callback
|
||||
def zones_update_callback(status):
|
||||
"""Update zone objects as per notification from the alarm."""
|
||||
_LOGGER.debug("Zones callback , status: %s", status)
|
||||
_LOGGER.debug("Zones callback, status: %s", status)
|
||||
async_dispatcher_send(hass, SIGNAL_ZONES_UPDATED, status[ZONES])
|
||||
|
||||
@callback
|
||||
def outputs_update_callback(status):
|
||||
"""Update zone objects as per notification from the alarm."""
|
||||
_LOGGER.debug("Outputs updated callback , status: %s", status)
|
||||
async_dispatcher_send(hass, SIGNAL_OUTPUTS_UPDATED, status["outputs"])
|
||||
|
||||
# Create a task instead of adding a tracking job, since this task will
|
||||
# run until the connection to satel_integra is closed.
|
||||
hass.loop.create_task(controller.keep_alive())
|
||||
hass.loop.create_task(
|
||||
controller.monitor_status(
|
||||
alarm_status_update_callback,
|
||||
zones_update_callback)
|
||||
zones_update_callback,
|
||||
outputs_update_callback)
|
||||
)
|
||||
|
||||
return True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue