Hi there,
i’m using esphome with home assistant for a while now. My last project was making my watermeter a smart one. I used a wemos d1 mini an an inductive sensor on my meter and it works quite well. Since I made a few restarts of the wemos I discovered that my “total”-values were not stored. So I wanted to fix this but somehow I am doing something wrong.
This ist my esphome config file for the metering device:
esphome:
name: metering-esp
friendly_name: metering_esp
esp8266:
board: d1_mini
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "xxxxxxxxxxxxxxxxxxxxxxxxxxx"
services:
- service: set_total
variables:
new_total: int
then:
- pulse_meter.set_total_pulses:
id: watermeter
value: !lambda 'return new_total;'
ota:
password: "xxxxxxx"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Metering-Esp Fallback Hotspot"
password: "xxxxxxxxxxxxxxxxxx"
captive_portal:
sensor:
- platform: pulse_meter
id: "watermeter"
pin: 12
name: "Wasserzähler Durchflus"
unit_of_measurement: "liter/min"
total:
name: "Wasserzähler Total"
unit_of_measurement: "m³"
accuracy_decimals: 3
device_class: water
state_class: total_increasing
filters:
- multiply: 0.001
switch:
- platform: restart
name: "Restart metering-esp"
So this api service is not working and I don’t get it why. Do I have to define a helper in HA to retain the value and enter it for the “int” or anything other wrong? I read some other threads but still I did not figure out how it could work. My goal is to synchronize the value shown on the real meter and HA.
Any hints for me?