Is there a way to limit the precision of Number-Items?

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.

1 Like

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!

1 Like