Not sure how to do what your asking, however the ipcamera binding has a feature that may be of interest. This is the autofps.mjpeg stream it can serve. This will serve one frame every eight seconds until the camera detects motion and then it ramps to 1fps until the motion stops. This is handled automatically and a mjpeg stream is just made up of snapshots, the eight seconds is because web browsers assume the stream is broken if the space is longer then this.
If your camera does not have support for motion detection built in, you can trigger this with any external zwave or other motion detection device that you can use in openhab. You can also use ffmpeg to detection motion and change the rate.
Hope someone helps with your question, but thought I would throw another way to achieve your end goal in case you or someone else is not aware this way exists.
refreshInterval does accept expressions, and there is no theoretical reason this code should not work. So, there is something else going on. Some things you can check to try and find out what’s going on are:
Are you sure that light is the name of an item? If that item state doesn’t ever equal “ON” then you’re always going to have 1000 seconds between refreshes.
Do you see any errors in the browser console when you bring this widget up?
Are you sure that your image source is changing that rapidly?
So I tested this approach as well and yes the regx is valid and it will evaluate the change but I am not sure that it will work as that refresh interval is only set on page load or on a page refresh.
look at your browser development tools and inspect and you can see exactly what is happening.
If you meet the condition and the state changes and then you do a page refresh the refresh interval does in fact change/update for that image card.
Thanks. So I have to refresh to whole page? Hm, this is not good. How could I do this?
I have many items, sliders, bars, graphs etc on this page and e.g. a power chart is updated every 5 mins by an item timer, which works fine. So the refreshInterval can’t be updated like all the other items and elements?
What I am not clear on is why you need to change the refresh interval? why not just leave it at the faster rate. Are you trying to save system resources? The rendering of a static jpg should not be that expensive I would think.
ok I understand your desire just not the rational. I guess you could puzzle out some rule that may trigger a page reload at the same time as the item state changes but that is definitely going to be a resource expensive approach. Even that is iffy at best since the client browser session may not honor a refresh /reload request.