How-To: Display Kodi cover- and fanart in HABPanel

Everything else is working fine

Things

kodi:kodi:libreelec				"Kodi"			@ "Living Room" [ipAddress="xxx.xxx.x.xxx", port=9090, httpPort=8080]

Items

Switch Kodi_mute          "Mute"            <soundvolume_mute>       { channel="kodi:kodi:libreelec:mute" }
Dimmer Kodi_volume        "Volume [%d]"     <soundvolume>           { channel="kodi:kodi:libreelec:volume" }
Player Kodi_control       "Control"               { channel="kodi:kodi:libreelec:control" }
Switch Kodi_stop          "Stop"                  { channel="kodi:kodi:libreelec:stop" }
String Kodi_title         "Title [%s]"            { channel="kodi:kodi:libreelec:title" }
String Kodi_showtitle     "Show title [%s]"       { channel="kodi:kodi:libreelec:showtitle" }
String Kodi_album         "Album [%s]"            { channel="kodi:kodi:libreelec:album" }
String Kodi_artist        "Artist [%s]"           { channel="kodi:kodi:libreelec:artist" }
String Kodi_mediatype     "Mediatype [%s]"        { channel="kodi:kodi:libreelec:mediatype" }
Image Kodi_thumbnail      "Thumbnail"             { channel="kodi:kodi:libreelec:thumbnail" }
Image Kodi_fanart         "Fanart"                { channel="kodi:kodi:libreelec:fanart" }

Sitemap

sitemap kodi label="Kodi"
{
    Frame label="Kodi" {
		Switch item=Harmony_Activity label="Kodi on/off" mappings=[ PowerOff="PowerOff", Kodi="Kodi" ]
        Switch    item=Kodi_mute visibility=[Harmony_Activity == Kodi]
        Slider    item=Kodi_volume visibility=[Harmony_Activity == Kodi]
        Selection item=Kodi_control mappings=[PLAY='Play', PAUSE='Pause', NEXT='Next', PREVIOUS='Previous', FASTFORWARD='Fastforward', REWIND='Rewind'] visibility=[Harmony_Activity == Kodi]
        Default   item=Kodi_control visibility=[Harmony_Activity == Kodi]
        Switch    item=Kodi_stop visibility=[Harmony_Activity == Kodi]

        Image     item=Kodi_thumbnail
        Image     item=Kodi_fanart      
    }
}

Your setup looks fine.

Which OH/binding version do you use?

Did you somehow set username or password for the Kodi webinterface?

openHAB 2.2.0-1
binding-kodi - 2.2.0 (installed via PaperUI, no nightly version)

yes, there is a username/password for the Kodi webinterface. I donā€™t see any options in the binding to provide these values.

edit:
woops, I see somthing in PaperUI (I always work with the textfiles, not via GUI) Let me try this! :slight_smile:

edit2:
Didnā€™t read the binding info completelyā€¦

kodi:kodi:libreelec				"Kodi"			@ "Living Room" [ipAddress="xxx.xxx.x.xxx", port=9090, httpPort=8080, httpUser="USER", httpPassword="PASS"]

is working fine now! thanks

See https://docs.openhab.org/v2.2/addons/bindings/kodi/readme.html#thing-configuration

You optionally can define a httpUser and a httpPassword parameter if the access to your Kodi webinterface is protected.

In your case:

kodi:kodi:libreelec "Kodi" @ "Living Room" [ipAddress="xxx.xxx.x.xxx", port=9090, httpPort=8080, httpUser="...", httpPassword="..."]

im not seeing the thumb and fanart thing channels either - is a working kodi binding for many versions on 2.3 nightlies

Hi Andrew,

Both channels should be available in the snapshot version. Did you create your Kodi thing before updating or after updating to snapshot version? If it was before you maybe have to recreate it.

Was before - as said was a working Kodi install - will try removing

Thanks
Andrew

OK removed and readded - got a much shorted UID for the kodi media center and all channels appear thanks so much

Next question - does this work in Habpanel and Iphone App (I tested the latter and wasnt showing like it was in BasicUI)

Cool, Iā€™m glad you got it working.

Iā€™m afraid I cannot answer your question because I donā€™t own an apple device.

Hey :sweat_smile:

I have a few problems and questions that Iā€™d like to askā€¦
I added the the Thumbnail Channel through PaperUI

I am currently on Openhab 2.3 on Ubuntu 18 LTS Which is my Desktop PC. So recently Iā€™ve tried using the Channels for Image(Thumbnail and Fanart) which in all attempts have failedā€¦
Oh and another thing,I upgraded recently to 2.3 from 2.0, so this is actually my first attempt

First of all, Iā€™ve added the Thumbnail Channel for OpenELEC(6) Running on a RPi 2, my desktop PC running the latest Kodi 17.3ā€¦

My first Attempt was with OpenELEC, and I got no where, when I check Paper UI it says ā€œNo image is currently presentā€(And there is a Thumbnail Image and Fanart Image)

Second, I installed the latest version of Kodi on my Desktop, but now PaperUI does discover, it does add it, but when I check the status it says: ā€œstatus: OFFLINE - COMMUNICATION_ERROR Connection could not be establishedā€

And so I have no other way of testing this the Thumbnail Channel.

Question that I have is:

  • Is there a Problem with openhab 2.3?
  • Am I supposed to be running a specific version of Kodi/OpenELEC?
  • Is there maybe other means of identifying a problem?

Thank You in Advanced

Hi,

The solution provided here does not use the thumbnail and fanart channels (these channels were not available when I posted this solution). However, it should be possible to use them I guess.

To be honest, I donā€™t know if the solution still works. My test setup died a long time ago and I havenā€™t reinstalled it since. On my production system Iā€™m still running openhab 1.xā€¦

Since the above solution does not work for you and Paper UI indicates a communication error, my best guess would be that the problem is in the configuration of Kodi.
Are you sure that the ā€˜Allow control Kodi via HTTPā€™ option in Kodi is enabled? Also, the code in the rule above assumes that Kodiā€™s webserver is listening on port 8080. Is yours also listening on port 8080 or perhaps on port 80?

I would first start by fixing the communication error you see in Paper UI. Once that is fixed then the next step would be to see if you can get this solution running.

I am using a Vero 4K with OSMC/Kodi installed, I will test the Thumbnail/fanart over the coming days as I want to display the movie art playing on my wall mounted tablet

EDIT: it appears to not display in the basic UI sitemap

Has anyone got this working for movies?

hello, would it be possible to add an option to the kodi binding so we can set an offline thumbnail image?
i recently setup a habpanel and it is working great as long as kodi is playing a video, but everytime kodi is not online, values for artist, album, titel, thumbnail, fanart are actually NULL or UNDEF.

iā€™ve setup some rules to change the values of those items when they are UNDEF but iā€™m struggling hard to do the same for the thumbnail. when kodi is offline i always get an empty picture frame in habpanel that looks ugly. ( same like when a picture is not found in an tag)

rule "No Titel"
when
        Item Kodi_Title changed or
        Item Kodi_Mediatype changed
then
        var String ersatzTitel = "No Title / No Playback"
        var String ersatzArtist = ""
        var String ersatzAlbum = ""
        var Number ersatzposi = 0
        var Number ersatzlength = 0


        if (Kodi_Title.state == UNDEF) {
        Kodi_Title.postUpdate(ersatzTitel)
        Kodi_Abspielpositionp.postUpdate(ersatzposi)
        Kodi_Abspielpositionp.postUpdate(ersatzlength)
        Kodi_Album.postUpdate(ersatzAlbum)
        Kodi_Artist.postUpdate(ersatzArtist)
//      Kodi_Thumbnail.postUpdate(Kodi_Offlineimage)

here i tried to set an image item but iā€™m not sure how it is done right since the documentation has no example for the type image. it is not working. can someone please correct me?

Image Kodi_Offlineimage { url="http://localhost:8080/static/kodi_nothingplaying.png" }

Hi Even,

Did you see this section? I would tend to a Sitemap which contains both Image elements and a visibility parameter like this:

    Image item=Kodi_Thumbnail visibility=[Kodi_Thumbnail!=UNDEF]
    Image url="https://localhost:8443/static/kodi_nothingplaying.png" visibility=[Kodi_Thumbnail==UNDEF]

Please be aware of typos I wrote this down in a second.

Thank you for your guidance, it is working in the sitemap. No i did not know about the article you linked.
I was refererring to this items guide
it says somewhere in the middle type name image but i didnā€™t find an example of how to use it.
There are examples for all types except of Image. It is still unclear how to do it outside of the sitemap in a regular .items file

here is a picture of your solution working in the sitemap.
Thank you. half way there =)

