Is it possible make a sensor that takes the current value of another sensor and compares it with the state of the same sensor an hour back in time?
I want to see if the temp in my house has gotten colder or hotter compared to an hour ago and also for the sensor to show the difference in +C och -C. Even better would be in green color or blue color depending on positive or negative.
I have tried using the binary_sensor but I’m not getting any good results and I dont even know if it would do the job as I want it to show in the end.
Since I’m using a pretty small tablet to view everything in the house I’m just interested in a small single value sensor that doesnt take much space. I’m using influx/grafana and have a couple of graphs through a panel_iframe there but in this particular case I just want a number that fits my already overwhelmed dashboard
since we already can subtract a sensor value from another sensor, all we need in this case is to fetch or store a value every hour to be used for subtraction. I guess this can be done with an automation of some sort. I just wondered if there was some kind of complete solution or component that I have missed. It would be a very nice feature to have in a monitoring system, seems pretty standard to me also
What if I make an input_number sensor, how can I then use it in an automation to store a value from an existing sensor in it?
If I can achieve this then I think the case is solved with a template sensor:
“current-sensor” minus “input_number sensor” that gets its value stored with the automation every hour.
This would give you the change over the defined period (and some other statistics) as attribute which you can then use to create a template sensor. Something like this:
wow, this seems to be exactly what I’m looking for. I’ll give it a go tonight!
Nickrout: I’ve tried that one, firstly I’m doing something wrong and cant get it working correctly… but secondly I dont think it returns a calculated value back like I want. It only gives a trend “up” och “down” value I think?
I would use influxdb sensor to retrieve the value from 1 hour ago and then a template sensor to find the difference between current value and old value.
I stumbled over this post and I’d be really curious what that code looked like on your end.
I got a similar idea, but not with temperatures.
I’d like to record the daily change of the corona virus infections compared to the day before.
My code currently looks like this:
Actually my two sensors also happen to return unknown since a few weeks ago, I havent had the time to investigate it but now I’m almost wondering if it has something to do with the later versions…? I’ll write here if I find the time to check