Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "trace": {
- "last_step": "sequence/1/then/11",
- "run_id": "3c4487faea38270c62bf841cf3f8b90a",
- "state": "stopped",
- "script_execution": "finished",
- "timestamp": {
- "start": "2022-12-02T14:23:34.292576+00:00",
- "finish": "2022-12-02T14:24:03.115092+00:00"
- },
- "domain": "script",
- "item_id": "google_home_resume_helper",
- "trace": {
- "sequence/0": [
- {
- "path": "sequence/0",
- "timestamp": "2022-12-02T14:23:34.294490+00:00",
- "changed_variables": {
- "this": {
- "entity_id": "script.google_home_resume_helper",
- "state": "off",
- "attributes": {
- "last_triggered": "2022-11-30T16:16:12.426326+00:00",
- "mode": "parallel",
- "current": 0,
- "max": 30,
- "icon": "mdi:cast-audio",
- "friendly_name": "00 - Google Home Resume - Helper Script"
- },
- "last_changed": "2022-12-02T14:22:09.964914+00:00",
- "last_updated": "2022-12-02T14:22:09.964914+00:00",
- "context": {
- "id": "01GK9KENHCD40JXK2ZCY1K98E8",
- "parent_id": null,
- "user_id": null
- }
- },
- "start_time": "2022-12-02 16:23:29.328374+02:00",
- "player": {
- "data_source": "resume_script",
- "entity_id": "media_player.ufficio_milena",
- "state": "playing",
- "type": "speaker",
- "members": [],
- "volume_level": 0.3,
- "app_name": "Spotify",
- "media_content_id": "spotify:track:7l9IqDtVWJurTvkQHq1BGh",
- "media_position": 136.54,
- "spotcast": "milena_dacheva"
- },
- "member_data": [],
- "players_to_resume": [
- "media_player.ufficio_milena"
- ],
- "event_script": false,
- "resume": true,
- "ytube_resume": false,
- "action_type": "resume",
- "resume_delay": {
- "seconds": 20
- },
- "context": {
- "id": "01GK9KH31BYQFPE42G5GHSY13A",
- "parent_id": null,
- "user_id": "2a298aebc80446749be35680bdc494b1"
- }
- }
- }
- ],
- "sequence/1": [
- {
- "path": "sequence/1",
- "timestamp": "2022-12-02T14:23:34.294553+00:00",
- "changed_variables": {
- "version": "2022.12.0"
- },
- "result": {
- "choice": "then"
- }
- }
- ],
- "sequence/1/if": [
- {
- "path": "sequence/1/if",
- "timestamp": "2022-12-02T14:23:34.294917+00:00",
- "result": {
- "result": true
- }
- }
- ],
- "sequence/1/if/condition/0": [
- {
- "path": "sequence/1/if/condition/0",
- "timestamp": "2022-12-02T14:23:34.294934+00:00",
- "result": {
- "result": true,
- "entities": []
- }
- }
- ],
- "sequence/1/then/0": [
- {
- "path": "sequence/1/then/0",
- "timestamp": "2022-12-02T14:23:34.295201+00:00"
- }
- ],
- "sequence/1/then/1": [
- {
- "path": "sequence/1/then/1",
- "timestamp": "2022-12-02T14:23:34.295380+00:00",
- "changed_variables": {
- "image": false,
- "dashboard_cast": false
- },
- "result": {
- "wait": {
- "remaining": 30,
- "completed": true
- }
- }
- }
- ],
- "sequence/1/then/2": [
- {
- "path": "sequence/1/then/2",
- "timestamp": "2022-12-02T14:23:34.295635+00:00",
- "changed_variables": {
- "wait": {
- "remaining": 30,
- "completed": true
- }
- }
- }
- ],
- "sequence/1/then/3": [
- {
- "path": "sequence/1/then/3",
- "timestamp": "2022-12-02T14:23:34.297054+00:00",
- "changed_variables": {
- "state_changed": true,
- "current_volume": 0.8,
- "data_volume": 0.3
- },
- "result": {
- "params": {
- "domain": "group",
- "service": "set",
- "service_data": {
- "object_id": "resume_active_ghresume_01gk9kh31byqfpe42g5ghsy13a",
- "name": "Entities which will be resumed by the Google Home Resume script",
- "icon": "mdi:autorenew",
- "entities": [
- "media_player.ufficio_milena"
- ]
- },
- "target": {}
- },
- "running_script": false,
- "limit": 10
- }
- }
- ],
- "sequence/1/then/4": [
- {
- "path": "sequence/1/then/4",
- "timestamp": "2022-12-02T14:23:34.301224+00:00",
- "result": {
- "wait": {
- "remaining": null,
- "completed": true
- }
- }
- }
- ],
- "sequence/1/then/5": [
- {
- "path": "sequence/1/then/5",
- "timestamp": "2022-12-02T14:23:43.098346+00:00",
- "changed_variables": {
- "wait": {
- "remaining": null,
- "completed": true
- }
- }
- }
- ],
- "sequence/1/then/5/if": [
- {
- "path": "sequence/1/then/5/if",
- "timestamp": "2022-12-02T14:23:43.098443+00:00",
- "result": {
- "result": false
- }
- }
- ],
- "sequence/1/then/5/if/condition/0": [
- {
- "path": "sequence/1/then/5/if/condition/0",
- "timestamp": "2022-12-02T14:23:43.098458+00:00",
- "result": {
- "result": false,
- "entities": []
- }
- }
- ],
- "sequence/1/then/6": [
- {
- "path": "sequence/1/then/6",
- "timestamp": "2022-12-02T14:23:43.098548+00:00",
- "result": {
- "choice": "then"
- }
- }
- ],
- "sequence/1/then/6/if": [
- {
- "path": "sequence/1/then/6/if",
- "timestamp": "2022-12-02T14:23:43.098613+00:00",
- "result": {
- "result": true
- }
- }
- ],
- "sequence/1/then/6/if/condition/0": [
- {
- "path": "sequence/1/then/6/if/condition/0",
- "timestamp": "2022-12-02T14:23:43.098625+00:00",
- "result": {
- "result": true,
- "entities": []
- }
- }
- ],
- "sequence/1/then/6/then/0": [
- {
- "path": "sequence/1/then/6/then/0",
- "timestamp": "2022-12-02T14:23:43.100062+00:00"
- }
- ],
- "sequence/1/then/6/then/0/repeat/sequence/0": [
- {
- "path": "sequence/1/then/6/then/0/repeat/sequence/0",
- "timestamp": "2022-12-02T14:23:43.100368+00:00",
- "changed_variables": {
- "repeat": {
- "first": true,
- "index": 1,
- "last": true,
- "item": "media_player.ufficio_milena"
- }
- },
- "result": {
- "params": {
- "domain": "media_player",
- "service": "volume_set",
- "service_data": {
- "volume_level": 0.3,
- "entity_id": [
- "media_player.ufficio_milena"
- ]
- },
- "target": {
- "entity_id": [
- "media_player.ufficio_milena"
- ]
- }
- },
- "running_script": false,
- "limit": 10
- }
- }
- ],
- "sequence/1/then/7": [
- {
- "path": "sequence/1/then/7",
- "timestamp": "2022-12-02T14:23:43.101630+00:00"
- }
- ],
- "sequence/1/then/7/if": [
- {
- "path": "sequence/1/then/7/if",
- "timestamp": "2022-12-02T14:23:43.101715+00:00",
- "result": {
- "result": false
- }
- }
- ],
- "sequence/1/then/7/if/condition/0": [
- {
- "path": "sequence/1/then/7/if/condition/0",
- "timestamp": "2022-12-02T14:23:43.101730+00:00",
- "result": {
- "result": false,
- "entities": []
- }
- }
- ],
- "sequence/1/then/8": [
- {
- "path": "sequence/1/then/8",
- "timestamp": "2022-12-02T14:23:43.101826+00:00",
- "result": {
- "choice": "then"
- }
- }
- ],
- "sequence/1/then/8/if": [
- {
- "path": "sequence/1/then/8/if",
- "timestamp": "2022-12-02T14:23:43.102007+00:00",
- "result": {
- "result": true
- }
- }
- ],
- "sequence/1/then/8/if/condition/0": [
- {
- "path": "sequence/1/then/8/if/condition/0",
- "timestamp": "2022-12-02T14:23:43.102020+00:00",
- "result": {
- "result": true,
- "entities": []
- }
- }
- ],
- "sequence/1/then/8/then/0": [
- {
- "path": "sequence/1/then/8/then/0",
- "timestamp": "2022-12-02T14:23:43.102231+00:00"
- }
- ],
- "sequence/1/then/8/then/1": [
- {
- "path": "sequence/1/then/8/then/1",
- "timestamp": "2022-12-02T14:23:43.102492+00:00",
- "changed_variables": {
- "ytube_music": false,
- "spotify": true,
- "youtube": false,
- "podcast": false,
- "stream": false,
- "mass": false
- },
- "result": {
- "choice": 3
- }
- }
- ],
- "sequence/1/then/8/then/1/choose/0": [
- {
- "path": "sequence/1/then/8/then/1/choose/0",
- "timestamp": "2022-12-02T14:23:43.102740+00:00",
- "result": {
- "result": false
- }
- }
- ],
- "sequence/1/then/8/then/1/choose/0/conditions/0": [
- {
- "path": "sequence/1/then/8/then/1/choose/0/conditions/0",
- "timestamp": "2022-12-02T14:23:43.102755+00:00",
- "result": {
- "result": false,
- "entities": []
- }
- }
- ],
- "sequence/1/then/8/then/1/choose/1": [
- {
- "path": "sequence/1/then/8/then/1/choose/1",
- "timestamp": "2022-12-02T14:23:43.102829+00:00",
- "result": {
- "result": false
- }
- }
- ],
- "sequence/1/then/8/then/1/choose/1/conditions/0": [
- {
- "path": "sequence/1/then/8/then/1/choose/1/conditions/0",
- "timestamp": "2022-12-02T14:23:43.102842+00:00",
- "result": {
- "result": false,
- "entities": []
- }
- }
- ],
- "sequence/1/then/8/then/1/choose/2": [
- {
- "path": "sequence/1/then/8/then/1/choose/2",
- "timestamp": "2022-12-02T14:23:43.102901+00:00",
- "result": {
- "result": false
- }
- }
- ],
- "sequence/1/then/8/then/1/choose/2/conditions/0": [
- {
- "path": "sequence/1/then/8/then/1/choose/2/conditions/0",
- "timestamp": "2022-12-02T14:23:43.102915+00:00",
- "result": {
- "result": false,
- "entities": []
- }
- }
- ],
- "sequence/1/then/8/then/1/choose/3": [
- {
- "path": "sequence/1/then/8/then/1/choose/3",
- "timestamp": "2022-12-02T14:23:43.102970+00:00",
- "result": {
- "result": true
- }
- }
- ],
- "sequence/1/then/8/then/1/choose/3/conditions/0": [
- {
- "path": "sequence/1/then/8/then/1/choose/3/conditions/0",
- "timestamp": "2022-12-02T14:23:43.102981+00:00",
- "result": {
- "result": true,
- "entities": []
- }
- }
- ],
- "sequence/1/then/8/then/1/choose/3/sequence/0": [
- {
- "path": "sequence/1/then/8/then/1/choose/3/sequence/0",
- "timestamp": "2022-12-02T14:23:43.103215+00:00"
- }
- ],
- "sequence/1/then/8/then/1/choose/3/sequence/1": [
- {
- "path": "sequence/1/then/8/then/1/choose/3/sequence/1",
- "timestamp": "2022-12-02T14:23:43.103385+00:00",
- "changed_variables": {
- "service_data": {
- "entity_id": "media_player.ufficio_milena",
- "force_playback": true
- },
- "account_data": {
- "account": "milena_dacheva"
- }
- },
- "result": {
- "params": {
- "domain": "spotcast",
- "service": "start",
- "service_data": {
- "entity_id": "media_player.ufficio_milena",
- "force_playback": true,
- "account": "milena_dacheva"
- },
- "target": {}
- },
- "running_script": false,
- "limit": 10
- }
- }
- ],
- "sequence/1/then/8/then/1/choose/3/sequence/2": [
- {
- "path": "sequence/1/then/8/then/1/choose/3/sequence/2",
- "timestamp": "2022-12-02T14:23:53.105039+00:00",
- "result": {
- "wait": {
- "remaining": 0,
- "completed": false
- }
- }
- }
- ],
- "sequence/1/then/8/then/1/choose/3/sequence/3": [
- {
- "path": "sequence/1/then/8/then/1/choose/3/sequence/3",
- "timestamp": "2022-12-02T14:24:03.106243+00:00",
- "changed_variables": {
- "wait": {
- "remaining": 0,
- "completed": false
- }
- }
- }
- ],
- "sequence/1/then/8/then/1/choose/3/sequence/3/if": [
- {
- "path": "sequence/1/then/8/then/1/choose/3/sequence/3/if",
- "timestamp": "2022-12-02T14:24:03.106367+00:00",
- "result": {
- "result": false
- }
- }
- ],
- "sequence/1/then/8/then/1/choose/3/sequence/3/if/condition/0": [
- {
- "path": "sequence/1/then/8/then/1/choose/3/sequence/3/if/condition/0",
- "timestamp": "2022-12-02T14:24:03.106385+00:00",
- "result": {
- "result": false,
- "entities": []
- }
- }
- ],
- "sequence/1/then/9": [
- {
- "path": "sequence/1/then/9",
- "timestamp": "2022-12-02T14:24:03.106609+00:00",
- "result": {
- "choice": "then"
- }
- }
- ],
- "sequence/1/then/9/if": [
- {
- "path": "sequence/1/then/9/if",
- "timestamp": "2022-12-02T14:24:03.106673+00:00",
- "result": {
- "result": true
- }
- }
- ],
- "sequence/1/then/9/if/condition/0": [
- {
- "path": "sequence/1/then/9/if/condition/0",
- "timestamp": "2022-12-02T14:24:03.106687+00:00",
- "result": {
- "result": true,
- "entities": []
- }
- }
- ],
- "sequence/1/then/9/then/0": [
- {
- "path": "sequence/1/then/9/then/0",
- "timestamp": "2022-12-02T14:24:03.108031+00:00",
- "result": {
- "params": {
- "domain": "group",
- "service": "set",
- "service_data": {
- "object_id": "resume_action_false_ghresume_01gk9kh31byqfpe42g5ghsy13a",
- "name": "Entities with actions which should not be resumed",
- "icon": "mdi:alert-octagon",
- "entities": []
- },
- "target": {}
- },
- "running_script": false,
- "limit": 10
- }
- }
- ],
- "sequence/1/then/10": [
- {
- "path": "sequence/1/then/10",
- "timestamp": "2022-12-02T14:24:03.109844+00:00",
- "result": {
- "params": {
- "domain": "group",
- "service": "set",
- "service_data": {
- "object_id": "resume_active_ghresume_01gk9kh31byqfpe42g5ghsy13a",
- "name": "Entities which will be resumed by the Google Home Resume script",
- "icon": "mdi:autorenew",
- "entities": []
- },
- "target": {}
- },
- "running_script": false,
- "limit": 10
- }
- }
- ],
- "sequence/1/then/11": [
- {
- "path": "sequence/1/then/11",
- "timestamp": "2022-12-02T14:24:03.111555+00:00",
- "result": {
- "params": {
- "domain": "group",
- "service": "set",
- "service_data": {
- "object_id": "resume_script_active_ghresume_01gk9kh31byqfpe42g5ghsy13a",
- "name": "Entities currently active with Google Home Resume script",
- "icon": "mdi:play-box",
- "entities": []
- },
- "target": {}
- },
- "running_script": false,
- "limit": 10
- }
- }
- ]
- },
- "config": {
- "alias": "00 - Google Home Resume - Helper Script",
- "description": "Helper script for the Google Home Resume script",
- "icon": "mdi:cast-audio",
- "mode": "parallel",
- "max": 30,
- "sequence": [
- {
- "alias": "Variable for version number",
- "variables": {
- "version": "2022.12.0"
- }
- },
- {
- "if": "{{ action_type == 'resume' }}",
- "then": [
- {
- "variables": {
- "image": "{{\n state_attr(player.entity_id, 'media_content_id') is not none\n and (\n 'jpg' in state_attr(player.entity_id, 'media_content_id') | lower\n or 'jpeg' in state_attr(player.entity_id, 'media_content_id') | lower\n or 'png' in state_attr(player.entity_id, 'media_content_id') | lower\n or 'gif' in state_attr(player.entity_id, 'media_content_id') | lower\n or 'webp' in state_attr(player.entity_id, 'media_content_id') | lower\n )\n}}\n",
- "dashboard_cast": "{{ is_state_attr(player.entity_id, 'app_name', 'Home Assistant Lovelace') }}"
- }
- },
- {
- "alias": "State changed since script started?",
- "wait_template": "{{\n event_script\n or ytube_resume\n or (\n (states[player.entity_id].last_changed > as_datetime(start_time))\n and expand([player.entity_id] + player.members)\n | selectattr('state', 'eq', 'playing')\n | list | count > 0\n )\n or image\n or dashboard_cast\n}}\n",
- "timeout": "00:00:30"
- },
- {
- "variables": {
- "state_changed": "{{ wait.completed }}",
- "current_volume": "{{ state_attr(player.entity_id, 'volume_level') | round(2, default=0) }}",
- "data_volume": "{{ player.volume_level | round(2, default=0) }}"
- }
- },
- {
- "alias": "Add entity to the restore active group",
- "service": "group.set",
- "data": {
- "object_id": "resume_active_ghresume_{{ context.id | lower }}",
- "name": "Entities which will be resumed by the Google Home Resume script",
- "icon": "mdi:autorenew",
- "entities": "{%- set g = 'group.resume_active_ghresume_' ~ context.id | lower %} {%- set current = state_attr(g, 'entity_id') %} {%- set current = [] if current == none else current | list %} {{ ( current + [ player.entity_id ] + player.members) | unique | list }}\n"
- }
- },
- {
- "alias": "Wait until player is idle again, and all other scripts are finished",
- "wait_template": "{%- set current = expand(states.group\n | selectattr('entity_id', 'search', 'group.resume_script_target_')\n | rejectattr('entity_id', 'search', context)\n | map(attribute='entity_id')\n | list) | map(attribute='entity_id') | list\n%} {%- set checklist = [player.entity_id] + player.members %} {{\n dashboard_cast or\n expand(checklist) | rejectattr('state', 'in', ['idle', 'off', 'paused']) | list | count == 0\n and current | select('eq', player.entity_id) | list | count == 0\n}}\n"
- },
- {
- "if": "{{ image or dashboard_cast }}",
- "then": [
- {
- "delay": "{{ resume_delay }}"
- }
- ]
- },
- {
- "alias": "Restore volume in case volume has changed",
- "if": "{{ data_volume != current_volume }}",
- "then": [
- {
- "alias": "Restore volume",
- "repeat": {
- "for_each": "{{ player.members if player.type == 'group' else [ player.entity_id ] }}",
- "sequence": [
- {
- "alias": "Set volume back to old state",
- "service": "media_player.volume_set",
- "target": {
- "entity_id": "{{ repeat.item }}"
- },
- "data": {
- "volume_level": "{%- if player.type == 'group' %}\n {{ member_data | selectattr('entity_id', 'eq', repeat.item) | map(attribute='volume_level') | join }}\n{%- else %}\n {{ data_volume }}\n{%- endif %}\n"
- }
- }
- ]
- }
- }
- ]
- },
- {
- "alias": "Google Home with screen back to idle screen",
- "if": "{{ player.type == 'screen' and not resume }}",
- "then": [
- {
- "alias": "Turn Google Home off to return to idle mode (photo display)",
- "service": "media_player.turn_off",
- "target": {
- "entity_id": "{{ player.entity_id }}"
- }
- }
- ]
- },
- {
- "alias": "Resume needed?",
- "if": "{{ ytube_resume or (state_changed and resume) }}",
- "then": [
- {
- "alias": "Set variables",
- "variables": {
- "ytube_music": "{{ player.app_name == 'Ytube Music Player' }}\n",
- "spotify": "{{ player.app_name == 'Spotify' }}\n",
- "youtube": "{{ player.app_name in ['YouTube', 'YouTube Music'] }}\n",
- "podcast": "{{ player.app_name == 'Google Podcasts' }}\n",
- "stream": "{{\n player.media_content_id is defined\n and player.media_content_id.startswith('http')\n}}\n",
- "mass": "{{ player.get('mass_playing') | default(false, true) }}"
- }
- },
- {
- "alias": "Resume playing",
- "choose": [
- {
- "alias": "Music Assistant?",
- "conditions": "{{ mass }}",
- "sequence": [
- {
- "service": "mass.queue_command",
- "data": {
- "command": "snapshot_restore"
- },
- "target": {
- "entity_id": "{{ player.mass_sync }}"
- }
- }
- ]
- },
- {
- "alias": "Ytube Music?",
- "conditions": "{{ ytube_music }}",
- "sequence": [
- {
- "variables": {
- "player_ytube": "{{ player.yt_player }}"
- }
- },
- {
- "service": "ytube_music_player.call_method",
- "data": {
- "entity_id": "{{ player_ytube }}",
- "command": "interrupt_resume"
- }
- },
- {
- "alias": "Wait until song is playing",
- "wait_template": "{{ iif(state_attr(player_ytube, '_media_id')) and iif(state_attr(player_ytube, 'media_position')) }}\n",
- "timeout": "00:00:10"
- },
- {
- "alias": "Go to the right position in the track when resume is performed",
- "if": "{{ wait.completed }}",
- "then": [
- {
- "alias": "Seek",
- "service": "media_player.media_seek",
- "target": {
- "entity_id": "{{ player.entity_id }}"
- },
- "data": {
- "seek_position": "{{ [0, player.media_position - 3] | max }}\n"
- }
- }
- ]
- }
- ]
- },
- {
- "alias": "YouTube?",
- "conditions": "{{ player.type == 'screen' and youtube }}",
- "sequence": [
- {
- "alias": "Play video",
- "service": "media_player.play_media",
- "target": {
- "entity_id": "{{ player.entity_id }}"
- },
- "data": {
- "media_content_type": "cast",
- "media_content_id": "{{ dict(app_name=\"youtube\", media_id=player.media_content_id) | to_json }}"
- }
- },
- {
- "alias": "Wait until video is playing",
- "wait_template": "{{\n is_state_attr(player.entity_id, 'media_content_id', player.media_content_id)\n and iif(state_attr(player.entity_id, 'media_position'))\n}}\n",
- "timeout": "00:00:10"
- },
- {
- "alias": "Go to the right position in the track when resume is performed",
- "if": "{{ wait.completed }}",
- "then": [
- {
- "alias": "Seek",
- "service": "media_player.media_seek",
- "target": {
- "entity_id": "{{ player.entity_id }}"
- },
- "data": {
- "seek_position": "{{ [0, player.media_position - 3] | max }}\n"
- }
- }
- ]
- }
- ]
- },
- {
- "alias": "Spotify?",
- "conditions": "{{ spotify }}",
- "sequence": [
- {
- "variables": {
- "service_data": {
- "entity_id": "{{ player.entity_id }}",
- "force_playback": true
- },
- "account_data": {
- "account": "{{ player.spotcast }}"
- }
- }
- },
- {
- "alias": "Resume spotify",
- "service": "spotcast.start",
- "data": "{{ service_data if player.spotcast == 'primary_account' else dict(service_data, **account_data) }}\n"
- },
- {
- "alias": "Wait until song is playing",
- "wait_template": "{{ is_state_attr(player.entity_id, 'app_name', 'Spotify') and iif(state_attr(player.entity_id, 'media_position')) }}\n",
- "timeout": "00:00:10"
- },
- {
- "alias": "Go to the right position in the track when resume is performed",
- "if": "{{ wait.completed }}",
- "then": [
- {
- "alias": "Seek",
- "service": "media_player.media_seek",
- "target": {
- "entity_id": "{{ player.entity_id }}"
- },
- "data": {
- "seek_position": "{{ [0, player.media_position - 3] | max }}\n"
- }
- }
- ]
- }
- ]
- },
- {
- "alias": "Google Podcast?",
- "conditions": "{{ podcast }}",
- "sequence": [
- {
- "variables": {
- "picture_url": "{{ player.fixed_picture if player.fixed_picture is defined else player.entity_picture }}",
- "metadata": {
- "metadataType": 3,
- "title": "{{ player.media_title }}",
- "artist": "{{ player.media_artist }}"
- },
- "picture": {
- "images": [
- {
- "url": "{{ picture_url }}"
- }
- ]
- }
- }
- },
- {
- "alias": "Resume stream",
- "service": "media_player.play_media",
- "target": {
- "entity_id": "{{ player.entity_id }}"
- },
- "data": {
- "media_content_id": "{{ player.media_content_id }}",
- "media_content_type": "{{ player.media_content_type }}",
- "extra": {
- "metadata": "{{ metadata if picture_url == 'no pic' else dict(metadata, **picture) }}\n"
- }
- }
- },
- {
- "alias": "Wait until media_content_id is available",
- "wait_template": "{{ is_state_attr(player.entity_id, 'media_content_id', player.media_content_id) }}",
- "timeout": "00:00:10"
- },
- {
- "alias": "Go to the right position in the track when resume is performed",
- "if": "{{ wait.completed }}",
- "then": [
- {
- "alias": "Seek",
- "service": "media_player.media_seek",
- "target": {
- "entity_id": "{{ player.entity_id }}"
- },
- "data": {
- "seek_position": "{{ [0, player.media_position - 3] | max }}\n"
- }
- }
- ]
- }
- ]
- },
- {
- "alias": "Stream?",
- "conditions": "{{ stream }}",
- "sequence": [
- {
- "variables": {
- "picture_url": "{{ player.entity_picture }}",
- "metadata": {
- "metadataType": 3,
- "title": "{{ player.media_title }}",
- "artist": "{{ player.media_artist }}"
- },
- "picture": {
- "images": [
- {
- "url": "{{ picture_url }}"
- }
- ]
- }
- }
- },
- {
- "alias": "Resume stream",
- "service": "media_player.play_media",
- "target": {
- "entity_id": "{{ player.entity_id }}"
- },
- "data": {
- "media_content_id": "{{ player.media_content_id }}",
- "media_content_type": "{{ player.media_content_type }}",
- "extra": {
- "metadata": "{{ metadata if picture_url == 'no pic' else dict(metadata, **picture) }}\n"
- }
- }
- },
- {
- "alias": "Wait until media_content_id is available",
- "wait_template": "{{ is_state_attr(player.entity_id, 'media_content_id', player.media_content_id) }}",
- "timeout": "00:00:10"
- },
- {
- "alias": "Play the media to avoid long delays",
- "if": "{{ wait.completed }}",
- "then": [
- {
- "alias": "Play (avoids long delay)",
- "service": "media_player.media_play",
- "target": {
- "entity_id": "{{ player.entity_id }}"
- }
- }
- ]
- }
- ]
- }
- ]
- }
- ]
- },
- {
- "alias": "Check if resume_action_false group exists",
- "if": "{{ integration_entities('group') | select('search', 'resume_action_false_ghresume_' ~ context.id | lower) | list | count > 0 }}\n",
- "then": [
- {
- "alias": "Remove entity + members from group",
- "service": "group.set",
- "data": {
- "object_id": "resume_action_false_ghresume_{{ context.id | lower }}",
- "name": "Entities with actions which should not be resumed",
- "icon": "mdi:alert-octagon",
- "entities": "{%- set current = state_attr('group.resume_action_false_ghresume' ~ context.id | lower, 'entity_id') %} {{ iif(current == none, [], current) | reject('in', [player.entity_id] + player.members) | list }}\n"
- }
- }
- ]
- },
- {
- "alias": "Remove entity + members from group",
- "service": "group.set",
- "data": {
- "object_id": "resume_active_ghresume_{{ context.id | lower }}",
- "name": "Entities which will be resumed by the Google Home Resume script",
- "icon": "mdi:autorenew",
- "entities": "{%- set g = 'group.resume_active_ghresume_' ~ context.id | lower %} {%- set current = state_attr(g, 'entity_id') %} {{ iif(current == none, [], current) | reject('in', [player.entity_id] + player.members) | list }}\n"
- }
- },
- {
- "alias": "Remove entity + members from group",
- "service": "group.set",
- "data": {
- "object_id": "resume_script_active_ghresume_{{ context.id | lower }}",
- "name": "Entities currently active with Google Home Resume script",
- "icon": "mdi:play-box",
- "entities": "{%- set g = 'group.resume_script_active_ghresume_' ~ context.id | lower %} {%- set current = state_attr(g, 'entity_id') %} {{ iif(current == none, [], current) | reject('in', [player.entity_id] + player.members) | list }}\n"
- }
- }
- ],
- "else": [
- {
- "alias": "Wait for TTS to be sent to dummy player",
- "wait_for_trigger": [
- {
- "platform": "event",
- "event_type": "call_service",
- "event_data": {
- "domain": "media_player",
- "service": "play_media",
- "service_data": {
- "media_content_type": "music",
- "entity_id": "{{ [ dummy_player ] }}"
- }
- }
- }
- ]
- },
- {
- "alias": "Send TTS message with picture",
- "service": "media_player.play_media",
- "target": "{{ target }}",
- "data": {
- "media_content_id": "{{ wait.trigger.event.data.service_data.media_content_id }}",
- "media_content_type": "music",
- "announce": true,
- "extra": {
- "metadata": {
- "metadataType": 3,
- "title": "{{ large_text }}",
- "artist": "{{ small_text }}",
- "images": [
- {
- "url": "{{ picture_url }}"
- }
- ]
- }
- }
- }
- }
- ]
- }
- ]
- },
- "blueprint_inputs": null,
- "context": {
- "id": "01GK9KH31BYQFPE42G5GHSY13A",
- "parent_id": null,
- "user_id": "2a298aebc80446749be35680bdc494b1"
- }
- },
- "logbookEntries": [
- {
- "when": 1669991014.292642,
- "state": "on",
- "entity_id": "script.google_home_resume_helper",
- "icon": "mdi:cast-audio",
- "context_user_id": "2a298aebc80446749be35680bdc494b1"
- },
- {
- "when": 1669991023.866183,
- "state": "off",
- "entity_id": "media_player.ufficio_milena",
- "context_user_id": "2a298aebc80446749be35680bdc494b1",
- "context_state": "on",
- "context_entity_id": "script.google_home_resume_helper"
- },
- {
- "when": 1669991023.867465,
- "state": "off",
- "entity_id": "group.resume_script_active_ghresume_01gk9kh31byqfpe42g5ghsy13a",
- "icon": "mdi:play-box",
- "context_user_id": "2a298aebc80446749be35680bdc494b1",
- "context_state": "on",
- "context_entity_id": "script.google_home_resume_helper"
- },
- {
- "when": 1669991023.867604,
- "state": "off",
- "entity_id": "group.resume_action_false_ghresume_01gk9kh31byqfpe42g5ghsy13a",
- "icon": "mdi:alert-octagon",
- "context_user_id": "2a298aebc80446749be35680bdc494b1",
- "context_state": "on",
- "context_entity_id": "script.google_home_resume_helper"
- },
- {
- "when": 1669991023.867656,
- "state": "off",
- "entity_id": "group.resume_active_ghresume_01gk9kh31byqfpe42g5ghsy13a",
- "icon": "mdi:autorenew",
- "context_user_id": "2a298aebc80446749be35680bdc494b1",
- "context_state": "on",
- "context_entity_id": "script.google_home_resume_helper"
- }
- ]
- }
Add Comment
Please, Sign In to add comment