My goal is to replace my openHAB2 installation. While doing this I want to see if I can replace HABPanel with the new openHAB pages.
This is what my current HABPanel page looks like:
This is an old screenshot so please don’t look at the alignment etc
It contains a background that changes based on the song that is playing on a Sonos device.
This was done with some custom JavaScript.
I am able to set the page background to a static image, however linking it to an item does not seem to work.
So this works:
Hi @joepadmiraal did you manage to get it working? also interested to perform same action, in my case I have a item type IMAGE already and would like to load that to the background directly…
I don’t think this is currently feasible. There are a couple of things going on.
style:
background: blue
works because when you use the style property, you are using css and blue is a valid css value for the background property to have. On the other hand,
style:
background: =items.bgItem.state
doesn’t work for a few reasons.
It doesn’t look like the style property of pages is processed through the expression parser, so you can’t use the same =expression that you can use in the widgets; this means there’s simply no access to OH item states for the style properties of a page.
Even if you could access OH item states, the state of the OH image item is not a valid css value for background; when using an image for a background the typical format is url(/path/to/image.file) not the image itself. If I recall, url(raw image data) will also work, but there’s another catch…
The state of an OH image is not the image data, but just a short MIME description such as raw type (image/jpeg): 36930 bytes the actual image data is stored in the rawState which I don’t think the widget items object has any access to. So there’s just no way to pass the raw image data to the css styles of the page.
You might be able to find a workaround with a lot of effort. One possibility is an external file. There are threads here in the forum about saving the image of an image item to a file. If you saved that image with a consistent name in the $OH_CONF/html folder, you could then statically link that file to the background property as: