mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Fix trigger template entities without a unique ID (#48631)
This commit is contained in:
parent
bdbb4f939f
commit
212d9aa748
@ -5,6 +5,7 @@ import voluptuous as vol
|
|||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
DEVICE_CLASSES_SCHEMA,
|
DEVICE_CLASSES_SCHEMA,
|
||||||
|
DOMAIN as SENSOR_DOMAIN,
|
||||||
ENTITY_ID_FORMAT,
|
ENTITY_ID_FORMAT,
|
||||||
PLATFORM_SCHEMA,
|
PLATFORM_SCHEMA,
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
@ -201,6 +202,7 @@ class SensorTemplate(TemplateEntity, SensorEntity):
|
|||||||
class TriggerSensorEntity(TriggerEntity, SensorEntity):
|
class TriggerSensorEntity(TriggerEntity, SensorEntity):
|
||||||
"""Sensor entity based on trigger data."""
|
"""Sensor entity based on trigger data."""
|
||||||
|
|
||||||
|
domain = SENSOR_DOMAIN
|
||||||
extra_template_keys = (CONF_VALUE_TEMPLATE,)
|
extra_template_keys = (CONF_VALUE_TEMPLATE,)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -1014,7 +1014,15 @@ async def test_trigger_entity(hass):
|
|||||||
"attribute_templates": {
|
"attribute_templates": {
|
||||||
"plus_one": "{{ trigger.event.data.beer + 1 }}"
|
"plus_one": "{{ trigger.event.data.beer + 1 }}"
|
||||||
},
|
},
|
||||||
}
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"trigger": [],
|
||||||
|
"sensors": {
|
||||||
|
"bare_minimum": {
|
||||||
|
"value_template": "{{ trigger.event.data.beer }}"
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -1027,6 +1035,10 @@ async def test_trigger_entity(hass):
|
|||||||
assert state is not None
|
assert state is not None
|
||||||
assert state.state == STATE_UNKNOWN
|
assert state.state == STATE_UNKNOWN
|
||||||
|
|
||||||
|
state = hass.states.get("sensor.bare_minimum")
|
||||||
|
assert state is not None
|
||||||
|
assert state.state == STATE_UNKNOWN
|
||||||
|
|
||||||
context = Context()
|
context = Context()
|
||||||
hass.bus.async_fire("test_event", {"beer": 2}, context=context)
|
hass.bus.async_fire("test_event", {"beer": 2}, context=context)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user