Hi there,
I have a similar problem like in this older post
I have bought an ESP32 reed sensor measure water consumption. I never really got it work properly, Despite setting different initial values in the developer tool, it still would start with the value I used for testing first (ca. 3.590m3 instead of currently 1.170m3).
Here is the configuration yaml. Could you kindly help me with that? And yes, I am not really a pro in HomeAssistant…
esphome:
name: meter-3644 # unique identifier
esp32: # MAC: 88:56:A6:5C:36:44
board: esp32-c3-devkitm-1
framework:
type: arduino
preferences:
flash_write_interval: 6h # save every 6 hours
ota:
- platform: esphome
password: "uLo8teip"
wifi:
output_power: 10db
ssid: "dummy" # Wi-Fi SSID
password: "dummy" # Wi-Fi password
ap:
password: "EeYaigh4" # fallback access point password
captive_portal:
api:
encryption:
key: O+wPZAwIexKiT9nxVXSsEqfbXA0M9m4NRXUU6bOU+is= # https://esphome.io/components/api.html
globals:
- id: pulses
type: int
restore_value: yes # restore value after reboot (yes)
initial_value: 1150.170 # inital value (0,0 m³)
binary_sensor:
- platform: gpio
id: pulse
internal: true
pin:
number: GPIO0
mode:
input: true
pullup: true
name: Pulse
filters:
- delayed_on: 10ms
on_press:
then:
- lambda: id(pulses) += 1;
sensor:
- platform: template
name: Water
device_class: water
unit_of_measurement: m³
state_class: total_increasing
icon: mdi:water
accuracy_decimals: 3
lambda: return id(pulses) * 0.01; # meter multiplier (0,01 m³)
update_interval: 60s
- platform: homeassistant
name: Offset-water
entity_id: sensor.meter_3644_offset
id: offset
on_value:
then:
- globals.set:
id: pulses
value: !lambda 'return int(x);'
web_server:
port: 80
local: true
logger:

