1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Template sensor/binary sensors without trigger now respect section unique id (#49613)

This commit is contained in:
Paulus Schoutsen
2021-04-24 07:14:31 -07:00
committed by GitHub
parent b0fecdcc3d
commit dcee78b747
5 changed files with 74 additions and 11 deletions

View File

@@ -636,8 +636,12 @@ async def test_unique_id(hass):
"""Test unique_id option only creates one sensor per id."""
await async_setup_component(
hass,
sensor.DOMAIN,
"template",
{
"template": {
"unique_id": "group-id",
"sensor": {"name": "top-level", "unique_id": "sensor-id", "state": "5"},
},
"sensor": {
"platform": "template",
"sensors": {
@@ -650,7 +654,7 @@ async def test_unique_id(hass):
"value_template": "{{ false }}",
},
},
}
},
},
)
@@ -658,7 +662,19 @@ async def test_unique_id(hass):
await hass.async_start()
await hass.async_block_till_done()
assert len(hass.states.async_all()) == 1
assert len(hass.states.async_all()) == 2
ent_reg = entity_registry.async_get(hass)
assert len(ent_reg.entities) == 2
assert (
ent_reg.async_get_entity_id("sensor", "template", "group-id-sensor-id")
is not None
)
assert (
ent_reg.async_get_entity_id("sensor", "template", "not-so-unique-anymore")
is not None
)
async def test_sun_renders_once_per_sensor(hass):