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:
Paulus Schoutsen 2019-05-29 08:39:12 -07:00 committed by GitHub
parent 85dfea1642
commit 6947f8cb2e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 346 additions and 86 deletions

View file

@ -1,5 +1,5 @@
"""Helper class to implement include/exclude of entities and domains."""
from typing import Callable, Dict, Iterable
from typing import Callable, Dict, List
import voluptuous as vol
@ -12,7 +12,7 @@ CONF_EXCLUDE_DOMAINS = 'exclude_domains'
CONF_EXCLUDE_ENTITIES = 'exclude_entities'
def _convert_filter(config: Dict[str, Iterable[str]]) -> Callable[[str], bool]:
def _convert_filter(config: Dict[str, List[str]]) -> Callable[[str], bool]:
filt = generate_filter(
config[CONF_INCLUDE_DOMAINS],
config[CONF_INCLUDE_ENTITIES],
@ -20,6 +20,8 @@ def _convert_filter(config: Dict[str, Iterable[str]]) -> Callable[[str], bool]:
config[CONF_EXCLUDE_ENTITIES],
)
setattr(filt, 'config', config)
setattr(
filt, 'empty_filter', sum(len(val) for val in config.values()) == 0)
return filt
@ -34,10 +36,10 @@ FILTER_SCHEMA = vol.All(
}), _convert_filter)
def generate_filter(include_domains: Iterable[str],
include_entities: Iterable[str],
exclude_domains: Iterable[str],
exclude_entities: Iterable[str]) -> Callable[[str], bool]:
def generate_filter(include_domains: List[str],
include_entities: List[str],
exclude_domains: List[str],
exclude_entities: List[str]) -> Callable[[str], bool]:
"""Return a function that will filter entities based on the args."""
include_d = set(include_domains)
include_e = set(include_entities)