async def _async_remove_ais_dom_entity(hass, entity_id):
    ent_registry = await hass.helpers.entity_registry.async_get_registry()
    platform = ""
    domain = ""
    unique_id = ""
    if ent_registry.async_is_registered(entity_id):
        entity_entry = ent_registry.async_get(entity_id)
        unique_id = entity_entry.unique_id
        domain = entity_entry.domain
        platform = entity_entry.platform
        ent_registry.async_remove(entity_id)
    # remove from already discovered
    if platform == "mqtt":
        discovery_hash = (domain, unique_id)
        if discovery_hash in hass.data[mqtt_disco.ALREADY_DISCOVERED]:
            mqtt_disco.clear_discovery_hash(hass, discovery_hash)
        # remove this code and his name from json
        G_RF_CODES_DATA.async_remove_code(unique_id)
    elif platform == "ais_drives_service":
        # remove drive, unmount and remove symlincs
        await hass.services.async_call("ais_drives_service",
                                       "rclone_remove_drive",
                                       {"name": unique_id})

    hass.states.async_remove(entity_id)
Exemple #2
0
 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
Exemple #3
0
 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
Exemple #4
0
 async def async_discover(discovery_payload):
     """Discover and add an MQTT lock."""
     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
Exemple #5
0
 async def async_discover(discovery_payload):
     """Discover and add a MQTT climate device."""
     try:
         discovery_hash = discovery_payload[ATTR_DISCOVERY_HASH]
         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 def async_discover(discovery_payload):
     """Discover and add a MQTT binary sensor."""
     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
Exemple #7
0
 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 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
Exemple #9
0
 def discovery_callback(payload):
     """Handle discovery update."""
     _LOGGER.info("Got update for entity with hash: %s '%s'",
                  self._discovery_hash, payload)
     if not payload:
         # Empty payload: Remove component
         _LOGGER.info("Removing component: %s", self.entity_id)
         self.hass.async_create_task(self.async_remove())
         clear_discovery_hash(self.hass, self._discovery_hash)
         self._remove_signal()
     elif self._discovery_update:
         # Non-empty payload: Notify component
         _LOGGER.info("Updating component: %s", self.entity_id)
         self.hass.async_create_task(self._discovery_update(payload))
Exemple #10
0
 def discovery_callback(payload):
     """Handle discovery update."""
     _LOGGER.info("Got update for entity with hash: %s '%s'",
                  self._discovery_hash, payload)
     if not payload:
         # Empty payload: Remove component
         _LOGGER.info("Removing component: %s", self.entity_id)
         self.hass.async_create_task(self.async_remove())
         clear_discovery_hash(self.hass, self._discovery_hash)
         self._remove_signal()
     elif self._discovery_update:
         # Non-empty payload: Notify component
         _LOGGER.info("Updating component: %s", self.entity_id)
         payload.pop(ATTR_DISCOVERY_HASH)
         self.hass.async_create_task(self._discovery_update(payload))
Exemple #11
0
async def _async_remove_ais_dom_entity(hass, entity_id):
    registry = await entity_registry.async_get_registry(hass)
    if entity_id in registry.entities:
        entity_entry = registry.async_get(entity_id)
        unique_id = entity_entry.unique_id
        domain = entity_entry.domain
        platform = entity_entry.platform
        registry.async_remove(entity_id)
        # remove from already discovered
        if platform == "mqtt":
            discovery_hash = (domain, unique_id)
            if discovery_hash in hass.data[mqtt_disco.ALREADY_DISCOVERED]:
                mqtt_disco.clear_discovery_hash(hass, discovery_hash)

    hass.states.async_remove(entity_id)

    # remove this code and his name from json
    G_RF_CODES_DATA.async_remove_code(unique_id)