What am I doing wrong here?
This condition doesn’t get evaluated although it’s placed higher (first):
- conditions:
- condition: template
value_template: >
{{ balcony_temp < previous_balcony_temp - 4 or bedroom_temp <
previous_bedroom_temp - 4}}
sequence:
- action: logbook.log
data:
name: Action Terminated
message: Automation stopped due to abnormal temperature drop.
- conditions:
This is the notification that I get:
Balcony: -5.82°C (Prev: -0.01°C), Bedroom: -4.46°C (Prev: -4.46°C). Triggered by: sensor.aqara_temp_balcony.
This is in the logbook:
Temperature Notification Debug Triggered by: sensor.aqara_temp_balcony. Balcony Temp: -5.82°C, Previous: -0.01°C. Bedroom Temp: -4.46°C, Previous: -4.46°C. triggered by automation Temperature Notifications triggered by state of Temp
10:21:50 AM - 23 minutes ago
Any ideas? I’m trying to ignore eroneous notifications as the Aqara sensors seem to misbehaving particularly at low temperatures.
The whole YAML code:
alias: Temperature Notifications
description: Notify based on temperature conditions between balcony and bedroom.
triggers:
- entity_id:
- sensor.aqara_temp_balcony
- sensor.aqara_temp_bedroom
trigger: state
for:
hours: 0
minutes: 0
seconds: 10
conditions:
- condition: sun
after: sunrise
before: sunset
actions:
- variables:
balcony_temp: "{{ states('sensor.aqara_temp_balcony') | float(0) }}"
bedroom_temp: "{{ states('sensor.aqara_temp_bedroom') | float(0) }}"
previous_balcony_temp: >-
{{ trigger.from_state.state | float(0) if trigger.entity_id ==
'sensor.aqara_temp_balcony' else balcony_temp }}
previous_bedroom_temp: >-
{{ trigger.from_state.state | float(0) if trigger.entity_id ==
'sensor.aqara_temp_bedroom' else bedroom_temp }}
- action: logbook.log
data:
name: Temperature Notification Debug
message: >
Triggered by: {{ trigger.entity_id }}. Balcony Temp: {{ balcony_temp
}}°C, Previous: {{ previous_balcony_temp }}°C. Bedroom Temp: {{
bedroom_temp }}°C, Previous: {{ previous_bedroom_temp }}°C.
- action: persistent_notification.create
data:
title: "Debug: Temperature Notification Triggered"
message: >
Balcony: {{ balcony_temp }}°C (Prev: {{ previous_balcony_temp }}°C),
Bedroom: {{ bedroom_temp }}°C (Prev: {{ previous_bedroom_temp }}°C).
Triggered by: {{ trigger.entity_id }}.
- choose:
- conditions:
- condition: template
value_template: >
{{ balcony_temp < previous_balcony_temp - 4 or bedroom_temp <
previous_bedroom_temp - 4}}
sequence:
- action: logbook.log
data:
name: Action Terminated
message: Automation stopped due to abnormal temperature drop.
- conditions:
- condition: template
value_template: |
{{ balcony_temp > bedroom_temp + 0.5 }}
- condition: state
entity_id: input_boolean.windows
state: "off"
sequence:
- data:
message: >
Open the windows. Balcony temperature: {{ balcony_temp }}°C.
Bedroom temperature: {{ bedroom_temp }}°C.
action: notify.mobile_app_krs_mini
- target:
entity_id: input_boolean.windows
action: input_boolean.turn_on
data: {}
- action: logbook.log
data:
name: Action Taken
message: Open windows notification sent.
- conditions:
- condition: template
value_template: |
{{ balcony_temp < previous_balcony_temp - 0.5 }}
- condition: state
entity_id: input_boolean.notify_balcony_temp_decrease
state: "off"
sequence:
- data:
message: >
Balcony temperature from {{ previous_balcony_temp }}°C to {{
balcony_temp }}°C.
action: notify.mobile_app_krs_mini
- target:
entity_id: input_boolean.notify_balcony_temp_decrease
action: input_boolean.turn_on
data: {}
- action: logbook.log
data:
name: Action Taken
message: Balcony temp decrease notification sent.
- conditions:
- condition: template
value_template: |
{{ bedroom_temp < previous_bedroom_temp - 0.5 }}
- condition: state
entity_id: input_boolean.notify_bedroom_temp_decrease
state: "off"
sequence:
- data:
message: >
Bedroom temperature from {{ previous_bedroom_temp }}°C to {{
bedroom_temp }}°C.
action: notify.mobile_app_krs_mini
- target:
entity_id: input_boolean.notify_bedroom_temp_decrease
action: input_boolean.turn_on
data: {}
- action: logbook.log
data:
name: Action Taken
message: Bedroom temp decrease notification sent.
- conditions:
- condition: template
value_template: >
{{ balcony_temp < bedroom_temp - 0.5 and balcony_temp <
previous_balcony_temp }}
- condition: state
entity_id: input_boolean.windows
state: "on"
sequence:
- data:
message: >
Close the windows. Balcony temperature: {{ balcony_temp }}°C.
Bedroom temperature: {{ bedroom_temp }}°C.
action: notify.mobile_app_krs_mini
- target:
entity_id: input_boolean.windows
action: input_boolean.turn_off
data: {}
- action: logbook.log
data:
name: Action Taken
message: Close windows notification sent.
default:
- action: logbook.log
data:
name: Debug Default Path
message: >
Default path triggered. Balcony: from {{ previous_balcony_temp }}°C
to {{ balcony_temp }}°C. Bedroom: from {{ previous_bedroom_temp
}}°C to {{ bedroom_temp }}°C. Booleans: {{
states('input_boolean.windows') }} // {{
states('input_boolean.notify_balcony_temp_decrease') }} // {{
states('input_boolean.notify_bedroom_temp_decrease') }}.
mode: single