Here is a picture of my habpanel so you can see what iā€™m trying to do.
And here is the code for the widget on the left side:

<div id="wrapper">
	<div id="row">
		<div id="thumbnailbox">
	            <img class="thumbnail_picture" src="{{itemValue('Kodi_Thumbnail')}}" height="250px" /> 
		</div>
		<div id="playinfo_col">
	    	<div id="playprogress">{{'%.1f' | sprintf:itemValue('Kodi_Abspielpositionp').split(' ')[0]}}% - GesamtlƤnge: {{itemValue('Kodi_Abspielzeitconverted')}}</div>
      	<div id="titlebox">{{itemValue('Kodi_Title')}}</div>
	    	<div id="artistbox">{{itemValue('Kodi_Artist')}}</div>
		    <div id="albumbox">{{itemValue('Kodi_Album')}}</div>
		</div>
	</div>
</div>

playprogress, title, artist and album gets replaced by my rule linked in last post but sometimes when watching a youtube video for instance either album or artist are still UNDEF and then itā€™s showing up like here:
habpanelyoutubevideo

I appreciate your help and thx a lot for your time.

You maybe then should review your Rule and change it to check for UNDEF on every Item state. Not only the title - do not forget to adept the Trigger as well.

if (Kodi_Title.state == UNDEF)
        Kodi_Title.postUpdate(ersatzTitel)
...
if (Kodi_Album.state == UNDEF)
        Kodi_Album.postUpdate(ersatzAlbum)
...

btw. is the following code snippet correct?

In HABPanel you probably want to use the relative path. When you open the page on e.g. your tablet then localhost will be your tablet so it wonā€™t be able to find the picture.

Image Kodi_Offlineimage { url="../static/kodi_nothingplaying.png" }

thx that helped, yes the code snippet was correct.
so the album, artist title are now replaced correctly.

but i still havenā€™t found a solution to the offline thumbnail not showing up in habpanel when kodi is offline or nothing is playing.
i tried:

        if (Kodi_Thumbnail.state == UNDEF) {
        Kodi_Thumbnail.postUpdate(Kodi_Offlineimage)
        }

        if (Kodi_Thumbnail.state == NULL) {
        Kodi_Thumbnail.postUpdate(Kodi_Offlineimage)
        }

i guess postupdate is not working for the thumbnail channel?
both are defined in an items file such as:

Image Kodi_Thumbnail { channel="bla:bla:47b9b6e4-f0c1-35fa-f22c-7041c303e8b2:thumbnail" }
Image Kodi_Offlineimage { url="http://xxx.xxx.xxx.xxx:8080/static/kodi_nothingplaying.png" }

iā€™m still not sure if the the syntax is correct for Kodi_Offlineimage in a regular items file since the docs have no examples for Image, except the sitemap one you mentioned above.

AFAIK you cannot define an Image item linked to a fixed source. Thus you currently should see errors or warnings in your log file. Additionally I am not an HABPanel expert but I am sure there is a solution for hiding stuff if necessary.

My solution is:

rule "KodiThumbnailUNDEF"
when
    Item Kodi_Thumbnail changed to UNDEF
then
    Kodi_Thumbnail.postUpdate("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=")
end

This sets a very small transparent image.

2 Likes