diff --git a/homeassistant/components/alexa/smart_home_http.py b/homeassistant/components/alexa/smart_home_http.py index 41738c824fb..6d6b9f54533 100644 --- a/homeassistant/components/alexa/smart_home_http.py +++ b/homeassistant/components/alexa/smart_home_http.py @@ -3,7 +3,13 @@ import logging from homeassistant import core from homeassistant.components.http.view import HomeAssistantView -from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET +from homeassistant.const import ( + CONF_CLIENT_ID, + CONF_CLIENT_SECRET, + ENTITY_CATEGORY_CONFIG, + ENTITY_CATEGORY_DIAGNOSTIC, +) +from homeassistant.helpers import entity_registry as er from .auth import Auth from .config import AbstractConfig @@ -60,7 +66,19 @@ class AlexaConfig(AbstractConfig): def should_expose(self, entity_id): """If an entity should be exposed.""" - return self._config[CONF_FILTER](entity_id) + if not self._config[CONF_FILTER].empty_filter: + return self._config[CONF_FILTER](entity_id) + + entity_registry = er.async_get(self.hass) + registry_entry = entity_registry.async_get(entity_id) + if registry_entry: + auxiliary_entity = registry_entry.entity_category in ( + ENTITY_CATEGORY_CONFIG, + ENTITY_CATEGORY_DIAGNOSTIC, + ) + else: + auxiliary_entity = False + return not auxiliary_entity @core.callback def async_invalidate_access_token(self): diff --git a/tests/helpers/test_entityfilter.py b/tests/helpers/test_entityfilter.py index 5bc37216f81..5d28295e3a0 100644 --- a/tests/helpers/test_entityfilter.py +++ b/tests/helpers/test_entityfilter.py @@ -205,6 +205,24 @@ def test_no_domain_case4c(): assert testfilter("sun.sun") is False +def test_filter_schema_empty(): + """Test filter schema.""" + conf = {} + filt = FILTER_SCHEMA(conf) + conf.update( + { + "include_domains": [], + "include_entities": [], + "exclude_domains": [], + "exclude_entities": [], + "include_entity_globs": [], + "exclude_entity_globs": [], + } + ) + assert filt.config == conf + assert filt.empty_filter + + def test_filter_schema(): """Test filter schema.""" conf = { @@ -216,6 +234,7 @@ def test_filter_schema(): filt = FILTER_SCHEMA(conf) conf.update({"include_entity_globs": [], "exclude_entity_globs": []}) assert filt.config == conf + assert not filt.empty_filter def test_filter_schema_with_globs(): @@ -230,6 +249,7 @@ def test_filter_schema_with_globs(): } filt = FILTER_SCHEMA(conf) assert filt.config == conf + assert not filt.empty_filter def test_filter_schema_include_exclude(): @@ -248,3 +268,4 @@ def test_filter_schema_include_exclude(): } filt = INCLUDE_EXCLUDE_FILTER_SCHEMA(conf) assert filt.config == conf + assert not filt.empty_filter