Automation trigger never triggers

The trigger is:

platform: template
value_template: '{{ states("sensor.xiaomi_airpurifier_temp") | float < 13.5 }}'

The sensor is xiaomi’s temperature reading. The template is correct (checked in the developer tools). The current reading is 12.4 so I’d think I add automation with a trigger like above and I should see it running but this does not happen. The debugger does not shed any light, says about the showflake (representing the trigger?) that “This node was not executed and so no further trace information is available.”

Home Assistant 2021.7.4.

This feels like a recent change, is it? I could not spot anything related in the changelog though.

Trigger templates triggered when after template’s evaluation, result changes from false to true.

If you can go to Developer Tools —> States (tab) —> Type the sensor’s entity —> Try changing it to above 13.5 (such as 14), then change it to below 13.5 (such as 12).

Then check if the automation is triggered or not.

Note: For a more detailed explanation, see Taras’ explanation here.

Thanks, playing with the state does trigger it. However it does not trigger when it should during the night, and the sensor history graph says there was crossing +14. The temperature sensor belongs to the Xiaomi purifier, it is one of those devices without an “id” (or something like that). How to debug this one?

btw I am seeing a bug - when I open some automation editor, the “save” button appears right away even though I did not make any change.

  1. Can you post here your full automation?
  2. Tested on mobile, you are correct that the save button appears even before any changes are made.
- id: '1627032305147'
  alias: Bedroom heater (<13C) ON nighttime
  description: ''
  trigger:
  - platform: template
    value_template: '{{ states("sensor.xiaomi_airpurifier_temp") | float < 13.5 }}'
  condition:
  - condition: time 
    after: 00:01
    before: 09:00
  action:
  - type: turn_on
    device_id: 52107782aa16c9da3915c6ede6217692
    entity_id: switch.powerextender_2
    domain: switch
  mode: single

(btw is there an easy way to extract yaml from the webui? this is from .homeassistant/automations.yaml).

The temperature crossed +14 down at 02:34AM, and went above +14 at 11AM.

Can you try out this? You can go to Automation Editor → On the top right you’ll see three dots → Click on it → Choose Edit in YAML → Copy over everything

alias: Bedroom heater (<13C) ON nighttime
description: ''
mode: single
trigger:
  - platform: numeric_state
    entity_id: sensor.xiaomi_airpurifier_temp
    below: '13.5'
  - platform: time
    at: '00:01:30'
  - platform: homeassistant
    event: start
condition:
  - condition: time
    after: '00:01:00'
    before: '09:00:00'
  - condition: numeric_state
    entity_id: sensor.xiaomi_airpurifier_temp
    below: '13.5'
action:
  - service: switch.turn_on
    target:
      entity_id: switch.powerextender_2

Explanation:

  1. This works the same as your template trigger-
  - platform: numeric_state
    entity_id: sensor.xiaomi_airpurifier_temp
    below: '13.5'
  1. This is to anticipate in case sensor.xiaomi_airpurifier_temp went below 13.5 before 00:01:00
  - platform: time
    at: '00:01:30'
  1. This is to anticipate if server reboot/crashes happens when sensor.xiaomi_airpurifier_temp crosses the threshold
  - platform: homeassistant
    event: start

The automation as you have it won’t trigger when going above 14°, only when going below 13.5°.