Cloud: Websocket API to manage Google assistant entity config (#24153)
* Extract exposed devices function * Add might_2fa info to trait * Do not filter with should_expose in Google helper func * Cloud: allow setting if Google entity is exposed * Allow disabling 2FA via config * Cloud: allow disabling 2FA * Lint * More changes * Fix typing
This commit is contained in:
parent
85dfea1642
commit
6947f8cb2e
12 changed files with 346 additions and 86 deletions
|
@ -17,7 +17,9 @@ from homeassistant.util.aiohttp import MockRequest
|
|||
|
||||
from . import utils
|
||||
from .const import (
|
||||
CONF_ENTITY_CONFIG, CONF_FILTER, DOMAIN, DISPATCHER_REMOTE_UPDATE)
|
||||
CONF_ENTITY_CONFIG, CONF_FILTER, DOMAIN, DISPATCHER_REMOTE_UPDATE,
|
||||
PREF_SHOULD_EXPOSE, DEFAULT_SHOULD_EXPOSE,
|
||||
PREF_DISABLE_2FA, DEFAULT_DISABLE_2FA)
|
||||
from .prefs import CloudPreferences
|
||||
|
||||
|
||||
|
@ -98,12 +100,26 @@ class CloudClient(Interface):
|
|||
if entity.entity_id in CLOUD_NEVER_EXPOSED_ENTITIES:
|
||||
return False
|
||||
|
||||
return google_conf['filter'](entity.entity_id)
|
||||
if not google_conf['filter'].empty_filter:
|
||||
return google_conf['filter'](entity.entity_id)
|
||||
|
||||
entity_configs = self.prefs.google_entity_configs
|
||||
entity_config = entity_configs.get(entity.entity_id, {})
|
||||
return entity_config.get(
|
||||
PREF_SHOULD_EXPOSE, DEFAULT_SHOULD_EXPOSE)
|
||||
|
||||
def should_2fa(entity):
|
||||
"""If an entity should be checked for 2FA."""
|
||||
entity_configs = self.prefs.google_entity_configs
|
||||
entity_config = entity_configs.get(entity.entity_id, {})
|
||||
return not entity_config.get(
|
||||
PREF_DISABLE_2FA, DEFAULT_DISABLE_2FA)
|
||||
|
||||
username = self._hass.data[DOMAIN].claims["cognito:username"]
|
||||
|
||||
self._google_config = ga_h.Config(
|
||||
should_expose=should_expose,
|
||||
should_2fa=should_2fa,
|
||||
secure_devices_pin=self._prefs.google_secure_devices_pin,
|
||||
entity_config=google_conf.get(CONF_ENTITY_CONFIG),
|
||||
agent_user_id=username,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue