mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +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 (
|
||||
DEVICE_CLASSES_SCHEMA,
|
||||
DOMAIN as SENSOR_DOMAIN,
|
||||
ENTITY_ID_FORMAT,
|
||||
PLATFORM_SCHEMA,
|
||||
SensorEntity,
|
||||
@ -201,6 +202,7 @@ class SensorTemplate(TemplateEntity, SensorEntity):
|
||||
class TriggerSensorEntity(TriggerEntity, SensorEntity):
|
||||
"""Sensor entity based on trigger data."""
|
||||
|
||||
domain = SENSOR_DOMAIN
|
||||
extra_template_keys = (CONF_VALUE_TEMPLATE,)
|
||||
|
||||
@property
|
||||
|
@ -1014,7 +1014,15 @@ async def test_trigger_entity(hass):
|
||||
"attribute_templates": {
|
||||
"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.state == STATE_UNKNOWN
|
||||
|
||||
state = hass.states.get("sensor.bare_minimum")
|
||||
assert state is not None
|
||||
assert state.state == STATE_UNKNOWN
|
||||
|
||||
context = Context()
|
||||
hass.bus.async_fire("test_event", {"beer": 2}, context=context)
|
||||
await hass.async_block_till_done()
|
||||
|
Loading…
x
Reference in New Issue
Block a user