Best Practice for reading file-system items

Still kinda new to OH.

I have a number of items that I want to read from various systems and databases in my house. I don’t want to pull the values every screen refresh.

Is there some filesystem best practice other than putting the values on the file system and reading them as needed with EXEC? I’m just using a script that runs every 10 minutes to get fresh values and write them into a file that openhab has access to that returns a value with CAT.

I realize I could probably use a more specific binding for each item (like 1wire, serial, etc.) but right now my system for grabbing the values works - just wondering if EXEC is the best way to display them.

Thanks as always for any help!

You could push the new values to OH using curl in your script and the OH REST API instead or writing the values to a file. That would be closer to a best practice when it comes to OH.

Beyond that…

OH does not poll for new values on every screen refresh. Each Item gets its value depending on how it is configured. For example, an HTTP or Exec bound Item could be set up to poll for a new value every so many seconds or minutes whereas an MQTT Item will have data pushed to it. Each Item is configured independently so you can have one poll for new data every 10 minutes and another every 10 seconds.

The sitemap polls OH for each Item’s current value on every refresh but that does not cause the Item to go out and poll its binding for a new value. Both are completely independent. So if that is your concern you have nothing to worry about.

So, an actual best practice would be to configure each Item to poll for the value themselves using what ever mechanism makes most sense for that interface (e.g. you may have a shell script executed with the Exec binding for one and an HTTP REST call for another and a specific binding for a third) and configure each binding to poll on your preferred interval.

Hi Rick!

Thanks again for the great answer. I was just out for a run and thinking that there must be a refresh timing setting on the items. I’ve probably seen it, but still drinking from the firehose - my method of learning is to try to accomplish something, and later realize there are several better ways of achieving the same result. I’ll have to think about the architecture of how I want to set things up more thoroughly now that I understand better.

Oops - sorry, Rich!

No worries. You are not the first to use “Rick” and I grew up using that nickname so its all good. You are the first to catch the difference though, or at least admit it. :slight_smile: