I want to share here my project in development for automating play for next episode to play on kodi.
I’m new to yaml automation and script so bear with me…
So here my start:
First I’ve search for a long time how to do it and almost no pages on web explain all deep ways to communicate with kodi.
My goal:
- Retreive all kodi shows
– in order lastWatched - Loop For each shows retreive All episodes
– For each episode ask if it as been seen - If all episodes availables as been seen continue on next lastShow watched
- and so on…
- If next episode as not been seen, send it to player
– And pause it
1.Make a Script: retreive all lastWatchedShow
alias: Get Last played TvShows
variables:
last_played_ids: null
sequence:
- service: kodi.call_method
data:
method: VideoLibrary.GetTVShows
properties:
- lastplayed
sort:
order: descending
method: lastplayed
target:
entity_id: media_player.qlexmediarpi4
...
2.Then make an Automation to be triggered by this script event and manipulate it data result:
alias: Auto set next show episode
description: >-
Va permettre de pouvoir automatiquement écouter la prochaine épisode du
dernier TV show a écouter
trigger:
- platform: event
event_type: kodi_call_method_result
event_data:
result_ok: true
input:
method: VideoLibrary.GetTVShows
condition:
- condition: template
value_template: "{{ lastPlayedShowsIDs | length > 0 }}"
action:
- delay:
milliseconds: 200
...
- Next is to loop throught the showid list received.
3.1 Request its episodes
3.1.1 Ordered by episode
3.1.2 Filtered by playcount = 0
3.1.3 Limit to 1 result
In openhab I was able with this call:
{"jsonrpc":"2.0",
"method":"VideoLibrary.GetEpisodes",
"params":{
"sort" : {"order" : "ascending", "method" : "episode"},
"tvshowid": " lastTvShowPlayedId ",
"filter":{"field":"playcount","operator":"is","value":"0"
}
},
"id":1}
Now I need to transfert kodi_call_method_result in automation event_data back to script variable list and iterate throught it in a loop…
Well I mean getting shows id list and request is kodi show/episodes one after one…