Hi all
I finally got this yaml to pass the restart check, but now it does not update despite the outdoor temperature increasing, and the template developer tools doesn’t mention the gw2000c_outdoor_temperature sensor. It says:-
This template listens for the following state changed events:
Entity: today_max_outdoor_temperature
Apologies for this probable misunderstanding as its my first trigger based sensor.
- triggers:
- platform: time
at: "00:00:00"
- platform: template
value_template: "{{ states('sensor.gw2000c_outdoor_temperature') < states('today_min_outdoor_temperature') }}"
sensor:
- name: Today min outdoor temperature
unique_id: today_min_outdoor_temperature
unit_of_measurement: "°C"
device_class: temperature
icon: mdi:thermometer-chevron-up
state: "{{ states('sensor.gw2000c_outdoor_temperature')}}"
attributes:
datetime: "{{ now() }}"
One syntax correction and one template correction.
When performing an arithmetic comparison of two sensor values, the values must be converted into float or int (because by default all entity values are strings even when they appear to be numbers).
This Trigger-based Template Sensor will trigger at midnight and whenever the Template Trigger’s value changes from false to true.
The problem with the design of your Template Trigger is that it will trigger when the outdoor temperature is less than the Template Sensor’s value and then never again as the outdoor temperature continues to decrease.
That’s because a Template Trigger fires when its template’s value changes from false to true. It first has to be false before it can become true. So if it becomes true and remains that way, never returning to false, there will be no further triggering.
Thank you Taras; I knew I was doing something wrong, and yes its not the first time I have been bitten by the less than staying true, so I should have twigged.
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.