Exemple #1
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Perform the setup for Envisalink alarm panels."""
    _configured_partitions = discovery_info['partitions']
    _code = discovery_info[CONF_CODE]
    _panic_type = discovery_info[CONF_PANIC]
    for part_num in _configured_partitions:
        _device_config_data = PARTITION_SCHEMA(
            _configured_partitions[part_num])
        _device = EnvisalinkAlarm(
            part_num,
            _device_config_data[CONF_PARTITIONNAME],
            _code,
            _panic_type,
            EVL_CONTROLLER.alarm_state['partition'][part_num],
            EVL_CONTROLLER)
        DEVICES.append(_device)

    add_devices(DEVICES)

    # Register Envisalink specific services
    descriptions = load_yaml_config_file(
        path.join(path.dirname(__file__), 'services.yaml'))

    hass.services.register(alarm.DOMAIN, SERVICE_ALARM_KEYPRESS,
                           alarm_keypress_handler,
                           descriptions.get(SERVICE_ALARM_KEYPRESS),
                           schema=ALARM_KEYPRESS_SCHEMA)
    return True
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
    """Perform the setup for Envisalink sensor devices."""
    _configured_partitions = discovery_info['partitions']
    for part_num in _configured_partitions:
        _device_config_data = PARTITION_SCHEMA(
            _configured_partitions[part_num])
        _device = EnvisalinkSensor(
            _device_config_data[CONF_PARTITIONNAME], part_num,
            EVL_CONTROLLER.alarm_state['partition'][part_num], EVL_CONTROLLER)
        add_devices_callback([_device])
Exemple #3
0
def setup_platform(hass, config, add_devices_callback, discovery_info=None):
    """Perform the setup for Envisalink alarm panels."""
    _configured_partitions = discovery_info['partitions']
    _code = discovery_info[CONF_CODE]
    for part_num in _configured_partitions:
        _device_config_data = PARTITION_SCHEMA(
            _configured_partitions[part_num])
        _device = EnvisalinkAlarm(
            part_num, _device_config_data[CONF_PARTITIONNAME], _code,
            EVL_CONTROLLER.alarm_state['partition'][part_num], EVL_CONTROLLER)
        add_devices_callback([_device])

    return True
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
    """Perform the setup for Envisalink sensor devices."""
    configured_partitions = discovery_info['partitions']

    devices = []
    for part_num in configured_partitions:
        device_config_data = PARTITION_SCHEMA(configured_partitions[part_num])
        device = EnvisalinkSensor(
            hass, device_config_data[CONF_PARTITIONNAME], part_num,
            hass.data[DATA_EVL].alarm_state['partition'][part_num],
            hass.data[DATA_EVL])
        devices.append(device)

    yield from async_add_devices(devices)
Exemple #5
0
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
    """Perform the setup for Envisalink alarm panels."""
    configured_partitions = discovery_info['partitions']
    code = discovery_info[CONF_CODE]
    panic_type = discovery_info[CONF_PANIC]

    devices = []
    for part_num in configured_partitions:
        device_config_data = PARTITION_SCHEMA(configured_partitions[part_num])
        device = EnvisalinkAlarm(
            hass,
            part_num,
            device_config_data[CONF_PARTITIONNAME],
            code,
            panic_type,
            hass.data[DATA_EVL].alarm_state['partition'][part_num],
            hass.data[DATA_EVL]
        )
        devices.append(device)

    async_add_devices(devices)

    @callback
    def alarm_keypress_handler(service):
        """Map services to methods on Alarm."""
        entity_ids = service.data.get(ATTR_ENTITY_ID)
        keypress = service.data.get(ATTR_KEYPRESS)

        target_devices = [device for device in devices
                          if device.entity_id in entity_ids]

        for device in target_devices:
            device.async_alarm_keypress(keypress)

    # Register Envisalink specific services
    descriptions = yield from hass.loop.run_in_executor(
        None, load_yaml_config_file, os.path.join(
            os.path.dirname(__file__), 'services.yaml'))

    hass.services.async_register(
        alarm.DOMAIN, SERVICE_ALARM_KEYPRESS, alarm_keypress_handler,
        descriptions.get(SERVICE_ALARM_KEYPRESS), schema=ALARM_KEYPRESS_SCHEMA)

    return True
Exemple #6
0
async def async_setup_platform(hass,
                               config,
                               async_add_entities,
                               discovery_info=None):
    """Perform the setup for Envisalink alarm panels."""
    configured_partitions = discovery_info['partitions']
    code = discovery_info[CONF_CODE]
    panic_type = discovery_info[CONF_PANIC]

    devices = []
    for part_num in configured_partitions:
        device_config_data = PARTITION_SCHEMA(configured_partitions[part_num])
        device = EnvisalinkAlarm(
            hass, part_num, device_config_data[CONF_PARTITIONNAME], code,
            panic_type, hass.data[DATA_EVL].alarm_state['partition'][part_num],
            hass.data[DATA_EVL])
        devices.append(device)

    async_add_entities(devices)

    @callback
    def alarm_keypress_handler(service):
        """Map services to methods on Alarm."""
        entity_ids = service.data.get(ATTR_ENTITY_ID)
        keypress = service.data.get(ATTR_KEYPRESS)

        target_devices = [
            device for device in devices if device.entity_id in entity_ids
        ]

        for device in target_devices:
            device.async_alarm_keypress(keypress)

    hass.services.async_register(alarm.DOMAIN,
                                 SERVICE_ALARM_KEYPRESS,
                                 alarm_keypress_handler,
                                 schema=ALARM_KEYPRESS_SCHEMA)

    return True