g1mli
(Denny Maag)
January 10, 2025, 2:20pm
1
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
Karosm
(Karosm)
January 10, 2025, 2:47pm
2
Why don’t you post your yaml including pulse counter…
EBME2
(Ebme2)
January 10, 2025, 3:38pm
3
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.
Slightly different sensor on my meter, mine is an Itron Cyble sensor which from memory like the OP’s stated up to 30v, rather bizarrely and I’m not sure how this works but mine is supposedly not polarity dependent, I think it has an internal 10 year lithium battery. I was more interested in counting total pulses but did use pulse meter, for completeness my code is below.
esphome:
name: water-meter
friendly_name: water-meter
on_boot:
then:
- pulse_meter.set_total_pulses:
…
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