You cannot create trigger-based sensors in the UI.
The UI template sensor helper state template box is for Jinja templates like:
{{ states('binary_sensor.motion_sensor_occupancy') }}
and not for YAML like:
template:
- trigger:
platform: state
So if you want a trigger-based sensor that only updates when the trigger fires, you must create that in YAML and not in the UI.
If you want a general template sensor that updates when any of the inputs change, you can use the UI.
As an example, I have two outside temperature sensors, one facing east, one facing west. I take the colder of the two to eliminate any sun heat issues.
I do this with a normal template sensor which can be set up via the UI:
{{ (states('sensor.outside_temperature_1')|float(0),
states('sensor.outside_temperature_2')|float(0))|min }}
That updates whenever a new sensor reading comes in from either sensor:
For a triggered example, I want a sensor that shows how many hours the heating system has run during the day. To do this, I use a trigger-based sensor that triggers at the end of the day and ignores any other changes:
template:
- trigger:
- platform: time
at: "23:59:00"
sensor:
- name: "Heating daily hours"
unit_of_measurement: 'hours'
state: "{{ states('sensor.heating_hours_today')|float(0) }}"
Without the trigger, that would just be a copy of the heating_hours_today
sensor that gradually increases through the day.
That is in my config files, as it cannot (yet) be set up through the UI.