-
Notifications
You must be signed in to change notification settings - Fork 779
Add support for Image items in Sitemaps and Classic+Basic UI #1800
Comments
Yes, absolutely, there is even an ImageItem type, although I just noticed that this isn't listed in the documentation. The Paper UI already supports it and we should imho also add support in the Classic UI and the Basic UI. |
@kaikreuzer We should/could add that to the Sonos binding as well |
Is the ImageItem type alreaded supported by HABdroid ? |
No, feel free to enter issues for the mobile apps in their respective openHAB repos. |
@kaikreuzer : could give an example of how item and sitemap should be defined ? |
It would be great if |
Isn't it what is done in OH 1.x ? If not, what is done with the provided item ? |
So, we have to wait for Kai's explanation as he said that it works in Paper UI. |
Well, as there weren't any Image items in OH1, the (current) sitemaps do not support them. So adding support in Classic/Basic UI actually also means to add support in the sitemaps first (I adapted the issue title accordingly). I think the sitemap change is pretty straight forward: Instead of having the url mandatory, we require either a url OR an item to be specified. |
@kaikreuzer - In OH2, does the use case work where |
@watou Currently no, because the UIs simply do not support it. |
Thanks for resolving that question, @kaikreuzer. Could the StringItems' states, treated as URLs, be piped through the runtime just as the |
String item that eould be set to an URL + image element in sitemap. This will perfect for album cover. I have mo idea how is remdered image by UIs in OH 1.x (using url parameter). Do we meed an optional size to resize the image to a particlar size ? |
I think this is difficult, since "piping through the runtime" would either mean to sent the content as a state event (that's what is done for ImageItems) or to provide a specific servlet, where the runtime would serve the content. Both is not really easy to do and probably rather results in something ugly, especially if this is only meant to be a temporary solution. So I think there should only be the three possibilities:
No, I didn't introduce this in the sitemap and left it to the UIs and their layout/rendering decisions to scale images to an appropriate size. |
I don't recall any suggestion of using StringItems holding URLs as being a temporary solution; sorry if I missed that somewhere. As I said, there are a few bindings already that update items with image URLs, but there is no UI that can make use of them without If someone submitted a PR that implemented your option 2 but with proxying as is done for the |
Sorry, I interpreted "There are currently bindings that report image URLs" as "soon there won't be such bindings anymore" ;-)
Thanks for reminding me, this indeed completely escaped me. So this actually IS already the servlet option that I mentioned above.
If this someone is you, I would never ever dare to reject it ;-) Go ahead! |
Excellent! I'll give it a go. |
@watou @kaikreuzer : can we make a new step and adjust the sitemap syntax ? The Image element is already defined and as I understood we just have to make the url= parameter optional. @watou: is it already done or is it still something to be done ? Are you able to propose this change ? |
I mention here an interesting discussion in my PR for the Sonos cover art about the usage of RawType for image items and the lack of format indication that could help UI to render the picture. |
Just an idea: maybe we could add an optional "format" parameter to the Image sitemap element to help UI ? |
And another question: why is there a "web" and a "web-src" directories ? Shall I update only files in "web-src" ? |
|
No chance to just edit the source file in Eclipse IDE and then run from inside Eclipse ? I need to run "grunt" outside Eclipse after each file update ? Isn(t it something integrated in Eclipse that runs automatically when I run OH from inside Eclipse ? |
No, there is not. You can create a run configuration (there is a "Grunt" configuration type), which will basically call the same command from Eclipse. It still will need to be triggered manually. |
Just to understand, when I run "mvn clean install", it does not do all the job ? |
It does not. Client-side scripts and styles are assembled with grunt. It's not included in the maven build process (as far as I remember due to legal reasons — it requires getting clearance on lots of javascript libraries). |
Tu understand, where are in the tree the source files to edit and the files that are produced by grunt and then used at runtime ? Is it easy to install grunt on a Windows machine ? It looks more something for Linux... |
Sources are in /web-src, resulting files are in /web. You need to install node.js and npm first, Google can help with the rest. |
For testing purposes, if I copy smarthome.js from web-src to web, can it work ? |
It will work, but the changes must be validated by eslint (run from grunt) before being commited. |
Thank you for your explanations, I am now able to see the impact of my changes (I have copied smarthome.js from web-src to web and edited it in web). If only few lines need to be updated, maybe I can provide them to you so that you can propose a proper PR ? |
Now that I can edit and debug the smarthome.js file (cool, thank you @resetnow ), I can see that setValuePrivate is called as expected but with itemState argument having the value "raw type (unknown): 4387 bytes". It is the format output of RawType.toString(). As a remember, I only put the data URI in RawType.toFullString(). So I can't update the image as I would like in setValuePrivate as I don't have the new data URI. |
It's not really up to me right now. I mean it's technically correct and probably will work, you just need to confirm it with maintainers. |
@watou : a blank PNG would be OK. Will look for that in the existing code. Regarding support of my changes in Safari, I will not be able to check that myself, sorry. But I will check at least with Firefox and Chrome. |
I succeeded making the update of image working in Basic UI (only 2 minor changes are required) but there is still one case that does not work, when state becomes UNDEF and you have suddenly to display the default URL while it was ignored when initially building the page. @watou : I was asking myself if rather than bypassing the proxy, we could use the proxy even for images that are stored in image items ? The advantage is that there would be no change to do in Basic UI and Classic UI. But I have no idea if it makes sense and if it makesis doable for the proxy ? |
Sorry to share all my thoughts loudly lol |
Ok, the refresh of image in Basic UI is now working. |
In case no default URL is set, my idea would be that the proxy would return the none.png icon. What would be the URI to build that leads to this icon ? A relative path ? |
The ProxyServlet is not able to address an image that isn't referenced via |
You can encode 1x1 transparent PNG in base64. |
I had trouble making that work in Safari in #1106. See here. ...which might be an issue for this PR, if setting |
@watou : the current logic is mostly implemented by the ProxyServlet and hidden to the UIs. By the way, a minor update of the ProxyServlet will be required because if not it will lead to an exception (not valid URI). |
Why would the ProxyServlet need to be involved in using ImageItems' state to show images? There are no http[s] URLs involved in those items. If the client has hit the proxy servlet in order show an image from an ImageItem, then it's already on the wrong code path. What am I missing here? |
No, I don't want to inject ImageItem in ProxyServlet, it is hanlded outside the ProxyServlet and it is ok. My concern is no more the ImageItem but the default URL and more precisely how to handle the case it will not be set in the sitemap image element (and so not provided by the ProxyServlet). |
To be clear, I would like any UI to support all these cases for the sitemap image element:
And of course, there is still the refresh parameter to not forget. |
I have now something working in my 5 use cases in Basic UI and Classic UI. @resetnow : I installed node.js, grunt-cli and grunt. What is the command to run at the root of Basic UI folder ? I tried just "grunt" but it seems to do nothing, web/smarthome.js is not updated. |
|
Works now, thanks. |
PR now merged.. issue to be closed. |
Continuing the discussion from https://community.openhab.org/t/squeezebox-display-coverart/12072/4
The Squeezebox binding implemented image support (coverart) by retrieving the image from a URL and converting the raw image data to a RawType. Is this a supported use of a RawType? I remember reading in a comment that images were one of its intended uses, but is this still the case? Right now I do not think there is a way of displaying a RawType in any client. Also there may be some other issues with this, like how to know if the RawType is jpeg, png or gif for images.
The text was updated successfully, but these errors were encountered: