Counter Configure Issue

I’m trying to help an automation get configured using a counter.

Counter runs every time a SumpPump is run. I duplicated the counter and called it hourly and reset it every hour.

My goal is to have a template sensor read the value so it can be graphed and some history on the hourly value. I cannot seem to get value to copy over to a last_hour counter. Should I be using an input number instead to store the hourly value before reset and then make a template sensor off its value?

Example automation that is not working.

- alias: Sump Pump Pit 1 Activations Counter - Hourly

  trigger:
    - platform: time_pattern
      minutes: 0
      
  action:  
    - service: counter.configure
      entity_id: counter.sump_pump1_activations_counter_last_hour
      value: {{ states.counter.sump_pump1_activations_counter_current_hour.state | int }}
    - service: counter.reset
      entity_id: counter.sump_pump1_activations_counter_current_hour

Try…

- alias: Sump Pump Pit 1 Activations Counter - Hourly
  trigger:
    - platform: time_pattern
      minutes: 0
  action:  
    - service: counter.configure
      data_template:
        entity_id: counter.sump_pump1_activations_counter_last_hour
        value: "{{ states.counter.sump_pump1_activations_counter_current_hour.state | int }}" 
    - service: counter.reset
      entity_id: counter.sump_pump1_activations_counter_current_hour

Worked perfect! Thank you!

1 Like