mirror of https://github.com/home-assistant/core
Rename google_assistant.AbstractConfig.get_local_agent_user_id (#109798)
* Rename google_assistant.AbstractConfig get_local_agent_user_id to get_local_user_id * Fix
This commit is contained in:
parent
cf188eabdf
commit
0cb913370f
|
@ -173,8 +173,12 @@ class CloudGoogleConfig(AbstractConfig):
|
|||
"""Return the webhook ID to be used for actions for a given agent user id via the local SDK."""
|
||||
return self._prefs.google_local_webhook_id
|
||||
|
||||
def get_local_agent_user_id(self, webhook_id: Any) -> str:
|
||||
"""Return the user ID to be used for actions received via the local SDK."""
|
||||
def get_local_user_id(self, webhook_id: Any) -> str:
|
||||
"""Map webhook ID to a Home Assistant user ID.
|
||||
|
||||
Any action inititated by Google Assistant via the local SDK will be attributed
|
||||
to the returned user ID.
|
||||
"""
|
||||
return self._user
|
||||
|
||||
@property
|
||||
|
|
|
@ -167,11 +167,16 @@ class AbstractConfig(ABC):
|
|||
and self._local_last_active > utcnow() - timedelta(seconds=70)
|
||||
)
|
||||
|
||||
def get_local_agent_user_id(self, webhook_id):
|
||||
"""Return the user ID to be used for actions received via the local SDK.
|
||||
def get_local_user_id(self, webhook_id):
|
||||
"""Map webhook ID to a Home Assistant user ID.
|
||||
|
||||
Return None is no agent user id is found.
|
||||
Any action inititated by Google Assistant via the local SDK will be attributed
|
||||
to the returned user ID.
|
||||
|
||||
Return None if no user id is found for the webhook_id.
|
||||
"""
|
||||
# Note: The manually setup Google Assistant currently returns the Google agent
|
||||
# user ID instead of a valid Home Assistant user ID
|
||||
found_agent_user_id = None
|
||||
for agent_user_id, agent_user_data in self._store.agent_user_ids.items():
|
||||
if agent_user_data[STORE_GOOGLE_LOCAL_WEBHOOK_ID] == webhook_id:
|
||||
|
@ -423,7 +428,7 @@ class AbstractConfig(ABC):
|
|||
pprint.pformat(async_redact_request_msg(payload)),
|
||||
)
|
||||
|
||||
if (agent_user_id := self.get_local_agent_user_id(webhook_id)) is None:
|
||||
if (agent_user_id := self.get_local_user_id(webhook_id)) is None:
|
||||
# No agent user linked to this webhook, means that the user has somehow unregistered
|
||||
# removing webhook and stopping processing of this request.
|
||||
_LOGGER.error(
|
||||
|
|
|
@ -258,8 +258,8 @@ async def test_google_config_local_fulfillment(
|
|||
await hass.async_block_till_done()
|
||||
|
||||
assert config.get_local_webhook_id(agent_user_id) == local_webhook_id
|
||||
assert config.get_local_agent_user_id(local_webhook_id) == agent_user_id
|
||||
assert config.get_local_agent_user_id("INCORRECT") is None
|
||||
assert config.get_local_user_id(local_webhook_id) == agent_user_id
|
||||
assert config.get_local_user_id("INCORRECT") is None
|
||||
|
||||
|
||||
async def test_secure_device_pin_config(hass: HomeAssistant) -> None:
|
||||
|
|
Loading…
Reference in New Issue