mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Guard bad supported features for Google (#42163)
This commit is contained in:
parent
d8577a1550
commit
5626a379de
@ -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 = [
|
||||
|
@ -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"
|
||||
|
Loading…
x
Reference in New Issue
Block a user