Hi - I’m trying to instruct Kodi to play a random file from a folder, where all of the files have a filename of the format filenn.mkv.
I’m calling the Kodi API method playlist.insert with a data template to generate a random number to append to the filename:
- data_template:
entity_id: media_player.kodi
item:
file: smb://NAS/folder/file{{ range (1,33) | random }}.mkv
method: playlist.insert
playlistid: 1
position: 1
service: media_player.kodi_call_method
When this runs the filename is constructed correctly, but Kodi returns an error, because the two integer parameters in the call (playlistid and position) get sent as strings:
Run API method media_player.kodi.playlist.insert({'item': {'file': 'smb://NAS/folder/file26.mkv'}, 'playlistid': '1', 'position': '1'}) error: {'code': -32602, 'data': {'method': 'Playlist.Insert', 'stack': {'message': 'Invalid type string received', 'name': 'playlistid', 'type': 'integer'}}, 'message': 'Invalid params.'}
If I make the same call without using a data template and specifying a particular file it runs as expected. It seems that jinja2 converts the entire block to strings and isn’t preserving the integer parameters. Is there a way to do so?
thanks