I’m trying to write an automation to (currently) notify me when my numeric states of 2 entities fit the ranges given. But I cannot seem to get it to fire the notification, unless this is manually with the run action function.
the YAML is :-
alias: 'Solar > Car '
description: Divert solar generation to EV
trigger:
- platform: numeric_state
entity_id: sensor.solar_panels_ac_output_total_power
for:
hours: 0
minutes: 0
seconds: 0
below: '5000'
above: '100'
condition:
- condition: numeric_state
entity_id: sensor.glow84cca85453c0_power_consumption
below: '0'
action:
- service: notify.notify
data:
message: Car Charge on
title: Car Charge
mode: single
Current values are:-
sensor.solar_panels_ac_output_total_power = 459.12
sensor.glow84cca85453c0_power_consumption = 136
Your automation only triggers when the total power goes from above 5000 to below 5000 or when it goes from below 100 to above 100. If it is changing within the 100 to 5000 window it will not trigger. As explained here.
You need to trigger on every change of state of both sensors then check if they are within the required value windows using conditions. Like this:
alias: 'Solar > Car '
description: Divert solar generation to EV
trigger:
- platform: state
entity_id: sensor.solar_panels_ac_output_total_power
to: # a null to: triggers on every change of state. Leaving the to: line out altogether triggers on attribute changes as well. You dont want this.
- platform: state
entity_id: sensor.glow84cca85453c0_power_consumption
to:
condition:
- condition: numeric_state
entity_id: sensor.solar_panels_ac_output_total_power
below: '5000'
above: '100'
- condition: numeric_state
entity_id: sensor.glow84cca85453c0_power_consumption
below: '0'
action:
- service: notify.notify
data:
message: Car Charge on
title: Car Charge
mode: single