I have this automation that triggers when a value is above 80 (% of the battery level).
When this happens, I increment the number of charges (var.number_of_car_charges
) and then subtract the 80% from the delta charge, so that I’ll wait for another 80% of charge before triggering again.
alias: Count complete charges of the car
description: Car has been charged more than 80%
trigger:
- platform: numeric_state
entity_id: var.previous_car_batt_delta_charge
above: "80"
condition: []
action:
- service: var.set
data:
entity_id: var.number_of_car_charges
value: "{{ (states('var.number_of_car_charges') | int(0)) + 1 }}"
enabled: true
- service: var.set
data:
entity_id: var.previous_car_batt_delta_charge
# How to replace the value 80 below with a variable that points to the 'above' value in the trigger?
value: "{{ (states('var.previous_car_batt_delta_charge') | int(0)) - 80 }}"
enabled: true
mode: single
This works, but I would like to replace the 80
value in the last template with the same value I’ve written in the trigger. Is that possible?
I mean, something like this.trigger[0].above
that allows me to change the hardcoded value in a single place within the same automation.