Exemple #1
0
async def async_setup_platform(hass, config, async_add_entities,
                               discovery_info=None):
    """Set up the ElkM1 alarm platform."""
    if discovery_info is None:
        return

    elk = hass.data[ELK_DOMAIN]['elk']
    entities = create_elk_entities(hass, elk.areas, 'area', ElkArea, [])
    async_add_entities(entities, True)

    def _dispatch(signal, entity_ids, *args):
        for entity_id in entity_ids:
            async_dispatcher_send(
                hass, '{}_{}'.format(signal, entity_id), *args)

    def _arm_service(service):
        entity_ids = service.data.get(ATTR_ENTITY_ID, [])
        arm_level = _arm_services().get(service.service)
        args = (arm_level, service.data.get(ATTR_CODE))
        _dispatch(SIGNAL_ARM_ENTITY, entity_ids, *args)

    for service in _arm_services():
        hass.services.async_register(
            alarm.DOMAIN, service, _arm_service, ELK_ALARM_SERVICE_SCHEMA)

    def _display_message_service(service):
        entity_ids = service.data.get(ATTR_ENTITY_ID, [])
        data = service.data
        args = (data['clear'], data['beep'], data['timeout'],
                data['line1'], data['line2'])
        _dispatch(SIGNAL_DISPLAY_MESSAGE, entity_ids, *args)

    hass.services.async_register(
        alarm.DOMAIN, 'elkm1_alarm_display_message',
        _display_message_service, DISPLAY_MESSAGE_SERVICE_SCHEMA)
Exemple #2
0
async def async_setup_platform(hass, config, async_add_entities,
                               discovery_info=None):
    """Set up the ElkM1 alarm platform."""
    if discovery_info is None:
        return

    elk = hass.data[ELK_DOMAIN]['elk']
    entities = create_elk_entities(hass, elk.areas, 'area', ElkArea, [])
    async_add_entities(entities, True)

    def _dispatch(signal, entity_ids, *args):
        for entity_id in entity_ids:
            async_dispatcher_send(
                hass, '{}_{}'.format(signal, entity_id), *args)

    def _arm_service(service):
        entity_ids = service.data.get(ATTR_ENTITY_ID, [])
        arm_level = _arm_services().get(service.service)
        args = (arm_level, service.data.get(ATTR_CODE))
        _dispatch(SIGNAL_ARM_ENTITY, entity_ids, *args)

    for service in _arm_services():
        hass.services.async_register(
            alarm.DOMAIN, service, _arm_service, ELK_ALARM_SERVICE_SCHEMA)

    def _display_message_service(service):
        entity_ids = service.data.get(ATTR_ENTITY_ID, [])
        data = service.data
        args = (data['clear'], data['beep'], data['timeout'],
                data['line1'], data['line2'])
        _dispatch(SIGNAL_DISPLAY_MESSAGE, entity_ids, *args)

    hass.services.async_register(
        alarm.DOMAIN, 'elkm1_alarm_display_message',
        _display_message_service, DISPLAY_MESSAGE_SERVICE_SCHEMA)
Exemple #3
0
async def async_setup_platform(
        hass, config, async_add_entities, discovery_info=None):
    """Create the Elk-M1 scene platform."""
    if discovery_info is None:
        return
    elk = hass.data[ELK_DOMAIN]['elk']
    entities = create_elk_entities(hass, elk.tasks, 'task', ElkTask, [])
    async_add_entities(entities, True)
Exemple #4
0
async def async_setup_platform(
        hass, config, async_add_entities, discovery_info=None):
    """Set up the Elk light platform."""
    if discovery_info is None:
        return
    elk = hass.data[ELK_DOMAIN]['elk']
    async_add_entities(
        create_elk_entities(hass, elk.lights, 'plc', ElkLight, []), True)
Exemple #5
0
async def async_setup_platform(
        hass, config, async_add_entities, discovery_info=None):
    """Create the Elk-M1 switch platform."""
    if discovery_info is None:
        return
    elk = hass.data[ELK_DOMAIN]['elk']
    entities = create_elk_entities(hass, elk.outputs, 'output', ElkOutput, [])
    async_add_entities(entities, True)
Exemple #6
0
async def async_setup_platform(hass, config, async_add_entities,
                               discovery_info=None):
    """Create the Elk-M1 switch platform."""
    if discovery_info is None:
        return
    elk = hass.data[ELK_DOMAIN]['elk']
    entities = create_elk_entities(hass, elk.outputs, 'output', ElkOutput, [])
    async_add_entities(entities, True)
Exemple #7
0
async def async_setup_platform(
        hass, config, async_add_entities, discovery_info=None):
    """Create the Elk-M1 sensor platform."""
    if discovery_info is None:
        return

    elk = hass.data[ELK_DOMAIN]['elk']
    entities = create_elk_entities(
        hass, elk.counters, 'counter', ElkCounter, [])
    entities = create_elk_entities(
        hass, elk.keypads, 'keypad', ElkKeypad, entities)
    entities = create_elk_entities(
        hass, [elk.panel], 'panel', ElkPanel, entities)
    entities = create_elk_entities(
        hass, elk.settings, 'setting', ElkSetting, entities)
    entities = create_elk_entities(
        hass, elk.zones, 'zone', ElkZone, entities)
    async_add_entities(entities, True)
Exemple #8
0
async def async_setup_platform(hass, config, async_add_entities,
                               discovery_info=None):
    """Create the Elk-M1 thermostat platform."""
    if discovery_info is None:
        return

    elk = hass.data[ELK_DOMAIN]['elk']
    async_add_entities(create_elk_entities(
        hass, elk.thermostats, 'thermostat', ElkThermostat, []), True)
Exemple #9
0
async def async_setup_platform(hass,
                               config,
                               async_add_entities,
                               discovery_info=None):
    """Set up the Elk light platform."""
    if discovery_info is None:
        return
    elk = hass.data[ELK_DOMAIN]['elk']
    async_add_entities(
        create_elk_entities(hass, elk.lights, 'plc', ElkLight, []), True)