Display local images

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.

When using Image or Video sitemap widgets, the URLs behind them are proxied, so that their content is as network reachable at the openHAB UI itself. So you can see them from an openHAB Cloud instance just as you can locally. I have a proposal for doing this safely for non-sitemap-based UIs as well.

WebView widgets aren’t proxied.

Hi. I don’t want to open a new Topic. So I post here. I have tried all suggested ways here.
I cannot get a simple image work on the sitemap.
I am using the openhabian raspberrypi image which runs perfectly.
I am also able to run a stream from my ctronics security cam.

However I cannot get an image to be displayed on the sitemap. The image is in the /etc/openhab2/icons/classic folder and is named capture_motion.jpg
sitemap:

Image url="http://openhabianip:8080/icons/classic/capture_motion.jpg"   refresh=60000

I also tried webview, no luck. What am I missing?

Directories on disk do not correspond to paths in URLs. You might have success by using the given location for static HTML. Related advice here:

1 Like

Why have you put it there?

Put it in:
/etc/openhab2/conf/html

Then you should be able to access it from:
http://openhabianip:8080/static/capture_motion.jpg

3 Likes

on the raspberry openhabian os
the icons are stored in /icons/classic/.
/etc/openhab2/conf does not exist.

However I finally managed. I found out the the url of the standard icons in the browser is
http://openhabianip:8080/icon/sofa.png
and if I put the picture test.png in the folder:

/etc/openhab2/icons/classic/test.png

i can use it as an icon.

I changed the sitemap to:

Image url=“http://openhabianip:8080/icon/test.png” refresh=60000

and it works.

The pictures have to be in /icons/classic
but you have to use icon/ in the sitemap.

Also only small letters work. No capital.

1 Like

If it’s not an icon file (which it doesn’t appear to be as you’re presenting the image with the Image sitemap widget) then correct place would be /etc/openhab2/html then.

The URL I mentioned should still apply.

2 Likes

You are absolutely right Daniel. I was not able to display jpg files my way.

With yours it works fine. Thank you very much.
I should have listened to you before. My apologies.

I know this is an old conversation, but I ran into my images getting locked by OpenHAB on my Windows machine running OpenHAB 2.2.0. I started using HABPanel to display my images on a wall mounted tablet, and as a result, my images were getting locked.

In the OPENHAB_ROOT/runtime/etc/jetty.xml file, I set the minMemoryMappedContentLength value to -1. Here is a snippit of the xml.

<Get name="handler">
		<Call name="addHandler">
			<Arg>
				<New class="org.eclipse.jetty.server.handler.ContextHandler">
					<Set name="contextPath">/static</Set>
					<Set name="handler">
						<New class="org.eclipse.jetty.server.handler.ResourceHandler">
							<Set name="resourceBase"><SystemProperty name="openhab.conf" />/html</Set>
							<Set name="directoriesListed">false</Set>
							<Set name="minMemoryMappedContentLength">-1</Set>
						</New>
					</Set>
				</New>
			</Arg>
		</Call>
	</Get>

Seems like they are after OpenHAB 1.5

I just recently moved to 1.8 and delayed this for a long time.

The Mobile Android App and GreenT UI (yea)

get something like this URL

src=“http://myhob:8080/proxy?sitemap=doma.sitemap&widgetId=000900

instead of the url in the sitemap definition:

Webview url=“http://192.168.5.8/icingaweb2/” height=10

To be strange, in the classic UI the URL is OK.

Proxied webview has problems with CSS at least. This break a lot of stuff for me now

1 Like

This worked for me