mirror of
https://github.com/home-assistant/core.git
synced 2025-08-07 04:28:19 +00:00
Fix availability for manual trigger entities
This commit is contained in:
parent
de9c05ad53
commit
07cd669bc1
@ -241,6 +241,7 @@ class ManualTriggerEntity(TriggerBaseEntity):
|
||||
}
|
||||
|
||||
self._render_templates(variables)
|
||||
self.async_write_ha_state()
|
||||
|
||||
|
||||
class ManualTriggerSensorEntity(ManualTriggerEntity, SensorEntity):
|
||||
|
@ -808,3 +808,52 @@ async def test_availability(
|
||||
entity_state = hass.states.get("sensor.test")
|
||||
assert entity_state
|
||||
assert entity_state.state == STATE_UNAVAILABLE
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"get_config",
|
||||
[
|
||||
{
|
||||
"command_line": [
|
||||
{
|
||||
"sensor": {
|
||||
"name": "Test",
|
||||
"command": "echo {{ states.sensor.input_sensor.state }}",
|
||||
"availability": "{{ value|is_number}}",
|
||||
"unit_of_measurement": " ",
|
||||
"state_class": "measurement",
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
)
|
||||
async def test_template_render_not_break_for_availability(
|
||||
hass: HomeAssistant, load_yaml_integration: None
|
||||
) -> None:
|
||||
"""Ensure command with templates get rendered properly."""
|
||||
hass.states.async_set("sensor.input_sensor", "sensor_value")
|
||||
|
||||
# Give time for template to load
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
dt_util.utcnow() + timedelta(minutes=1),
|
||||
)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
entity_state = hass.states.get("sensor.test")
|
||||
assert entity_state
|
||||
assert entity_state.state == STATE_UNAVAILABLE
|
||||
|
||||
hass.states.async_set("sensor.input_sensor", "1")
|
||||
|
||||
# Give time for template to load
|
||||
async_fire_time_changed(
|
||||
hass,
|
||||
dt_util.utcnow() + timedelta(minutes=1),
|
||||
)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
entity_state = hass.states.get("sensor.test")
|
||||
assert entity_state
|
||||
assert entity_state.state == "1"
|
||||
|
Loading…
x
Reference in New Issue
Block a user