diff --git a/homeassistant/components/google_assistant/helpers.py b/homeassistant/components/google_assistant/helpers.py index 8ec2bce4602..48664bff395 100644 --- a/homeassistant/components/google_assistant/helpers.py +++ b/homeassistant/components/google_assistant/helpers.py @@ -343,6 +343,15 @@ class GoogleEntity: state = self.state domain = state.domain features = state.attributes.get(ATTR_SUPPORTED_FEATURES, 0) + + if not isinstance(features, int): + _LOGGER.warning( + "Entity %s contains invalid supported_features value %s", + self.entity_id, + features, + ) + return [] + device_class = state.attributes.get(ATTR_DEVICE_CLASS) self._traits = [ diff --git a/tests/components/google_assistant/test_helpers.py b/tests/components/google_assistant/test_helpers.py index 2bd68926da1..87e3cac657c 100644 --- a/tests/components/google_assistant/test_helpers.py +++ b/tests/components/google_assistant/test_helpers.py @@ -9,6 +9,7 @@ from homeassistant.components.google_assistant.const import ( # noqa: F401 NOT_EXPOSE_LOCAL, ) from homeassistant.config import async_process_ha_core_config +from homeassistant.core import State from homeassistant.setup import async_setup_component from homeassistant.util import dt @@ -242,3 +243,12 @@ async def test_sync_entities_all(agents, result): res = await config.async_sync_entities_all() assert sorted(mock.mock_calls) == sorted([call(agent) for agent in agents]) assert res == result + + +def test_supported_features_string(caplog): + """Test bad supported features.""" + entity = helpers.GoogleEntity( + None, None, State("test.entity_id", "on", {"supported_features": "invalid"}) + ) + assert entity.is_supported() is False + assert "Entity test.entity_id contains invalid supported_features value invalid"