I have integrated my kodi instance with HA.
Now I want to be able to play a Kodi folder that contains music with a trigger; button, or state etc.
While being familiar with the triggering part, I am completely at sea with regards to how to play music from the folder located at \storage\music on the kodi host. I am unable to find very relevant documentation on the same either. Appreciate any help. Thank you.
I do not play a folder, but a file (file path is given by a trigger). Maybe it helps anyway…
- id: '1639043665489'
alias: Play on Kodi
description: ''
trigger:
- platform: event
event_type: play_on_kodi_wz
id: play_on_kodi_wz
condition: []
action:
- service: media_player.play_media
data:
media_content_id: '{{ trigger.event.data.filepath }}'
media_content_type: file
target:
entity_id: media_player.kodi_wz_2
mode: restart
1 Like
Sorry I didnt understand … (file path is given by a trigger)
In my case, a local webserver fires an event via HA’s REST API. This event is called “play_on_kodi_wz” and the event data contains the file path (e.g. “/storage/media/my_movie.mp4”).
Background is: I use a webpage that lists all my videos, and by a click on a file name (a link), the webserver fires the event on HA. But that doesn’t matter for HA, it just gets an event with a file path.
I don’t know enough about your problem to help further. Do you want to play a specific file from a folder or all files from that folder? Is it always the same path or where does the path come from? Things like that
1 Like
Well actually the file resides on the same machine as HA and so does the Kodi instance (Kodi on Coreelec, and HA running dockerised).
I would ideally like to play all the files in the folder.
The path of the folder is \storage\music as far as kodi is concerned.
I would prefer my trigger to be something like 8 am in the morning on weekdays. Or lets say when I switch off a certain light which I do every morning.
In the docs of the kodi integration you find this:
- service: media_player.play_media
target:
entity_id: media_player.kodi
data:
media_content_type: DIRECTORY
media_content_id: special://profile/playlists/video/feuerwehrmann_sam.xsp
look like just starting a “smart play list” is a good way to do that. Creating such a playlist can be easily done in kodi and can by dynamic. So I’d try that way.
For details on creating smart play lists, you can start here:
https://kodi.wiki/view/Smart_playlists/XSP_Method
1 Like
This seems too much and unneccessary. I dont wish to create a playlist etc. because I will have to edit it each time I add or remove new music.
Lets leave kodi out. Is it possible for HA to use some other player (or a built in player if there is one) to merely play music from a folder?
Edit: The media files can reside on the same R Pi I am using as the HA server. And would like to use the analog audio output of the Pi for sound output.