コード例 #1
0
ファイル: axis.py プロジェクト: adolfoeliazat/voidhomecontrol
def setup_device(hass, config):
    """Set up device."""
    from axis import AxisDevice

    config['hass'] = hass
    device = AxisDevice(config)  # Initialize device
    enable_metadatastream = False

    if device.serial_number is None:
        # If there is no serial number a connection could not be made
        _LOGGER.error("Couldn\'t connect to %s", config[CONF_HOST])
        return False

    for component in config[CONF_INCLUDE]:
        if component in EVENT_TYPES:
            # Sensors are created by device calling event_initialized
            # when receiving initialize messages on metadatastream
            device.add_event_topic(convert(component, 'type', 'subscribe'))
            if not enable_metadatastream:
                enable_metadatastream = True
        else:
            discovery.load_platform(hass, component, DOMAIN, config)

    if enable_metadatastream:
        device.initialize_new_event = event_initialized
        device.initiate_metadatastream()
    AXIS_DEVICES[device.serial_number] = device
    return True
コード例 #2
0
ファイル: axis.py プロジェクト: ozzpy/home-assistant
def setup_device(hass, config):
    """Set up device."""
    from axis import AxisDevice

    config['hass'] = hass
    device = AxisDevice(config)  # Initialize device
    enable_metadatastream = False

    if device.serial_number is None:
        # If there is no serial number a connection could not be made
        _LOGGER.error("Couldn\'t connect to %s", config[CONF_HOST])
        return False

    for component in config[CONF_INCLUDE]:
        if component in EVENT_TYPES:
            # Sensors are created by device calling event_initialized
            # when receiving initialize messages on metadatastream
            device.add_event_topic(convert(component, 'type', 'subscribe'))
            if not enable_metadatastream:
                enable_metadatastream = True
        else:
            discovery.load_platform(hass, component, DOMAIN, config)

    if enable_metadatastream:
        device.initialize_new_event = event_initialized
        device.initiate_metadatastream()
    AXIS_DEVICES[device.serial_number] = device
    return True
コード例 #3
0
ファイル: axis.py プロジェクト: Landrash/home-assistant
def setup_device(hass, config, device_config):
    """Set up device."""
    from axis import AxisDevice

    device_config['hass'] = hass
    device = AxisDevice(device_config)  # Initialize device
    enable_metadatastream = False

    if device.serial_number is None:
        # If there is no serial number a connection could not be made
        _LOGGER.error("Couldn\'t connect to %s", device_config[CONF_HOST])
        return False

    for component in device_config[CONF_INCLUDE]:
        if component in EVENT_TYPES:
            # Sensors are created by device calling event_initialized
            # when receiving initialize messages on metadatastream
            device.add_event_topic(convert(component, 'type', 'subscribe'))
            if not enable_metadatastream:
                enable_metadatastream = True
        else:
            camera_config = {
                CONF_HOST: device_config[CONF_HOST],
                CONF_NAME: device_config[CONF_NAME],
                CONF_PORT: device_config[CONF_PORT],
                CONF_USERNAME: device_config[CONF_USERNAME],
                CONF_PASSWORD: device_config[CONF_PASSWORD]
            }
            discovery.load_platform(hass,
                                    component,
                                    DOMAIN,
                                    camera_config,
                                    config)

    if enable_metadatastream:
        device.initialize_new_event = event_initialized
        if not device.initiate_metadatastream():
            hass.components.persistent_notification.create(
                'Dependency missing for sensors, '
                'please check documentation',
                title=DOMAIN,
                notification_id='axis_notification')

    AXIS_DEVICES[device.serial_number] = device

    return True
コード例 #4
0
def setup_device(hass, config, device_config):
    """Set up device."""
    from axis import AxisDevice

    device_config['hass'] = hass
    device = AxisDevice(device_config)  # Initialize device
    enable_metadatastream = False

    if device.serial_number is None:
        # If there is no serial number a connection could not be made
        _LOGGER.error("Couldn\'t connect to %s", device_config[CONF_HOST])
        return False

    for component in device_config[CONF_INCLUDE]:
        if component in EVENT_TYPES:
            # Sensors are created by device calling event_initialized
            # when receiving initialize messages on metadatastream
            device.add_event_topic(convert(component, 'type', 'subscribe'))
            if not enable_metadatastream:
                enable_metadatastream = True
        else:
            camera_config = {
                CONF_HOST: device_config[CONF_HOST],
                CONF_NAME: device_config[CONF_NAME],
                CONF_PORT: device_config[CONF_PORT],
                CONF_USERNAME: device_config[CONF_USERNAME],
                CONF_PASSWORD: device_config[CONF_PASSWORD]
            }
            discovery.load_platform(hass, component, DOMAIN, camera_config,
                                    config)

    if enable_metadatastream:
        device.initialize_new_event = event_initialized
        if not device.initiate_metadatastream():
            hass.components.persistent_notification.create(
                'Dependency missing for sensors, '
                'please check documentation',
                title=DOMAIN,
                notification_id='axis_notification')

    AXIS_DEVICES[device.serial_number] = device

    return True