Пример #1
0
async def async_setup_entry(hass, config_entry, async_add_entities):
    """Set up MQTT vacuum dynamically through MQTT discovery."""
    async def async_discover(discovery_payload):
        """Discover and add a MQTT vacuum."""
        config = PLATFORM_SCHEMA(discovery_payload)
        await _async_setup_entity(config, async_add_entities,
                                  discovery_payload[ATTR_DISCOVERY_HASH])

    async_dispatcher_connect(hass, MQTT_DISCOVERY_NEW.format(DOMAIN, 'mqtt'),
                             async_discover)
Пример #2
0
async def async_setup_entry(hass, config_entry, async_add_entities):
    """Set up MQTT camera dynamically through MQTT discovery."""
    async def async_discover(discovery_payload):
        """Discover and add a MQTT camera."""
        config = PLATFORM_SCHEMA(discovery_payload)
        await _async_setup_entity(hass, config, async_add_entities)

    async_dispatcher_connect(
        hass, MQTT_DISCOVERY_NEW.format(camera.DOMAIN, 'mqtt'),
        async_discover)
Пример #3
0
async def async_setup_entry(hass, config_entry, async_add_entities):
    """Set up MQTT alarm control panel dynamically through MQTT discovery."""
    async def async_discover(discovery_payload):
        """Discover and add an MQTT alarm control panel."""
        config = PLATFORM_SCHEMA(discovery_payload)
        await _async_setup_entity(hass, config, async_add_entities,
                                  discovery_payload[ATTR_DISCOVERY_HASH])

    async_dispatcher_connect(
        hass, MQTT_DISCOVERY_NEW.format(alarm.DOMAIN, 'mqtt'),
        async_discover)
Пример #4
0
async def async_setup_entry(hass, config_entry, async_add_entities):
    """Set up MQTT vacuum dynamically through MQTT discovery."""
    async def async_discover(discovery_payload):
        """Discover and add a MQTT vacuum."""
        discovery_data = discovery_payload.discovery_data
        try:
            config = PLATFORM_SCHEMA(discovery_payload)
            await _async_setup_entity(config, async_add_entities, config_entry,
                                      discovery_data)
        except Exception:
            clear_discovery_hash(hass, discovery_data[ATTR_DISCOVERY_HASH])
            raise

    async_dispatcher_connect(hass, MQTT_DISCOVERY_NEW.format(DOMAIN, "mqtt"),
                             async_discover)
Пример #5
0
async def async_setup_entry(hass, config_entry, async_add_entities):
    """Set up MQTT vacuum dynamically through MQTT discovery."""
    async def async_discover(discovery_payload):
        """Discover and add a MQTT vacuum."""
        try:
            discovery_hash = discovery_payload.pop(ATTR_DISCOVERY_HASH)
            config = PLATFORM_SCHEMA(discovery_payload)
            await _async_setup_entity(config, async_add_entities, config_entry,
                                      discovery_hash)
        except Exception:
            if discovery_hash:
                clear_discovery_hash(hass, discovery_hash)
            raise

    async_dispatcher_connect(
        hass, MQTT_DISCOVERY_NEW.format(DOMAIN, 'mqtt'), async_discover)
Пример #6
0
async def async_setup_entry(hass, config_entry, async_add_entities):
    """Set up MQTT lock dynamically through MQTT discovery."""
    async def async_discover(discovery_payload):
        """Discover and add an MQTT lock."""
        try:
            discovery_hash = discovery_payload[ATTR_DISCOVERY_HASH]
            config = PLATFORM_SCHEMA(discovery_payload)
            await _async_setup_entity(config, async_add_entities,
                                      discovery_hash)
        except Exception:
            if discovery_hash:
                clear_discovery_hash(hass, discovery_hash)
            raise

    async_dispatcher_connect(hass,
                             MQTT_DISCOVERY_NEW.format(lock.DOMAIN, 'mqtt'),
                             async_discover)
Пример #7
0
async def async_setup_entry(hass, config_entry, async_add_entities):
    """Set up MQTT climate device dynamically through MQTT discovery."""
    async def async_discover(discovery_payload):
        """Discover and add a MQTT climate device."""
        try:
            discovery_hash = discovery_payload.pop(ATTR_DISCOVERY_HASH)
            # state_topic is implicitly set by MQTT discovery, remove it
            discovery_payload.pop(CONF_STATE_TOPIC, None)
            config = PLATFORM_SCHEMA(discovery_payload)
            await _async_setup_entity(hass, config, async_add_entities,
                                      config_entry, discovery_hash)
        except Exception:
            if discovery_hash:
                clear_discovery_hash(hass, discovery_hash)
            raise

    async_dispatcher_connect(hass,
                             MQTT_DISCOVERY_NEW.format(climate.DOMAIN, 'mqtt'),
                             async_discover)
Пример #8
0
async def async_setup_entry(hass, config_entry, async_add_entities):
    """Set up MQTT climate device dynamically through MQTT discovery."""
    async def async_discover(discovery_payload):
        """Discover and add a MQTT climate device."""
        try:
            discovery_hash = discovery_payload.pop(ATTR_DISCOVERY_HASH)
            # state_topic is implicitly set by MQTT discovery, remove it
            discovery_payload.pop(CONF_STATE_TOPIC, None)
            config = PLATFORM_SCHEMA(discovery_payload)
            await _async_setup_entity(hass, config, async_add_entities,
                                      config_entry, discovery_hash)
        except Exception:
            if discovery_hash:
                clear_discovery_hash(hass, discovery_hash)
            raise

    async_dispatcher_connect(
        hass, MQTT_DISCOVERY_NEW.format(climate.DOMAIN, 'mqtt'),
        async_discover)