mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Handle Alexa entity removed (#39569)
This commit is contained in:
parent
4486251382
commit
d5bcafaefd
@ -201,6 +201,11 @@ class DisplayCategory:
|
||||
WEARABLE = "WEARABLE"
|
||||
|
||||
|
||||
def generate_alexa_id(entity_id: str) -> str:
|
||||
"""Return the alexa ID for an entity ID."""
|
||||
return entity_id.replace(".", "#").translate(TRANSLATION_TABLE)
|
||||
|
||||
|
||||
class AlexaEntity:
|
||||
"""An adaptation of an entity, expressed in Alexa's terms.
|
||||
|
||||
@ -232,7 +237,7 @@ class AlexaEntity:
|
||||
|
||||
def alexa_id(self):
|
||||
"""Return the Alexa API entity id."""
|
||||
return self.entity.entity_id.replace(".", "#").translate(TRANSLATION_TABLE)
|
||||
return generate_alexa_id(self.entity.entity_id)
|
||||
|
||||
def display_categories(self):
|
||||
"""Return a list of display categories."""
|
||||
|
@ -10,7 +10,7 @@ from homeassistant.const import MATCH_ALL, STATE_ON
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from .const import API_CHANGE, Cause
|
||||
from .entities import ENTITY_ADAPTERS
|
||||
from .entities import ENTITY_ADAPTERS, generate_alexa_id
|
||||
from .messages import AlexaResponse
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@ -181,8 +181,7 @@ async def async_send_delete_message(hass, config, entity_ids):
|
||||
if domain not in ENTITY_ADAPTERS:
|
||||
continue
|
||||
|
||||
alexa_entity = ENTITY_ADAPTERS[domain](hass, config, hass.states.get(entity_id))
|
||||
endpoints.append({"endpointId": alexa_entity.alexa_id()})
|
||||
endpoints.append({"endpointId": generate_alexa_id(entity_id)})
|
||||
|
||||
payload = {"endpoints": endpoints, "scope": {"type": "BearerToken", "token": token}}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user