#Gas meter hookup - where is the state kept?

1 messages · Page 1 of 1 (latest)

bright geyser
#

So I've been putting together something that can read my gas meter - I'm using a hall effect sensor with the meter, and that seems to read off pulses (great). Now, the energy panel seems to require that I provide it with a sensor which reads incrementally increasing consumption (gas readout as if I were reading the numbers). So I need to turn a pulse reader into something that can sum up consumption and expose that. I've been looking at some example templates:

sensor:
  - platform: template
    name: "Gas used"
    device_class: gas
    unit_of_measurement: "m³"
    state_class: "total_increasing"
    icon: "mdi:fire"
    accuracy_decimals: 2
    lambda: |-
        return id(total_pulses) * 0.01;

I do wonder however where the state for this is kept? Is it on the esphome node (seems unlikely), or in HA?

violet bane
#

you can add a total field to your esphome sensor, which is just a counter

#

or alternatively you can add a riemann helper in home assistant, I would personally put it on the esphome device

bright geyser
#

But then the state would be lost if there's an intermittent power issue?

twilit drift
#

Esp32s have persistent storage.
It also doesn't really matter, even if the esp reports 0 and then climbs back up, HA will treat that as a sensor reset in the energy dashboard and ignore it, as would any utility meters or the like based on the esphome entity

violet bane
#

the esphome side doesnt have to save anything

bright geyser
#

perfect

#

so the lambda gets executed in HA?

violet bane
#

Depends where you put it

bright geyser
#

I mean given the yaml declaration above