Set value of counter / get changes of counter per day

Hello!

I made a counter to count how often a window-sensor was closed. I’m using this to measure gas consumption on a gasmeter which uses a magnet to show when another 0,01m3 gas was used.

So I have a window senser, a counter as a helper and a small automation which is incrementing the counter everytime the window sensor closes. This works so far, but I got 2 problems:

  • I want to set the counter to the current value of the gasmeter. So I went to developer tools → entities → states and changed to state of the counter to the current value. But the problem is that the next time the window sensor closes, the value is resetted to the value before (incremented by 1). So if I got 11, changed the value to 22.000, it gets incremented to 12. Why I can’t change the value this way?

  • How can I make a template which contains the number of increments the counter has done today or yesterday?

You may want to take a look at the DIY Rain Gauge thread for an example of how to use a combination of built-in integrations like History Stats, Template sensors, and Utility Meter to convert “pulses” from a door sensor into other units.

1 Like