def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
    """Set up MQTT Sensor."""
    if discovery_info is not None:
        config = PLATFORM_SCHEMA(discovery_info)

    name = config.get(CONF_NAME)
    friendly = config.get("fname")
    qos = 0
    no_update = 0
    update = 1

    async_add_devices([
        # entries RSSI
        JkwMqttSensor(hass, name + "_rssi", name + "/r/rssi", qos, '%',
                      no_update, "mdi:signal-variant", friendly + " Signal"),
        # entries BSSID
        JkwMqttSensor(hass, name + "_bssid", name + "/r/BSSID", qos, '',
                      no_update, "mdi:information-outline", friendly),
        # entries SSID
        JkwMqttSensor(hass, name + "_ssid", name + "/r/SSID", qos, '',
                      no_update, "mdi:information-outline", friendly),
        # entries update
        JkwMqttSensor(hass, name + "_info", name + "/r/INFO", qos, '',
                      no_update, "mdi:information-outline", friendly),
        # entries capability
        JkwMqttSensor(hass, name + "_capability", name + "/r/capability", qos,
                      '', no_update, "mdi:information-outline", friendly),
        # entries update
        JkwMqttSensor(hass, name + "_update", name + "/r/#", qos, 'min',
                      update, "mdi:timer-sand", friendly),
        # entries all
        #  JkwMqttSensor(hass, name,name+"/r/#",qos,'',no_update,"mdi:information-outline",friendly),
        # end of entries
    ])
Beispiel #2
0
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
    """Set up a NIPCA Camera Sensor."""
    if discovery_info:
        config = PLATFORM_SCHEMA(discovery_info)
    url = config.get(CONF_URL)
    device = NipcaCameraDevice.from_url(hass, config, url)
    async_add_devices([NipcaMotionSensor(hass, device)])
Beispiel #3
0
async def async_setup_platform(hass,
                               config,
                               async_add_devices,
                               discovery_info=None):

    if (discovery_info):
        entries = [PLATFORM_SCHEMA(x) for x in discovery_info]
    else:
        entries = [config]

    if DATA_NIBE not in hass.data:
        raise PlatformNotReady

    sensors = []
    update = False
    for entry in entries:
        sensors.append(
            NibeSensor(
                hass.data[DATA_NIBE]['uplink'],
                entry.get(CONF_SYSTEM),
                entry.get(CONF_PARAMETER),
                object_id=entry.get(CONF_OBJECTID),
                data=entry.get(CONF_DATA),
                name=entry.get(CONF_NAME)
            )
        )
        if entry.get(CONF_DATA) is None:
            update = True

    async_add_devices(sensors, update)
Beispiel #4
0
async def async_setup_platform(hass,
                               config,
                               async_add_entities,
                               discovery_info=None):
    """Set up a NIPCA Camera Sensors."""
    if discovery_info:
        config = PLATFORM_SCHEMA(discovery_info)
    url = config.get(CONF_URL)
    device = await hass.async_add_executor_job(NipcaCameraDevice.from_url,
                                               hass, config, url)

    coordinator = DataUpdateCoordinator(
        hass,
        _LOGGER,
        name="motion_sensor",
        update_method=device.update_motion_sensors,
        update_interval=timedelta(seconds=config.get(CONF_SCAN_INTERVAL)),
    )

    device.coordinator = coordinator

    await coordinator.async_refresh()

    sensors = ["md1"]

    if "mic" in device._attributes and device._attributes["mic"] == "yes":
        sensors.append("audio_detected")

    if "pir" in device._attributes and device._attributes["pir"] == "yes":
        sensors.append("pir")

    if "led" in device._attributes and device._attributes["led"] == "yes":
        sensors.append("led")

    if "ir" in device._attributes and device._attributes["ir"] == "yes":
        sensors.append("irled")

    if "inputs" in device._attributes:
        num_inputs = int(device._attributes["inputs"])
        if num_inputs > 0:
            for input in range(1, num_inputs + 1):
                sensors.append(f"input{input}")

    if "outputs" in device._attributes:
        num_outputs = int(device._attributes["outputs"])
        if num_outputs > 0:
            for output in range(1, num_outputs + 1):
                sensors.append(f"output{output}")

    async_add_entities(
        NipcaMotionSensor(hass, device, coordinator, name) for name in sensors)