Automation - temp below 0

Hi,
I want to setup automation that would notify my at 7AM if temperature was below 0 at night
I set the trigger to 1C and I’m using openweather as the temperature source
I have this:

alias: Notify when night temp was below 0°C
description: ''
trigger:
  - platform: template
    value_template: '{{ states(''sensor.openweathermap_temperature'') | float < 1 }}'
condition:
  - condition: time
    after: '23:00'
    before: '07:00'
action:
  - condition: time
    after: '07:01'
  - service: notify.mobile_app_my_iphone
    data:
      message: Temp at night was below 0
mode: single

This looks OK to me but that does not seem to be working. I cannot figure out why.

Here’s what I suggest you try:

alias: Notify when night temp was below 0°C
description: ''
trigger:
  - platform: state
    entity_id: sensor.openweathermap_temperature
condition:
  - condition: template
    value_template: '{{ trigger.to_state.state | float < 1 }}'
  - condition: template
    value_template: '{{ now().hour == 23 or now().hour < 7 }}'
action:
  - wait_for_trigger:
      - platform: time
        at: '07:00:00'
  - service: notify.mobile_app_my_iphone
    data:
      message: Temp at night was below 0.
mode: single
max_exceeded: silent

The reason the automation doesn’t seem to be working is that you have set up your conditions in such a way that they will never all be true… There is no time that is “after 23:00” and “before 7:00” as well as “after 7:01”… so when the automation is triggered overnight, it passes the first time condition, then fails the one you have in the action section of the automation.

1 Like