Esempio n. 1
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the access to Netatmo binary sensor."""
    netatmo = hass.components.netatmo
    home = config.get(CONF_HOME)
    timeout = config.get(CONF_TIMEOUT)
    if timeout is None:
        timeout = DEFAULT_TIMEOUT

    module_name = None

    import pyatmo
    try:
        data = CameraData(netatmo.NETATMO_AUTH, home)
        if not data.get_camera_names():
            return None
    except pyatmo.NoDevice:
        return None

    welcome_sensors = config.get(
        CONF_WELCOME_SENSORS, WELCOME_SENSOR_TYPES)
    presence_sensors = config.get(
        CONF_PRESENCE_SENSORS, PRESENCE_SENSOR_TYPES)
    tag_sensors = config.get(CONF_TAG_SENSORS, TAG_SENSOR_TYPES)

    for camera_name in data.get_camera_names():
        camera_type = data.get_camera_type(camera=camera_name, home=home)
        if camera_type == 'NACamera':
            if CONF_CAMERAS in config:
                if config[CONF_CAMERAS] != [] and \
                   camera_name not in config[CONF_CAMERAS]:
                    continue
            for variable in welcome_sensors:
                add_entities([NetatmoBinarySensor(
                    data, camera_name, module_name, home, timeout,
                    camera_type, variable)], True)
        if camera_type == 'NOC':
            if CONF_CAMERAS in config:
                if config[CONF_CAMERAS] != [] and \
                   camera_name not in config[CONF_CAMERAS]:
                    continue
            for variable in presence_sensors:
                add_entities([NetatmoBinarySensor(
                    data, camera_name, module_name, home, timeout,
                    camera_type, variable)], True)

        for module_name in data.get_module_names(camera_name):
            for variable in tag_sensors:
                camera_type = None
                add_entities([NetatmoBinarySensor(
                    data, camera_name, module_name, home, timeout,
                    camera_type, variable)], True)
Esempio n. 2
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup access to Netatmo cameras."""
    netatmo = get_component('netatmo')
    home = config.get(CONF_HOME)
    import lnetatmo
    try:
        data = CameraData(netatmo.NETATMO_AUTH, home)
        for camera_name in data.get_camera_names():
            camera_type = data.get_camera_type(camera=camera_name, home=home)
            if CONF_CAMERAS in config:
                if config[CONF_CAMERAS] != [] and \
                   camera_name not in config[CONF_CAMERAS]:
                    continue
            add_devices([NetatmoCamera(data, camera_name, home, camera_type)])
    except lnetatmo.NoDevice:
        return None
Esempio n. 3
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up access to Netatmo cameras."""
    netatmo = hass.components.netatmo
    home = config.get(CONF_HOME)
    verify_ssl = config.get(CONF_VERIFY_SSL, True)
    import pyatmo
    try:
        data = CameraData(netatmo.NETATMO_AUTH, home)
        for camera_name in data.get_camera_names():
            camera_type = data.get_camera_type(camera=camera_name, home=home)
            if CONF_CAMERAS in config:
                if config[CONF_CAMERAS] != [] and \
                   camera_name not in config[CONF_CAMERAS]:
                    continue
            add_entities([NetatmoCamera(data, camera_name, home,
                                        camera_type, verify_ssl)])
    except pyatmo.NoDevice:
        return None
Esempio n. 4
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up access to Netatmo cameras."""
    netatmo = hass.components.netatmo
    home = config.get(CONF_HOME)
    verify_ssl = config.get(CONF_VERIFY_SSL, True)
    import pyatmo
    try:
        data = CameraData(netatmo.NETATMO_AUTH, home)
        for camera_name in data.get_camera_names():
            camera_type = data.get_camera_type(camera=camera_name, home=home)
            if CONF_CAMERAS in config:
                if config[CONF_CAMERAS] != [] and \
                   camera_name not in config[CONF_CAMERAS]:
                    continue
            add_entities([NetatmoCamera(data, camera_name, home,
                                        camera_type, verify_ssl)])
    except pyatmo.NoDevice:
        return None
