I mean storing the value in another tag/variable.
In fact it does.
Yep, correct. I’ve modified the automation above with this:
id: '1652210702680'
alias: Reset distance travelled
description: When charging, reset the counter of the distance in km
trigger:
- platform: state
entity_id: switch.car_charging
from: 'on'
to: 'off'
condition: []
action:
- service: var.set
data:
entity_id: var.previous_car_charge_distance
value: '{{ states(''sensor.km_since_last_car_charge'') | int(0) }}'
- service: var.set
data:
entity_id: var.previous_car_charge_odometer
value: '{{ states(''sensor.car_odometer'') | int(0) }}'
mode: single
The first of the two action is new, and copies the template sensor into a new variable var.previous_car_charge_distance. This is the variable I would like to graph and save history.
OK, so I’m forced to use InfluxDB even for this specific (and easy) task.
Of course, as there are no other ways to do that. Or can InfluxDB make the calculations to create a bar chart from the sawtooth data? I mean to display the max value after each zero cross as a bar.