mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +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
|
state = self.state
|
||||||
domain = state.domain
|
domain = state.domain
|
||||||
features = state.attributes.get(ATTR_SUPPORTED_FEATURES, 0)
|
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)
|
device_class = state.attributes.get(ATTR_DEVICE_CLASS)
|
||||||
|
|
||||||
self._traits = [
|
self._traits = [
|
||||||
|
@ -9,6 +9,7 @@ from homeassistant.components.google_assistant.const import ( # noqa: F401
|
|||||||
NOT_EXPOSE_LOCAL,
|
NOT_EXPOSE_LOCAL,
|
||||||
)
|
)
|
||||||
from homeassistant.config import async_process_ha_core_config
|
from homeassistant.config import async_process_ha_core_config
|
||||||
|
from homeassistant.core import State
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.util import dt
|
from homeassistant.util import dt
|
||||||
|
|
||||||
@ -242,3 +243,12 @@ async def test_sync_entities_all(agents, result):
|
|||||||
res = await config.async_sync_entities_all()
|
res = await config.async_sync_entities_all()
|
||||||
assert sorted(mock.mock_calls) == sorted([call(agent) for agent in agents])
|
assert sorted(mock.mock_calls) == sorted([call(agent) for agent in agents])
|
||||||
assert res == result
|
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