Allright, I hope you guys can help me with this. I have set up a binary_sensor using a GPIO pin:
- platform: rpi_gpio
ports:
5: Water meter
Now what this does is, everytime 1 liter of water is used it goes On and then Off again. Currently what I did is create a counter and have an automation increase the counter by 1 everytime the sensor is triggered from Off to On.
I bet there’s a much better way because I would like this as a numeric sensor. So that I can plot graphs of the water usage and such. I have looked into the template sensor but I feel like I am missing something very simple.
Hmmm it says that it can track “how long a sensor had a specific state in a period of time”. I want to count how often the state ‘on’ was achieved. So sensor type ‘count’ would seem good. I’m just not sure as to how I can make it show in blocks of 1 minute.
if you just want the count in the last minute, change the duration to only look at the last minute and specify the end. The documentation mentions that you need to specify exactly 2 of the following paramters: start, end, duration. Not all 3.
When you configured it this way, you’re saying ‘start at the begining of time’. Begining of time in computer speak is jan 1st 1970. So in this configuration you essentially said “Look at the the minute between 00:00:00 and 00:01:00 on January 1st 1970”.
start: '{{ 0 }}'
duration: 00:01:00
When you configured it this way, you’re saying ‘start at the begining of the day’, because 0 hour, 0 minute, and 0 second is midnight.
So the proper configuration to solve your problem would be: (this will tabulate data based on your startup, i.e if you started up at second 14, this will tabulate every time the time hit second 14).