Add optional unique_id attribute to the template platforms (#38011)
* Add unique_id to template platforms * Update test_binary_sensor.py * Update test_binary_sensor.py
This commit is contained in:
1 parent
6b85e23408
commit
f09a9abc1c
19 files changed
+444
No files matched your search
@@ -639,3 +639,32 @@ async def test_no_template_match_all(hass, caplog):
|
||||
assert hass.states.get("sensor.invalid_entity_picture").state == "hello"
|
||||
assert hass.states.get("sensor.invalid_friendly_name").state == "hello"
|
||||
assert hass.states.get("sensor.invalid_attribute").state == "hello"
|
||||
|
||||
|
||||
async def test_unique_id(hass):
|
||||
"""Test unique_id option only creates one sensor per id."""
|
||||
await async_setup_component(
|
||||
hass,
|
||||
"sensor",
|
||||
{
|
||||
"sensor": {
|
||||
"platform": "template",
|
||||
"sensors": {
|
||||
"test_template_sensor_01": {
|
||||
"unique_id": "not-so-unique-anymore",
|
||||
"value_template": "{{ true }}",
|
||||
},
|
||||
"test_template_sensor_02": {
|
||||
"unique_id": "not-so-unique-anymore",
|
||||
"value_template": "{{ false }}",
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_start()
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(hass.states.async_all()) == 1
|
||||
Reference in new issue
Block a user