[ { "id": "Jukebox - Notify of Queued Song", "result": { "structured": "TRIGGER: When a webhook with the specified ID is received via POST or GET, not restricted to local network. CONDITIONS: None. ACTIONS: Turn on jukebox queue [input_boolean.jukebox_queue].", "natural_language": { "trigger": "When a webhook request (using either POST or GET methods, and allowed from outside the local network) with a specific identifier is received.", "conditions": "There are no conditions that must be met.", "action": "Activates the jukebox queue by turning on the input boolean jukebox queue [input_boolean.jukebox_queue]." }, "human_like": "Turns on the jukebox queue mode when a song request is received via a webhook.", "complexity": "low" } }, { "id": "Jukebox - Set Default Playlist when Jukebox Queue is zero", "result": { "structured": "TRIGGER: When jukebox queue length [input_number.jukebox_queue_length] changes to 1.0. CONDITIONS: None. ACTIONS: Turn off jukebox queue [input_boolean.jukebox_queue] AND set shuffle to true on media player [media_player.] AND play the default party playlist on media player [media_player.] with enqueue mode 'play'.", "natural_language": { "trigger": "When the jukebox queue length [input_number.jukebox_queue_length] reaches exactly 1.0.", "conditions": "There are no conditions.", "action": "Turns off the jukebox queue [input_boolean.jukebox_queue], enables shuffle on the media player [media_player.], and starts playing the default party playlist on the same media player." }, "human_like": "When the song queue is nearly empty, this automation switches to a default party playlist to keep the music playing.", "complexity": "low" } }, { "id": "Jukebox - Switch Jukebox Access on/off", "result": { "structured": "TRIGGER: When song request access [input_boolean.songrequestaccess] changes from off to on OR when song request access [input_boolean.songrequestaccess] changes from on to off. CONDITIONS: None. ACTIONS: IF song request access [input_boolean.songrequestaccess] is on THEN execute shell_command.create_jukebox_token AND turn off jukebox queue [input_boolean.jukebox_queue]. ELSE execute shell_command.delete_jukebox_token.", "natural_language": { "trigger": "Whenever the song request access [input_boolean.songrequestaccess] is turned on or turned off.", "conditions": "There are no conditions for this automation.", "action": "If the song request access [input_boolean.songrequestaccess] is turned on, the automation creates a new jukebox token via a shell command and also turns off the jukebox queue [input_boolean.jukebox_queue]. If the song request access is turned off, the automation revokes the active token by executing a different shell command to delete it." }, "human_like": "Manages jukebox access by creating or deleting an access token when the song request feature is enabled or disabled.", "complexity": "medium" } }, { "id": "Jukebox - Track Queue Size", "result": { "structured": "TRIGGER: When media player [media_player.] changes its media_position_updated_at attribute. CONDITIONS: None. ACTIONS: Call service music_assistant.get_queue for media player [media_player.] and store the response in variable 'jukeboxqueuedetail'. Set variable 'speaker_data' to the value of key 'media_player.' from the 'jukeboxqueuedetail' dictionary. Set variable 'items_count' by extracting the first integer after the pattern \"'items': \" from 'speaker_data' (default to 0 if not found). Set variable 'current_index' by extracting the first integer after the pattern \"'current_index': \" from 'speaker_data' (default to 0 if not found). Set variable 'remaining' to the integer difference between 'items_count' and 'current_index'. Set the value of jukebox queue length [input_number.jukebox_queue_length] to the value of 'remaining'.", "natural_language": { "trigger": "Whenever the media player [media_player.] updates its playback position timestamp.", "conditions": "There are no conditions; the automation runs every time the trigger occurs.", "action": "The automation fetches the current queue details from the Music Assistant for the media player [media_player.]. It then parses the response to find the total number of items in the queue and the current playing index. It calculates the number of remaining tracks by subtracting the current index from the total items. Finally, it updates the jukebox queue length [input_number.jukebox_queue_length] helper with this calculated remaining count." }, "human_like": "Updates a counter showing how many songs are left in the media player's queue whenever the playing track changes.", "complexity": "medium" } }, { "id": "JukeBox Controller", "result": { "structured": "TRIGGER: When tablet stue media player [media_player.tablet_stue] media_position_updated_at attribute changes OR When jukebox allow access switch [switch.music_assistant_jukebox_jukebox_allow_access] turns on (from off) OR When a webhook with ID '-notify_queue_of_song' is received via POST or PUT locally OR When jukebox queue length number [number.music_assistant_jukebox_jukebox_queue_length] becomes 0 OR When jukebox allow access switch [switch.music_assistant_jukebox_jukebox_allow_access] turns off (from on). CONDITIONS: None. ACTIONS: Set variables media_player to media_player.tablet_stue and default_playlist to 'Jukebox'. Then, based on which trigger fired: IF trigger is Position Updated THEN get queue details for tablet stue media player [media_player.tablet_stue], extract items count and current index, calculate remaining items, and set jukebox queue length number [number.music_assistant_jukebox_jukebox_queue_length] to the remaining count. IF trigger is Access enabled THEN turn off jukebox queue switch [switch.music_assistant_jukebox_jukebox_queue]. IF trigger is Webhook THEN turn on jukebox queue switch [switch.music_assistant_jukebox_jukebox_queue]. IF trigger is Playlist finished AND song request access input boolean [input_boolean.song_request_access] is on THEN turn off jukebox queue switch [switch.music_assistant_jukebox_jukebox_queue] AND play the default playlist 'Jukebox' on tablet stue media player [media_player.tablet_stue], replacing the current queue. IF trigger is Access disabled THEN stop playback on tablet stue media player [media_player.tablet_stue] AND turn off both jukebox allow access switch [switch.music_assistant_jukebox_jukebox_allow_access] and jukebox queue switch [switch.music_assistant_jukebox_jukebox_queue].", "natural_language": { "trigger": "The automation can be triggered in several ways: when the playback position updates on the tablet stue media player [media_player.tablet_stue]; when the jukebox allow access switch [switch.music_assistant_jukebox_jukebox_allow_access] is turned on; when a specific local webhook named '-notify_queue_of_song' is called; when the jukebox queue length number [number.music_assistant_jukebox_jukebox_queue_length] reaches zero; or when the jukebox allow access switch [switch.music_assistant_jukebox_jukebox_allow_access] is turned off.", "conditions": "There are no global conditions for this automation. However, for the specific action when the playlist finishes, an additional check is performed: the song request access input boolean [input_boolean.song_request_access] must be on.", "action": "First, the automation sets up internal variables for the media player and a default playlist. Depending on which trigger occurred, it performs different actions. If the playback position updated, it fetches the current queue details, calculates how many songs are left, and updates the queue length display. If jukebox access is enabled, it turns off the jukebox queue switch [switch.music_assistant_jukebox_jukebox_queue]. If the webhook is received, it turns that same queue switch on. If the queue length reaches zero and song requests are allowed, it turns off the queue switch and starts playing the default playlist. Finally, if jukebox access is disabled, it stops the music player and turns off both the access and queue switches." }, "human_like": "This automation manages a jukebox system by updating the queue counter, controlling playback based on access permissions, and handling song requests via a webhook.", "complexity": "high" } } ]