Make Alexa custom ID unique (#44839)

* Make Alexa custom ID unique

* Lint

* Lint
This commit is contained in:
Paulus Schoutsen 2021-01-05 17:35:28 +01:00 committed by GitHub
parent 16e1046dbc
commit 69b5176730
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 83 additions and 20 deletions

View file

@ -45,6 +45,11 @@ class AbstractConfig(ABC):
"""Return if proactive mode is enabled."""
return self._unsub_proactive_report is not None
@callback
@abstractmethod
def user_identifier(self):
"""Return an identifier for the user that represents this config."""
async def async_enable_proactive_mode(self):
"""Enable proactive mode."""
if self._unsub_proactive_report is None:

View file

@ -329,7 +329,7 @@ class AlexaEntity:
"manufacturer": "Home Assistant",
"model": self.entity.domain,
"softwareVersion": __version__,
"customIdentifier": self.entity_id,
"customIdentifier": f"{self.config.user_identifier()}-{self.entity_id}",
},
}

View file

@ -53,6 +53,11 @@ class AlexaConfig(AbstractConfig):
"""Return config locale."""
return self._config.get(CONF_LOCALE)
@core.callback
def user_identifier(self):
"""Return an identifier for the user that represents this config."""
return ""
def should_expose(self, entity_id):
"""If an entity should be exposed."""
return self._config[CONF_FILTER](entity_id)