Esempio n. 5
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup access to Netatmo binary sensor."""
    netatmo = get_component('netatmo')
    home = config.get(CONF_HOME, None)
    timeout = config.get(CONF_TIMEOUT, 15)
    offset = config.get(CONF_OFFSET, 90)

    module_name = None

    import lnetatmo
    try:
        data = CameraData(netatmo.NETATMO_AUTH, home)
        if data.get_camera_names() == []:
            return None
    except lnetatmo.NoDevice:
        return None

    welcome_sensors = config.get(
        CONF_WELCOME_SENSORS, WELCOME_SENSOR_TYPES)
    presence_sensors = config.get(
        CONF_PRESENCE_SENSORS, PRESENCE_SENSOR_TYPES)
    tag_sensors = config.get(CONF_TAG_SENSORS, TAG_SENSOR_TYPES)

    for camera_name in data.get_camera_names():
        camera_type = data.get_camera_type(camera=camera_name, home=home)
        if camera_type == "NACamera":
            if CONF_CAMERAS in config:
                if config[CONF_CAMERAS] != [] and \
                   camera_name not in config[CONF_CAMERAS]:
                    continue
            for variable in welcome_sensors:
                add_devices([NetatmoBinarySensor(data, camera_name,
                                                 module_name, home, timeout,
                                                 offset, camera_type,
                                                 variable)])
        if camera_type == "NOC":
            if CONF_CAMERAS in config:
                if config[CONF_CAMERAS] != [] and \
                   camera_name not in config[CONF_CAMERAS]:
                    continue
            for variable in presence_sensors:
                add_devices([NetatmoBinarySensor(data, camera_name,
                                                 module_name, home, timeout,
                                                 offset, camera_type,
                                                 variable)])

        for module_name in data.get_module_names(camera_name):
            for variable in tag_sensors:
                camera_type = None
                add_devices([NetatmoBinarySensor(data, camera_name,
                                                 module_name, home,
                                                 timeout, offset,
                                                 camera_type,
                                                 variable)])
Esempio n. 6
0
def setup_platform(hass, config, add_devices, discovery_info=None):
    """Set up the access to Netatmo binary sensor."""
    netatmo = hass.components.netatmo
    home = config.get(CONF_HOME)
    timeout = config.get(CONF_TIMEOUT)
    if timeout is None:
        timeout = DEFAULT_TIMEOUT

    module_name = None

    import lnetatmo
    try:
        data = CameraData(netatmo.NETATMO_AUTH, home)
        if not data.get_camera_names():
            return None
    except lnetatmo.NoDevice:
        return None

    welcome_sensors = config.get(CONF_WELCOME_SENSORS, WELCOME_SENSOR_TYPES)
    presence_sensors = config.get(CONF_PRESENCE_SENSORS, PRESENCE_SENSOR_TYPES)
    tag_sensors = config.get(CONF_TAG_SENSORS, TAG_SENSOR_TYPES)

    for camera_name in data.get_camera_names():
        camera_type = data.get_camera_type(camera=camera_name, home=home)
        if camera_type == 'NACamera':
            if CONF_CAMERAS in config:
                if config[CONF_CAMERAS] != [] and \
                   camera_name not in config[CONF_CAMERAS]:
                    continue
            for variable in welcome_sensors:
                add_devices([
                    NetatmoBinarySensor(data, camera_name, module_name, home,
                                        timeout, camera_type, variable)
                ], True)
        if camera_type == 'NOC':
            if CONF_CAMERAS in config:
                if config[CONF_CAMERAS] != [] and \
                   camera_name not in config[CONF_CAMERAS]:
                    continue
            for variable in presence_sensors:
                add_devices([
                    NetatmoBinarySensor(data, camera_name, module_name, home,
                                        timeout, camera_type, variable)
                ], True)

        for module_name in data.get_module_names(camera_name):
            for variable in tag_sensors:
                camera_type = None
                add_devices([
                    NetatmoBinarySensor(data, camera_name, module_name, home,
                                        timeout, camera_type, variable)
                ], True)