Pulse Counter reset via action entity issue

Hi there,

I´m new to HA and ESPhome and have a irrigation, where a pulse counter counts the pulses of flowing water to calculate the consumption of water.

The pulse counter is integrated in HA via ESPhome, so far so good.

I use a entity called “bewaesserung_pulses” which is counting the pulses when water is flowing.

The entity shows me the correct count, that is working.

But I struggle in implementing an action which allows me to manually set/reset the count of the esp.

I´ve found the following code in the documentation of ESPhome, which I´ve added to my yaml file but it didn´t work.

api:
  encryption:
    key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  actions:
    - action: set_pulse_total
      variables:
        new_pulse_total: int
      then:
        - pulse_counter.set_total_pulses:
            id: "bewaesserung_pulses"
            value: !lambda 'return new_pulse_total;'

When I try to install it, I get the following error:

Couldn’t find ID ‘bewaesserung_pulses’. Please check you have defined an ID with that name in your configuration.

I have a sensor with the name sensor.bewaesserung_pulses in my home assistant and it shows me the correct count.

Can someone help me with my problem?

Greets Denny

Why don’t you post your yaml including pulse counter…

What you have posted here would set a pulse counter called bewaesserung_pulses that is defined in your ESPhome config not something in HA, do you have a pulse counter in ESPHome? As @Karosm has said we would need to see the full YAML.

If it was me I’d store the value in flash to survive reboots, for resetting the total use a number component to enter the new value and a button to update. You may find some of my water meter config useful see this post.

When assigning something an ID, it doesnt get " ". Name can use " " but isnt necessary.

api:
  encryption:
    key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  actions:
    - action: set_pulse_total
      variables:
        new_pulse_total: int
      then:
        - pulse_counter.set_total_pulses:
            id: bewaesserung_pulses
            value: !lambda 'return new_pulse_total;'

Something else you can do is just create a button that zeros the meter, like this.

Create a Template button.

button:
  - platform: template
    id: zero_pulse_meter
    name: "Reset Pulse Meter"
    on_press:
      then:
         - pulse_counter.set_total_pulses:
              id: bewaesserung_pulses
              value: 0