I want to use an ESP8266 for reading an Watermeter with an impulse Sensor.
For each 1 L of water, the sensor will send one pulse…
So far, I already have my configuration…
esphome:
name: watermeter
friendly_name: WaterMeter
esp8266:
board: d1_mini
restore_from_flash: true
early_pin_init: false
# Enable Home Assistant API
api:
encryption:
key: *********
sensor:
- platform: pulse_counter
pin: GPIO13
update_interval : 1s
name: "water pulse meter cold"
id: water_pulse_meter_cold
device_class: water
state_class: total_increasing
total:
unit_of_measurement: 'l'
name: 'Water Meter Kaltwasser'
filters:
- multiply: 1 #(1 pulse per liter)
binary_sensor:
- platform: gpio
name: pulse_counter_eg_input
id: meter_eg_reading
internal: true
pin:
number: GPIO13
on_press:
then:
- light.turn_on: meter_eg_reading_light
on_release:
then:
- light.turn_off: meter_eg_reading_light
light:
- platform: status_led
id: internal_led_light
name: "Internal LED Light"
pin:
number: GPIO2 # LED at Wifi module // // Also available on PIN D5
inverted: true
- platform: status_led
id: meter_onboard_led
name: "Meter-Onboard-LED"
pin:
number: GPIO14 # Onboard LED "SCK" // Also available on PIN D4
inverted: false
- platform: binary
id: meter_eg_reading_light
internal: true
name: "MeterReading-LED"
output: light_eg_output
output:
- id: light_eg_output
platform: gpio
pin: GPIO0
captive_portal:
It is working well so far - BUT:
I would like to implement the sensor into the energy dashboard, and noticed the following:
Whenever the ESP is rebooting, the meter_counter will be reset to zero.
How could I make the sensor value “persistent” in case the ESP does reboot, or similar?
Or doesn’t it matter if the sensor will be reset to zero?
I found a similar approach recently - but after testing, I have to say that it was really slow…
The values of the meter didn’t change “directly” after simulating the pulse… sometimes, it took several seconds and multiple pulses until the sensor value was updated in HA…
Therefore, I was not sure how reliable this approach will be in the end - but I will try it.
→ Sure, since I am using “total_increasing” as state class, HA will take this into account and measure the values accordingly… maybe, I will create another sensor / helper within HA to make a persistent counter (to keep track of the total count)