I tried localhost, 127.0.0.1 and the dynamic dns address that I have set up. None of those worked but using the 192.168.2.37 address that is assigned by my router lets all the other functions of the binding work except getting the cover url. I did have to add 192.168.2.37 to the list of IPs that can bypass authentication in Plex. Just to be clear Plex and OpenHAB run on the same PC so I expected localhost to work.
I’ve managed to get a cover URL in the String item, but the only way to use it (as far as I know) is making a web page with javascript that will retrieve URL from the item, insert it in the img object on the web page and then display that web page in the Webview widget. I’ve tried that approach, but it doesn’t look nice, so I’ve ditched it. Regarding the information I’ve found on this forum and OpenHAB github, there is no way to use dynamic URL for the Image or Webview widget (security issues), and you can’t replace static image once you open it (you need to restart OH server), so, I guess, the web page approach is the only one at the moment.
just tested on a PI3 with OH2 latest snapshot and it’s working. Web ui doesn’t refresh automatically (I think it is a known problem anyway) so you have to manually refresh in order to display a new cover.
Thank you for the information. I actually haven’t tried doing it from the rule, but I’ve tried simply replacing the file in Windows, and it wouldn’t let me do it. I’ll try your approach, because it looks much better to have the cover in Image widget, than displaying web page in Webview widget.
No openHAB/ESH UI currently does anything with the item= attribute on an Image widget in the sitemap, but it would be great to finally add support for string items providing the URL dynamically to the image to display. This would make the url= attribute optional. In ESH, there is a new Image item that is to contain raw image data, but I see potential issues tunnelling this through HTTP instead of using HTTP as the native transport.
I think both should be supported: Image item=StringItem would interpret the item’s state as a URL, but proxy the image through the server so it can be viewed everywhere that the current url= attribute does. Whenever the item’s state is changed or the refresh cycle has come around again, the image would update in the client. There are a few more bindings besides the Plex binding that could immediately benefit from this enhancement.
Image item=ImageItem would convey the raw image payload to the client as it changed, but would ignore the refresh= attribute as it would be meaningless.
I just spent the best part of a day getting something to work and Rod’s ‘rules’ nearly worked but I’m on osx and no wget caused me no end of problems (until I found out no wget on osx). So instead this does work:
rule "DownloadPlexcover "
when
Item PlexPCover changed
then
executeCommandLine("curl -o /Users/richardjohn/openhab2/conf/html/Plex_Cover.png " + PlexPCover.state.toString
)
end
rule "Download Spotify Cover "
when
Item Spotify_urlCover changed
then
executeCommandLine("curl -O/LightEASY/conf/html/CoverSpoty.png " + Spotify_urlCover.state.toString)
end
but no work