mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 17:57:55 +00:00
Do not sync entities with an empty name (#14181)
This commit is contained in:
parent
46c260fd85
commit
5dcad89a0d
@ -102,18 +102,23 @@ class _GoogleEntity:
|
|||||||
if state.state == STATE_UNAVAILABLE:
|
if state.state == STATE_UNAVAILABLE:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
entity_config = self.config.entity_config.get(state.entity_id, {})
|
||||||
|
name = (entity_config.get(CONF_NAME) or state.name).strip()
|
||||||
|
|
||||||
|
# If an empty string
|
||||||
|
if not name:
|
||||||
|
return None
|
||||||
|
|
||||||
traits = self.traits()
|
traits = self.traits()
|
||||||
|
|
||||||
# Found no supported traits for this entity
|
# Found no supported traits for this entity
|
||||||
if not traits:
|
if not traits:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
entity_config = self.config.entity_config.get(state.entity_id, {})
|
|
||||||
|
|
||||||
device = {
|
device = {
|
||||||
'id': state.entity_id,
|
'id': state.entity_id,
|
||||||
'name': {
|
'name': {
|
||||||
'name': entity_config.get(CONF_NAME) or state.name
|
'name': name
|
||||||
},
|
},
|
||||||
'attributes': {},
|
'attributes': {},
|
||||||
'traits': [trait.name for trait in traits],
|
'traits': [trait.name for trait in traits],
|
||||||
|
@ -286,3 +286,29 @@ async def test_unavailable_state_doesnt_sync(hass):
|
|||||||
'devices': []
|
'devices': []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async def test_empty_name_doesnt_sync(hass):
|
||||||
|
"""Test that an entity with empty name does not sync over."""
|
||||||
|
light = DemoLight(
|
||||||
|
None, ' ',
|
||||||
|
state=False,
|
||||||
|
)
|
||||||
|
light.hass = hass
|
||||||
|
light.entity_id = 'light.demo_light'
|
||||||
|
await light.async_update_ha_state()
|
||||||
|
|
||||||
|
result = await sh.async_handle_message(hass, BASIC_CONFIG, {
|
||||||
|
"requestId": REQ_ID,
|
||||||
|
"inputs": [{
|
||||||
|
"intent": "action.devices.SYNC"
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
assert result == {
|
||||||
|
'requestId': REQ_ID,
|
||||||
|
'payload': {
|
||||||
|
'agentUserId': 'test-agent',
|
||||||
|
'devices': []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user