Is it possible to use the utility_meter without a cycle, using only an automation to reset its counter?
I would like to track the number of kilometers travelled for each charge of my car, but not with an input number because my goal is having statistics for each charge. utility_meter seems perfect for this purpose, but I can’t find the correct way to reset it when I’m charging the vehicle (and using without tariffs and cycles).
This is my current
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: 'off' to: 'on' condition:  action: - service: utility_meter.reset entity_id: sensor.km_foreach_charge mode: single
sensor.km_foreach_charge helper is defined like so:
state_class: total_increasing source: sensor.car_odometer status: collecting last_period: '0' last_reset: '2022-05-10T19:15:18.507533+00:00' unit_of_measurement: km icon: mdi:counter friendly_name: km for each charge
It works, as it’s counting the distance travelled (by calculating the km difference from the odometer), but even if the automation has been triggered during charging, the status is still collecting with the distance not being 0 (27 at the moment).
It should have moved the previous value to the
last_period attribute and started a new cycle.
The log seems correct:
this: entity_id: automation.reset_distance_travelled state: 'on' attributes: last_triggered: null mode: single current: 0 id: '1652210702680' friendly_name: Reset distance travelled when charging last_changed: '2022-05-11T15:49:38.183144+00:00' last_updated: '2022-05-11T15:49:38.183144+00:00' context: id: b5376f08ebff13d067f0bc4b947733b7 parent_id: null user_id: null trigger: id: '0' idx: '0' platform: state entity_id: switch.car_charging from_state: entity_id: switch.car_charging state: 'off' attributes: last_result: '' last_updated: null last_changed: '2022-05-11T21:04:48.690588+00:00' last_updated: '2022-05-11T21:04:48.690588+00:00' context: id: 6af6d443d5125e2d655411aad32ed336 parent_id: null user_id: null to_state: entity_id: switch.car_charging state: 'on' attributes: last_result: '' last_updated: null last_changed: '2022-05-12T03:09:55.285780+00:00' last_updated: '2022-05-12T03:09:55.285780+00:00' context: id: 187c722c1960a2c459b99811332b0509 parent_id: null user_id: null for: null attribute: null description: state of switch.car_charging