AutomationDataset/DJS91/description-ready.json

149 lines
11 KiB
JSON

[
{
"id": "Jukebox - Notify of Queued Song",
"automation": "- alias: Jukebox - Notify of Queued Song\n description: Tells home assistant that someone has requested a song and to switch\n the queueing mode for guests for further requests\n triggers:\n - trigger: webhook\n allowed_methods:\n - POST\n - GET\n local_only: false\n webhook_id: < YOUR WEBHOOK ID HERE >\n conditions: []\n actions:\n - action: input_boolean.turn_on\n metadata: {}\n data: {}\n target:\n entity_id: input_boolean.jukebox_queue",
"config": [
{
"name": "jukebox queue",
"room": null,
"type": "input_boolean",
"id": {
"entity_id": "input_boolean.jukebox_queue",
"device_id": null
}
}
]
},
{
"id": "Jukebox - Set Default Playlist when Jukebox Queue is zero",
"automation": "- alias: Jukebox - Set Default Playlist when Jukebox Queue is zero\n description: Once the guests queued songs are all played, play the default party\n playlist so the music doesnt stop\n triggers:\n - trigger: state\n entity_id:\n - input_number.jukebox_queue_length\n to: '1.0'\n conditions: []\n actions:\n - action: input_boolean.turn_off\n metadata: {}\n data: {}\n target:\n entity_id: input_boolean.jukebox_queue\n - action: media_player.shuffle_set\n metadata: {}\n data:\n shuffle: true\n target:\n entity_id: media_player.<YOUR MEDIA PLAYER HERE>\n - action: music_assistant.play_media\n metadata: {}\n data:\n enqueue: play\n media_id: <YOUR DEFAULT PARTY PLAYLIST NAME HERE>\n media_type: playlist\n target:\n entity_id: media_player.<YOUR MEDIA PLAYER HERE>\n mode: single",
"config": [
{
"name": "jukebox queue",
"room": null,
"type": "input_boolean",
"id": {
"entity_id": "input_boolean.jukebox_queue",
"device_id": null
}
},
{
"name": "jukebox queue length",
"room": null,
"type": "input_number",
"id": {
"entity_id": "input_number.jukebox_queue_length",
"device_id": null
}
},
{
"name": "media player",
"room": null,
"type": "media_player",
"id": {
"entity_id": "media_player.<YOUR MEDIA PLAYER HERE>",
"device_id": null
}
}
]
},
{
"id": "Jukebox - Switch Jukebox Access on/off",
"automation": "- alias: Jukebox - Switch Jukebox Access on/off\n description: Controls access to the jukebox by enableing the app and provisioning\n an access token or disabling the app and revoking any active token\n triggers:\n - trigger: state\n entity_id:\n - input_boolean.songrequestaccess\n from: 'off'\n to: 'on'\n - trigger: state\n entity_id:\n - input_boolean.songrequestaccess\n from: 'on'\n to: 'off'\n conditions: []\n actions:\n - if:\n - condition: state\n entity_id: input_boolean.songrequestaccess\n state: 'on'\n then:\n - action: shell_command.create_jukebox_token\n metadata: {}\n data: {}\n - action: input_boolean.turn_off\n metadata: {}\n data: {}\n target:\n entity_id: input_boolean.jukebox_queue\n else:\n - action: shell_command.delete_jukebox_token\n metadata: {}\n data: {}\n mode: single",
"config": [
{
"name": "jukebox queue",
"room": null,
"type": "input_boolean",
"id": {
"entity_id": "input_boolean.jukebox_queue",
"device_id": null
}
},
{
"name": "song request access",
"room": null,
"type": "input_boolean",
"id": {
"entity_id": "input_boolean.songrequestaccess",
"device_id": null
}
}
]
},
{
"id": "Jukebox - Track Queue Size",
"automation": "- alias: Jukebox - Track Queue Size\n description: Keeps track of the media player queue length and updates the Jukebox\n Queue Length helper\n triggers:\n - trigger: state\n entity_id:\n - media_player.<YOUR MEDIA PLAYER HERE>\n attribute: media_position_updated_at\n conditions: []\n actions:\n - action: music_assistant.get_queue\n metadata: {}\n data: {}\n target:\n entity_id: media_player.<YOUR MEDIA PLAYER HERE>\n response_variable: jukeboxqueuedetail\n - variables:\n speaker_data: '{{ jukeboxqueuedetail[''media_player.<YOUR MEDIA PLAYER HERE>'']\n }}'\n - variables:\n items_count: '{% set matches = speaker_data | regex_findall(\"''items'': (\\d+)\")\n %} {{ matches[0] if matches else 0 }}'\n current_index: '{% set matches = speaker_data | regex_findall(\"''current_index'':\n (\\d+)\") %} {{ matches[0] if matches else 0 }}'\n remaining: '{{ (items_count | int) - (current_index | int) }}'\n - action: input_number.set_value\n target:\n entity_id: input_number.jukebox_queue_length\n data:\n value: '{{ remaining | float }}'\n mode: queued\n max: 10",
"config": [
{
"name": "jukebox queue length",
"room": null,
"type": "input_number",
"id": {
"entity_id": "input_number.jukebox_queue_length",
"device_id": null
}
},
{
"name": "media player",
"room": null,
"type": "media_player",
"id": {
"entity_id": "media_player.<YOUR MEDIA PLAYER HERE>",
"device_id": null
}
}
]
},
{
"id": "JukeBox Controller",
"automation": "- alias: JukeBox Controller\n description: \"Keeps control of the jukebox\\n\\nInstructions:\\nBefore use remember\\\n \\ to change the media_player in the first trigger \\nand put the defined variable\\\n \\ media_player to the same player\\nYou should also update the default playlist\\\n \\ variable to the playlist you want to use\\n\\nWhat the automation does\\n\\n- Keeps\\\n \\ the queue counter updated\\n- Stops the playback when Access is disabled\\n- Does\\\n \\ something to the queue switch, but not sure what it is \\n used for\"\n triggers:\n - trigger: state\n entity_id:\n - media_player.tablet_stue\n attribute: media_position_updated_at\n id: Position Updated\n - trigger: state\n entity_id:\n - switch.music_assistant_jukebox_jukebox_allow_access\n from: 'off'\n to: 'on'\n id: Access enabled\n - trigger: webhook\n allowed_methods:\n - POST\n - PUT\n local_only: true\n webhook_id: -notify_queue_of_song\n id: Webhook\n - trigger: state\n entity_id:\n - number.music_assistant_jukebox_jukebox_queue_length\n to: '0'\n id: Playlist finished\n - trigger: state\n entity_id:\n - switch.music_assistant_jukebox_jukebox_allow_access\n from: 'on'\n to: 'off'\n id: Access disabled\n conditions: []\n actions:\n - variables:\n media_player: media_player.tablet_stue\n default_playlist: Jukebox\n - choose:\n - conditions:\n - condition: trigger\n id:\n - Position Updated\n sequence:\n - action: music_assistant.get_queue\n metadata: {}\n data: {}\n target:\n entity_id: media_player.tablet_stue\n response_variable: jukeboxqueuedetail\n - variables:\n speaker_data: '{{ jukeboxqueuedetail[''media_player.tablet_stue''] }}'\n - variables:\n items_count: '{% set matches = speaker_data | regex_findall(\"''items'':\n (\\d+)\") %} {{ matches[0] if matches else 0 }}'\n current_index: '{% set matches = speaker_data | regex_findall(\"''current_index'':\n (\\d+)\") %} {{ matches[0] if matches else 0 }}'\n remaining: '{{ (items_count | int) - (current_index | int) }}'\n - action: input_number.set_value\n data:\n value: '{{ remaining }}'\n target:\n entity_id: number.music_assistant_jukebox_jukebox_queue_length\n - conditions:\n - condition: trigger\n id:\n - Access enabled\n sequence:\n - action: switch.turn_off\n metadata: {}\n data: {}\n target:\n entity_id: switch.music_assistant_jukebox_jukebox_queue\n - conditions:\n - condition: trigger\n id:\n - Webhook\n sequence:\n - action: switch.turn_on\n metadata: {}\n data: {}\n target:\n entity_id: switch.music_assistant_jukebox_jukebox_queue\n - conditions:\n - condition: trigger\n id:\n - Playlist finished\n - condition: state\n entity_id: input_boolean.song_request_access\n state: 'on'\n sequence:\n - action: switch.turn_off\n metadata: {}\n data: {}\n target:\n entity_id: switch.music_assistant_jukebox_jukebox_queue\n - action: music_assistant.play_media\n metadata: {}\n data:\n enqueue: replace\n media_id: '{{ default_playlist }}'\n media_type: playlist\n target:\n entity_id: '{{ media_player }}'\n - conditions:\n - condition: trigger\n id:\n - Access disabled\n sequence:\n - action: media_player.media_stop\n metadata: {}\n data: {}\n target:\n entity_id: '{{ media_player }}'\n - action: switch.turn_off\n metadata: {}\n data: {}\n target:\n entity_id:\n - switch.music_assistant_jukebox_jukebox_allow_access\n - switch.music_assistant_jukebox_jukebox_queue\n mode: queued\n max: 10",
"config": [
{
"name": "tablet stue media player",
"room": "living_room",
"type": "media_player",
"id": {
"entity_id": "media_player.tablet_stue",
"device_id": null
}
},
{
"name": "jukebox allow access switch",
"room": null,
"type": "switch",
"id": {
"entity_id": "switch.music_assistant_jukebox_jukebox_allow_access",
"device_id": null
}
},
{
"name": "jukebox queue length number",
"room": null,
"type": "number",
"id": {
"entity_id": "number.music_assistant_jukebox_jukebox_queue_length",
"device_id": null
}
},
{
"name": "jukebox queue switch",
"room": null,
"type": "switch",
"id": {
"entity_id": "switch.music_assistant_jukebox_jukebox_queue",
"device_id": null
}
},
{
"name": "song request access input boolean",
"room": null,
"type": "input_boolean",
"id": {
"entity_id": "input_boolean.song_request_access",
"device_id": null
}
}
]
}
]