Syntax Help for String Item whose state is a URL

I’m working with a video feed from an IP cam and the instructions in this link have this line.
http://docs.openhab.org/configuration/sitemaps.html#element-type-video

  • item can refer to a String Item whose state is an URL to a video. Some clients may not (yet) consider item.

Everything seems to be working fine in the BasicUI but I’m getting an ERROR 404 in my HABPanel widget.
Please don’t laugh but here is my attempt at creating an item whose state is a URL.

String Camera1 "Camera1 [http://10.240.XXX.XXX/mjpg/video.mjpg] "

Can someone give me an example of using a URL for an item state?

You attempt created an Item with a URL in its label. To change the Item’st state you need to bootstrap the state by postUpdate or sendCommand. So your options are:

  1. Create a System started rule and call Camera1.postUpdate("http://..."). If you have persistence with restoreOnStartup on this Item you can remove the System started rule once Camera1 gets its initial value.

  2. Make sure Camera1 is persisted with restoreOnStartup and send the URL to it using the REST API. You can do this straight from the REST API Docs (installable under the Misc tab in PaperUI)

Hi Rich

Thanks for the super fast response.
I’m so confused now because if I only add the following to my sitemap it works but creates all kinds of errors in the logs.

Frame label="Cameras"{
           Video item=Camera1 url="http://10.240.195.79/mjpg/video.mjpg" encoding="mjpeg"

Here is the log file output when I comment out the item from the item file.

2017-07-26 16:29:26.075 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'Camera1' for widget org.eclipse.smarthome.model.sitemap.Video
2017-07-26 16:29:26.081 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'Camera1' for widget org.eclipse.smarthome.model.sitemap.Video
2017-07-26 16:29:26.080 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'Camera1' for widget org.eclipse.smarthome.model.sitemap.Video
2017-07-26 16:29:26.086 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'Camera1' for widget org.eclipse.smarthome.model.sitemap.Video
2017-07-26 16:29:26.086 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'Camera1' for widget org.eclipse.smarthome.model.sitemap.Video
2017-07-26 16:29:26.087 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Video
2017-07-26 16:29:26.088 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Video
2017-07-26 16:29:26.092 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'Camera1' for widget org.eclipse.smarthome.model.sitemap.Video
2017-07-26 16:29:26.096 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Video
2017-07-26 16:29:56.509 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'Camera1' for widget org.eclipse.smarthome.model.sitemap.Video
2017-07-26 16:29:56.520 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'Camera1' for widget org.eclipse.smarthome.model.sitemap.Video
2017-07-26 16:29:56.523 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'Camera1' for widget org.eclipse.smarthome.model.sitemap.Video
2017-07-26 16:29:56.527 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'Camera1' for widget org.eclipse.smarthome.model.sitemap.Video
2017-07-26 16:29:56.529 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'Camera1' for widget org.eclipse.smarthome.model.sitemap.Video
2017-07-26 16:29:56.530 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Video
2017-07-26 16:29:56.533 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Video
2017-07-26 16:29:56.536 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item 'Camera1' for widget org.eclipse.smarthome.model.sitemap.Video
2017-07-26 16:29:56.543 [ERROR] [ui.internal.items.ItemUIRegistryImpl] - Cannot retrieve item for widget org.eclipse.smarthome.model.sitemap.Video

If I use only this in my items file all errors go away.

//Camera items
String Camera1 "Camera1"

The reason I added the URL in the item label is because the item state documentation found here said that’s where the state is defined.

I think the first thing I need to figure out is when the openHAB documentation mentions an item state talking about sitemaps is it the same as the item state when it’s talking about the items file?


You would benefit from going through the Beginner’s Tutorial and the Intro parts of the main docs.

I think you do not yet understand the various parts of OH and how they work together.

To refer to an Item in a sitemap or anywhere else you must define that Item in a .items file or through PaperUI. The errors were caused because you did not have Camera1 defined anywhere.

An Item has a state. What that state is depends on the type of the Item. A String Items has a string of arbitrary characters as its state.

The only way to set an Item’s state is to postUpdate or sendCommand to that Item as I described above. You cannot set an Item’s state in the .items file nor can you do it in the .sitemap file. You must use one of the two options I listed above to give your Camera1 Item a state.

The documentation you point to about State is referring to how the state of the Item gets presented as part of its label on the sitemap. It is strictly for presentation. You cannot set the state in the .items file.

Hi Rich

I took your advise and went through the beginner’s tutorial as you mentioned, it was informative but didn’t help much on this.
I was able to figure out how to set the items state by persisting Camera1 with restoreOnStartup but I can’t tell it did anything different from just adding the item and adding it to my sitemap.

It shows up and displays the camera feed for 60 seconds then drops. I can get it back if I refresh the page but since I turned on persistence for the item and changed it’s state from NULL to http://10.240.195.79/mjpg/video.mjpg shouldn’t that stay active?

The problem described is unlikely to be an OH problem but a problem with your web browser or your network.

The only thing that could potentially be a problem caused by OH is if the Camera1 Item’s state is being changed after 60 seconds. You can see this by looking in events.log. If you don’t see Camera1 being changed in events.log, the problem is outside of OH.

I can’t say where the problem is but I can say the feed works just fine in the browser when I go directly there.
And it works fine in the HABPanel.
It doesn’t keep working in the basicui on Chrome or FireFox on both a Win 7 or Win 10 computer.
The camera’s state isn’t being changed according to the logs.
Guess I’ll just stick with using the HABPanel for now. Thanks again for all your help and info.