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.
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:
I don’t think this is currently feasible. There are a couple of things going on.
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,
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: