I’m using image card to show photo on the page. Photo is generated daily (by Powershell script and copy to /conf/html/ folder and renaming to Photo01.jpg).
I’m using Edge as browser and brower still keep old photo in the cache ans OpenHab shows still the same photo In private mode of the Edge I see new photo.
I tried to change “Refresh Interval” of image card but it dosn’t effects
Any idea how to solve this problem?
This is pretty standard browser behavior. Any page would show the same issue when you changed the contents of an image file. The browser is simply not constantly watching the contents of the file and has no way of knowing that it has changed unless you tell it to reload the page.
There are a couple of oh based solutions. The best world be to change your script so that, instead of saving a file it uses an API call to update an image item with the image. Then oh will automatically change the displayed images when the item gets changed.
It would also work (although be a little more complicated) to change not just the contents of the image, but also the name of the image file in a way that both your script and oh can do consistently, such as add the date the file name and have a rule that updates a string item with three new files name at the same time.
Thank you JustinG.
What do you mean “it uses an API call to update an image item with the image”? Which API- OH or any other API you mean?
I mean the OH API. There are specific API endpoints that you can use for sending commands or state updates to items which allow non-core applications to work with OH data. This is even how the UIs including the MainUI work. The core program runs separately, and the UI sends and receives data using the API.
If you are not used to working with APIs in general or OHs API then there are other options for sending information to an item as well. You could look at using an MQTT broker, or the webhooks binding. All of these are examples of how to connect some general outside information to OH which is ultimately the “most native” way what you want to do.
I’m sure there are also ways outside of OH to bypass your problem as well. There are probably browser extensions you can use that will reload a page at a certain time for example.
Thank you so much JustinG! As I see I can call REST API of OH also directly from PowerShell.
I will share with community my solution soon (I hope )
I believe it can also be done with the new command item that 4.1 brings as a new feature. SEE release blog for 4.1 on how you can navigate and refresh the main UI from a command item.
Another trick is to use a URL with a query at the end like this…
You can change the file and when the web browser does a refresh it sees the query has changed due to the timestamp. You do not need to change the filename it self, yet I hear this trick will work.
That’s a much more clever url trick than what I proposed. I love it!
EPIC! It works! Simpler=better! Great idea!
Thank you so much!
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.