Your advices are always appreciated! Thanks a lot Rich. I will definitely do so.
Just to clarify: you can use all this with your existing *.items files.
True but itâs so much work and so easy to get wrong as to hardly be worth it.
Back to the original question, easy and somewhat direct method to get what you want (that has many reasons itâs not the most elegant way).
Tie your binding to an item. Make a second item that is the rounded value. Run a rule that updates the rounded item whenever the bound item changes. Trigger all your interesting database stuff off the rounded item. Means you still have access to the raw value, but youâre only firing rules and database persistence off the reduced precision item.
Although Rich said it, I donât think the point was made strongly enough. Youâre using influx db. This is a time series database specifically designed for data series like weâre talking about here. You can set retention policies that downsample a measurement into averages and use less space on disk over time. Be more aggressive in your policy if itâs a major concern for you.
That being said, I donât think this is a problem worth solving. Of course youâre welcome to disagree and do whatever you want, but make sure itâs worth your time before trying too hard. I suggest doing some math estimates before deciding itâs worth solving. How many bytes does a measurement (or row in the db) take up on disk? Given a measurement per minute, how long would it take to fill a megabyte? How long for 100 megabytes? A gigabyte? Then determine how much data is too much for this particular item. Disk space is very cheap these days and your time is worth at least something. How much of your time is it worth spending to do what you asked about in the OP vs some alternative solution. The right answer could be to not worry about it, or to wipe the table once every year, or to just buy another hard drive or clear off some unused files on the existing one.
Iâm super curious whether youâll still feel the problem is worth solving after considering what I wrote here. Please do share your thoughts when you have a chance!
This would be a solution. Thanks for sharing your idea!
Hi Jonathan, youâre right. In the particular case I came up with it might not be worth solving it the way I was intended to do. I thought there might exist a kind of formatting that I missed to just lower the precision.
I have other data points that fire a trigger every second (and yes even this might not be worth thinking about it - Iâll do the math) so it was good to learn about retention policies in influxdb.
So thanks everyone for the valuable input!