Display local images

No I have no item. Image is only defined in sitemap.

It works for me:

Frame label=“Bartek room” {
Image url=“http://localhost:8080/cameras/room.png” height=10 refresh=1000
}

room.png is stored on $OPENHAB_ROOT/webapps/cameras/room.png

Showing the local image is not an issue. But when you want to update file stays locked and you cannot rewrite it.
Any solutions for that?

Thanks!
Sasha

Bumping this thread as I’m also wondering how an image can be updated while OH is running. Seems like once it is loaded, regardless of whether it is actively being shown anywhere or not, you can’t update it without exiting out of OH.

I would like to refresh topic regarding openHAB2. In “old” openHAB there were $OPENHAB_ROOT/webapps directory and it works. In openHAB2 I cannot find such place. Do anyone know how to display local images in openHAB2?

I’ve tried a little bit and could get it working the following way:

  • place the image file in the conf/icons/classic folder of your openhab2 installation (see Iconset (where is in OH2?)

  • created the following sitemap entry:
    Image label="test" icon="camera" url="http://serverip:8080/icon/filename.png" refresh=60000'
    where you just have to change serverip regarding the ip of your OH2 server and the correct filename.

as an alternative you could also use the WebView Item in you sitemap:

Webview url="http://serverip:8080/icon/filename.png"

but there you go without the automatic refresh.

Hope that helps :slight_smile:

Yes that’s working. Thanks!

But it turns out that on the url address file extension is ignored and assumed to be only png is shown. I have tried even situation when I have to files: image.png and image.jpg and there is no difference in following lines:
Image url="http://localhost:8080/icon/image.png" refresh=60000'
Image url="http://localhost:8080/icon/image.jpg" refresh=60000'
Image url="http://localhost:8080/icon/image" refresh=60000'

in all cases image.png appears. Webview way won’t work neither for png nor for jpg:
Webview url="http://localhost:8080/icon/image.png"

Is there any other way to show .jpg files?

Yes, you’re right. I’ve tested it only with png, and jpg also doesn’t work here with me either. I think only png is supported as they say in the icons thread :unamused:

I ran into this file locking issue again after upgrading my openhab runtime to 1.8.3. @scooter_seh gets the credit for the ‘fix’ for this, but the issue is that the Jetty webserver has a default setting that locks files.

In the OPENHAB_ROOT/etc/webdefault.xml file, change the ‘useFileMappedBuffer’ setting to ‘false’ and restart the runtime.

Jetty’s website has more detail on this.

1 Like

Hello!

Do you know if there is a similar fix for OpenHAB2? Right now I’m using separate installation of Apache Web Server to accomplish this.

Best regards,
Davor

There is now an alternate approach possible in openHAB 2 (not 1.x) where your Image and Video sitemap widgets can have an optional item= that references a String item. If the item’s state is a URL, the widget will proxy to that URL instead of the mandatory-supplied URL in the url= parameter. Whenever the item referenced by item= changes state, the Class UI, Basic UI and mobile apps will show the image or video referenced by the item.

1 Like

Hello!

These are a really good news. Last thing I’ve heard was a discussion about safety issues with that approach. Didn’t know it was implemented in the meantime. Thank you for this information.

Best regards,
Davor

There are no new security issues with support for item= because it is a choice you make to include item= in your sitemap. Check out the demo configuration for an example. You could even implement a rotating display of security cameras by having a rule periodically update the item to point to the next camera in the list every X seconds. Of if a binding updates an item to be some dynamic URL only known via the binding, etc.

Hello!

I was referring to some old discussion between Kai and Chris, and Kai said using String item as Image URL was a security hole, so he rejected the idea. I haven’t looked at this solution for a pretty long time, since I’ve used Apache. Anyway, this is definitely much easier way to show dynamic images (i.e. Plex cover image). My home network is not open from the outside, so I don’t have that kind of concerns, it was just the reason it was not implemented before (the thread was from 2013 if I recall correctly). Once again, thank you for your help.

Best regards,
Davor

In openhab 1.8.3 you can place you .png or .jpg in the webapps/media dir. Make a new media dir inside there.

Put the folowing line in your sitemap

Frame label=“label” Image url=“http://serverip:8080/media/image.png” height=10 refresh=1000

serverip can be or localhost or your ip number. Both work.

I also tested jpg and png. Both did work. Also with android, and myopenhab it works.

1 Like

PMFJI, but have you really got a different JPG running, or the same JPG as the PNG (which is loaded instead)? I opened a thread yesterday to a similar problem, and just found this thread here, that first did not help me, but at least explained to me, why I cannot display the weather-warning map from DWD as an im.age (which I would prefer over loading it as a webview which is working - as the Image has a refresh value) in openHAB 1.8.3.

Using this Code in my sitemap:

                Text label="Wetterwarnungen" icon="light" {
                        Image url="http://www.dwd.de/DWD/warnungen/warnstatus/SchilderHA.jpg" }

I always get a broken link icon. The same Image works as webview. But as this Image is external, I have no chance to
get a PNG of it.

I have a sitemap with both a jpg and a png, different images, just to test this item. Both work. Also with myopenhab.

Hi, please can you point me in the right direction of where to find help or examples for this feature? - I have been scouring for days but cant find anything but I would like to proxy local webcam streams via OpenHab externally as my setup doesnt lend itself to making the cameras directly available externally - it sounds like this approach would work.

Thanks in advance.

See here and here.

.[quote=“watou, post:24, topic:2592, full:true”]
See here and here.
[/quote]
Thank you for the prompt response but maybe I am missing something? - the pages in the example all appear to be public facing rather than internal? - I did try the examples you linked to just in case but I still get the same symptoms and error.

To clarify, my issue is that I have a couple of camera streams that are on private address space (192.168.0.x) and I cant publish them onto the internet (I probably wouldnt want to either). I can get still images from the camera onto the OpenHAB server by using FTP but I would like a way to see the live stream. This works perfectly when I am at home on the same private network using this sitemap item;

Webview url=“http://192.168.0.123/videostream.cgi?rate=0&user=admin&pwd=password” height=10

However, when I leave home and hit the public internet, I can no longer get the streams and I see the following error in karaf;

18:29:48.258 [WARN ] [io.openhabcloud.internal.CloudClient] - Jetty request 435863 failed: null

Thanks in advance.