BasicUI image caching (webview svg)

Hello,
just one quick how to (if anyhow)
I have a script which generates picture with shadows of the house based on sun/time. It’s saved as static file in OH, every change.

In the version 3.x Images shown on basicUI has been automatically refreshed
In the 4.x seems they are cached and to view changes I need to hit hard refresh in the browser.

I’ve seen solution in here

Is there any other way how to make dynamic image on UI refreshed?

Did you try the refresh option?

I send images via MQTT to the oh-image-card.

I have an item set as an image type.

I have a script that sends a webcam image every minute via MQTT and I get the image from zoneminder security software.

#!/bin/bash
LOCATION="/var/www/html/weather/WEBCAM"
curl -s  "http://192.168.1.139/zm/cgi-bin/nph-zms?mode=single&monitor=6" --output $LOCATION/image.jpg
mosquitto_pub -h 192.168.1.164 -t jedwood/raw/weatherimage -f "$LOCATION/image.jpg"

NOTE the -f in the mosquitto_pub command.

ah i forgot to mention is svg, so I’m using webview for it, as Image would not work

Webview url="/static/shadow.svg?{{itemValue('Sun_Azimuth')}}" icon="none"

and looks like there is no refresh param

If you can change the source check this out:

well the difference is, that he is calling html which refreshes itself.

but I’m calling svg, which refreshes itself, but webview does not care. Not sure if those are the same things.
I need to digout if svg has got some expiration header or smthing like that.

(again. in older version of OH this worked just fine …)

Webview is implemented in Basic UI with iframe. The src attribute of this iframe is set when opening the page and then never updated. I don’t see how the content of the iframe could have been automatically refreshed in the past by the app itself. And no change was done for this element.

Maybe a behaviour change in the browser you use?
Are you still using the same browser and what browser?

I would suggest you rename the thread to mention webview.

If I recon it correctly, it was updated when page got loaded, not automatically each minute.
What’s different now is that content is not updated till hard refresh of the browser.
And this svg is not on the main page, so shall be update everytime I go into the subframe.

Later today I’ll run OH3.x again to see if it is browser issue or something in the OH4

Am using still same browser for ages in the iPad which controls whole house, so this has not changed. Also on all of my computers with various different browsers it acts same.

My thinking is, maybe browser see this as static values each time? (not sure how OH interprets item values) so it’s not random number each change, but always the same name - therefor cached by browsers by default?

Frame {
				Webview url="/static/shadow.svg?{{itemValue('Sun_Azimuth')}}" icon="none"

note: updated topic name

I even do not understand your syntax. You request a SVG image passing to it parameters ? This is something possible ? What do you expect exactly with “?{{itemValue(‘Sun_Azimuth’)}}” ? “itemValue” comes from where ?

yes it is and yes it’s really working for quite time already :wink:

In the very first post of this thread there is a

The ?{{itemValue(‘Sun_Azimuth’)}} ensures that the SVG gets refreshed automatically as the azimuth changes.

so this probably changed in OH4 and it’s no longer called with the number and that’s why it’s cached by default.
:thinking:

I can try to pass random number somehow, but since it will be helperItem again, it will probably act same.

You expect itemValue as being an existing JavaScript table provided by the JavaScript of Basic UI ?
This table does not exist in smarthome.js and I clearly do not remember to have removed it in the past.

What browser do you use to view the sitemap, and what version of OH4 are you on?

I’m experiencing the same, whilst using a prepared weather image as a background in a widget:

  background:
    - component: oh-image
      config:
        refreshInterval: 600000
        url: /static/dynamic/wetter_resized-cropped.jpg

Starting the UI (using Chromium on Ubuntu) it will always first load the cached image. I remember not having this issue before, not sure since when exactly this happens. Could be since version 4.x. I’m currently on openHAB 4.1.1 - Release Build

Not being able to find an option in Chromium to clear all cache on exit makes it worse :wink:

It was really working in the past… But I can’t really tell if that was just coincidence or really because it was called with actual number.

Anyway, if we probably found why it’s being cached. Is there a way how to call it with some parameter?

I can indeed do rule to populate any item, or something else with random number each time, but the question is how it will be translated in the BasicUI? eg. how to write it properly on the sitemap.

eg.

/static/shadow.svg?3533

thoughts?

First, I would like to understand what you were doing and learn about that. I am not familiar with this syntax of HTML URL “/static/shadow.svg?{{itemValue(‘Sun_Azimuth’)}}”. How should a browser handle the part “{{itemValue(‘Sun_Azimuth’)}}” ? Is it supposed to interpret something ?

It’s the HABPanel angularJS syntax. It looks like it was even taken from a HABPanel thread. I can’t imagine that it has any actual function in the sitemap webview.

OH shall pass value of the Sun_Azimuth, which is number so output of this for the brower was

shadow.svg?233

and next minute

shadow.svg?234

as Azimuth changes constantly.

Then browsers are not seeing image as cached because name is different.

A Webview element is currently attached to no item, that is the initial point so you can’t expect a refresh based on an item update. If something should be implemented to add refresh capability to the Webview element, certainly it will not be with such exotic syntax. We should imagine something that will be intuitive and consistent with what exists for other sitemap elements.

Please open a feature request in GitHub - openhab/openhab-core: Core framework of openHAB explaining your need of a refresh feature for the Webview sitemap element. Then this will be discussed with all the maintainers. This new feature will require changes everywhere, core framework for sitemap syntax extension and updated sitemap REST API, Main UI for the sitemap generator and of course all sitemap UIs (Basic UI, Android app, iOS app).