Hm, I thought it sounded a bit odd that I would ned a CEC addon to control Kodi from hass.io. My kitchen Kodi is not connected to a TV, but an official 7" Raspberry Pi screen.
I tried the play_media service with the JSON arguments above, and I get the same spinning wheel as with my script.
Now, this is really weird. I found out that the channel I am calling does not correspond with the channel shown in media_player.kodi_kok. By trial and error I have now found the channels I am subsribing to.
Sorry for the misunderstanding. The CEC protocol is to control TVs. I thought you had 2 problems: to turn on the TV, and to play some media. Now I see your problem is only with the OpenElec PVR channels…
Well, the JSON RPC API for Kodi could be a little complex… but it has good docs. It’s not really a problem of HA or hassio. You could play with the Kodi API from within a Jupyter notebook, or an ipython console, or with some CURL commands in the CLI, before using it from Home Assistant, your life would be easier
I actually managed to play PVR when I finally called the right channels. I am using two Kodi machines as stated above and the channels are unfortunately not the same for both of them. Also, I have not been able to play a specific album or artist from my mp3 music collection on my Linux server (with Samba share).
If you have any tips or examples on how to get HA to play these in Kodi, it would be very helpful. Also, is there a way to extract which channels correspond to which media_content_id? I also have Radio enabled in Kodi.
You’re welcome.
If you have these mp3 albums added to your Kodi media library, you only need to know their identifiers to play them. As I said, The Kodi API is a complex, but most complete one. It requires to play a lot with it to get things done.
Like with the PVR channel ids, there are API commands to query the Kodi DB in order to obtain the necessary info to do what you want.
Also, to play internet video or audio streams, take a look to the media_extractor component in Home Assistant.
Well, in the link to my TV control yaml config you can see some. But if you’re doing complex orders, you’ll need a powerful tool to make the automations. I use the awesome appdaemon to do that.
As an example, I have an input_select and some scripts to dynamically populate it: for loading and then selecting items from the ‘recent TV shows’ and ‘recent movies’ playlists (and for the PVR channels). To receive the API call results and populate the input_select, I have this appdaemon app.
Thanks @azogue, quite advanced stuff and so far a little bit over my head, although I am trying to learn
What I am after to begin with is this:
Let HA tell Kodi to play TV or radio at the press of a button or switch or e.g. a certain channel on the kitchen tv every workday morning
Let HA tell Kodi to play a predefined playlist of mp3’s, such as e.g. “Dinner music” or random songs from a music genre with a button press or switch
Same as 2), but get music from Spotify or Tidal through Kodi addons
However, I guess I still need to learn how to extract the content_id from Kodi. I tried to call Kodi with the parameters album_id and artist_id, but couldn’t get it to find anything in my Kodi music db.
Later on I will probably like to do some of the advanced stuff with input_select etc., but to begin with pretty basic stuff.
Also, I am running a Logitech Media Server on my Ubuntu Server in order to try and accomplish multi-room functionality with Squeezelite or Squeezebox and Kodi. I have also seen examples using HA to play a random playlist from LMS.
I will look at the documentation you suggest, but as many of us unwilling to “reinvent the wheel” I was also looking for some basic examples that I could apply to my setup.
I want to fire a JSON RPC API command thrue a script with HA to a kodi box, but I can’t find a proper example of a code. With an example from mviezzer I have a party mode working, now I like to stream a radio station with the Kodi Addon “Radio.de”.
Is there anyone who can post a few script examples for Kodi (addons)?
There is a nice Kodi add-on for MQTT … this provides the Kodi status (on, off ,pause, screensaver, movie title, progress, etc) … it works much more easy!
Hi. Did you figure out how the config looks like?
I have installed kodi2mqtt addon and connected it to my hassio broker, but I’m strugling with adding it to my config.
Can anybody tell how I can play specific spotify playlist on kodi?
I found that probably i can call to the plugin, but can’t figure out how to do it from call method.
here’s what i got from kodi debug and i want to invoke:
plugin://plugin.audio.spotify/?action=play_playlist&ownerid=spotify&playlistid=37i9TECEVXcSwR3jlLXHm8