Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "trace": {
- "last_step": "sequence/5/choose/0/sequence/0",
- "run_id": "945a12beb0563584b376fa83d2dd764c",
- "state": "stopped",
- "script_execution": "finished",
- "timestamp": {
- "start": "2022-03-28T09:48:02.858122+00:00",
- "finish": "2022-03-28T09:48:04.457740+00:00"
- },
- "domain": "script",
- "item_id": "google_home_resume_perform_resume",
- "trace": {
- "sequence/0": [
- {
- "path": "sequence/0",
- "timestamp": "2022-03-28T09:48:02.859270+00:00",
- "changed_variables": {
- "this": {
- "entity_id": "script.google_home_resume_perform_resume",
- "state": "off",
- "attributes": {
- "last_triggered": "2022-03-27T20:24:35.653591+00:00",
- "mode": "parallel",
- "current": 0,
- "max": 20,
- "icon": "mdi:cast-audio",
- "friendly_name": "00 🔊 Google Home Resume - Perform resume"
- },
- "last_changed": "2022-03-28T09:46:41.869785+00:00",
- "last_updated": "2022-03-28T09:46:41.869785+00:00",
- "context": {
- "id": "2aba769cc638d1a066464f9d8fd48c41",
- "parent_id": null,
- "user_id": null
- }
- },
- "start_time": "2022-03-28 12:48:02.581098+03:00",
- "player": {
- "data_source": "resume_script",
- "entity_id": "media_player.living_room_speaker",
- "state": "playing",
- "app_name": "Default Media Receiver",
- "volume_level": 0.4000000059604645,
- "media_content_id": "https://radiorecord.hostingradio.ru/chillhouse96.aacp",
- "media_title": "no title",
- "media_artist": "no artist",
- "media_content_type": "music",
- "entity_picture": "no pic",
- "media_position": 3.277478,
- "members": [],
- "type": "no screen"
- },
- "member_data": [],
- "ytube_music_data": [],
- "players_to_resume": [
- "media_player.living_room_speaker"
- ],
- "event_script": false,
- "context": {
- "id": "77149785f0e1b9898d09caa19a6572eb",
- "parent_id": null,
- "user_id": "50437e77880745a2a2a14f3daae510ee"
- }
- },
- "result": {
- "wait": {
- "remaining": 29.570904033258557,
- "completed": true
- }
- }
- }
- ],
- "sequence/1": [
- {
- "path": "sequence/1",
- "timestamp": "2022-03-28T09:48:03.294352+00:00",
- "changed_variables": {
- "wait": {
- "remaining": 29.570904033258557,
- "completed": true
- }
- },
- "result": {
- "params": {
- "domain": "group",
- "service": "set",
- "service_data": {
- "object_id": "resume_active_ghresume_77149785f0e1b9898d09caa19a6572eb",
- "name": "Entities which will be resumed by the Google Home Resume script",
- "icon": "mdi:autorenew",
- "entities": [
- "media_player.living_room_speaker"
- ]
- },
- "target": {}
- },
- "running_script": false,
- "limit": 10
- }
- }
- ],
- "sequence/2": [
- {
- "path": "sequence/2",
- "timestamp": "2022-03-28T09:48:03.299303+00:00",
- "result": {
- "choice": 0
- }
- }
- ],
- "sequence/2/choose/0": [
- {
- "path": "sequence/2/choose/0",
- "timestamp": "2022-03-28T09:48:03.300103+00:00",
- "result": {
- "result": true
- }
- }
- ],
- "sequence/2/choose/0/conditions/0": [
- {
- "path": "sequence/2/choose/0/conditions/0",
- "timestamp": "2022-03-28T09:48:03.300177+00:00",
- "result": {
- "result": true,
- "entities": []
- }
- }
- ],
- "sequence/2/choose/0/sequence/0": [
- {
- "path": "sequence/2/choose/0/sequence/0",
- "timestamp": "2022-03-28T09:48:03.301933+00:00"
- }
- ],
- "sequence/2/choose/0/sequence/1": [
- {
- "path": "sequence/2/choose/0/sequence/1",
- "timestamp": "2022-03-28T09:48:03.302786+00:00",
- "changed_variables": {
- "spotify": false,
- "youtube": false,
- "stream": true
- },
- "result": {
- "wait": {
- "remaining": null,
- "completed": true
- }
- }
- }
- ],
- "sequence/2/choose/0/sequence/2": [
- {
- "path": "sequence/2/choose/0/sequence/2",
- "timestamp": "2022-03-28T09:48:04.427900+00:00",
- "changed_variables": {
- "wait": {
- "remaining": null,
- "completed": true
- }
- }
- }
- ],
- "sequence/2/choose/0/sequence/2/choose/0": [
- {
- "path": "sequence/2/choose/0/sequence/2/choose/0",
- "timestamp": "2022-03-28T09:48:04.428467+00:00",
- "result": {
- "result": false
- }
- }
- ],
- "sequence/2/choose/0/sequence/2/choose/0/conditions/0": [
- {
- "path": "sequence/2/choose/0/sequence/2/choose/0/conditions/0",
- "timestamp": "2022-03-28T09:48:04.428540+00:00",
- "result": {
- "result": false,
- "entities": [
- "media_player.living_room_speaker"
- ]
- }
- }
- ],
- "sequence/2/choose/0/sequence/3": [
- {
- "path": "sequence/2/choose/0/sequence/3",
- "timestamp": "2022-03-28T09:48:04.429077+00:00",
- "result": {
- "choice": 2
- }
- }
- ],
- "sequence/2/choose/0/sequence/3/choose/0": [
- {
- "path": "sequence/2/choose/0/sequence/3/choose/0",
- "timestamp": "2022-03-28T09:48:04.429645+00:00",
- "result": {
- "result": false
- }
- }
- ],
- "sequence/2/choose/0/sequence/3/choose/0/conditions/0": [
- {
- "path": "sequence/2/choose/0/sequence/3/choose/0/conditions/0",
- "timestamp": "2022-03-28T09:48:04.429701+00:00",
- "result": {
- "result": false,
- "entities": []
- }
- }
- ],
- "sequence/2/choose/0/sequence/3/choose/1": [
- {
- "path": "sequence/2/choose/0/sequence/3/choose/1",
- "timestamp": "2022-03-28T09:48:04.429951+00:00",
- "result": {
- "result": false
- }
- }
- ],
- "sequence/2/choose/0/sequence/3/choose/1/conditions/0": [
- {
- "path": "sequence/2/choose/0/sequence/3/choose/1/conditions/0",
- "timestamp": "2022-03-28T09:48:04.430003+00:00",
- "result": {
- "result": false,
- "entities": []
- }
- }
- ],
- "sequence/2/choose/0/sequence/3/choose/2": [
- {
- "path": "sequence/2/choose/0/sequence/3/choose/2",
- "timestamp": "2022-03-28T09:48:04.430226+00:00",
- "result": {
- "result": true
- }
- }
- ],
- "sequence/2/choose/0/sequence/3/choose/2/conditions/0": [
- {
- "path": "sequence/2/choose/0/sequence/3/choose/2/conditions/0",
- "timestamp": "2022-03-28T09:48:04.430274+00:00",
- "result": {
- "result": true,
- "entities": []
- }
- }
- ],
- "sequence/2/choose/0/sequence/3/choose/2/sequence/0": [
- {
- "path": "sequence/2/choose/0/sequence/3/choose/2/sequence/0",
- "timestamp": "2022-03-28T09:48:04.431774+00:00"
- }
- ],
- "sequence/2/choose/0/sequence/3/choose/2/sequence/1": [
- {
- "path": "sequence/2/choose/0/sequence/3/choose/2/sequence/1",
- "timestamp": "2022-03-28T09:48:04.432640+00:00",
- "changed_variables": {
- "picture_url": "no pic",
- "metadata": {
- "metadataType": 3,
- "title": "no title",
- "artist": "no artist"
- },
- "picture": {
- "images": [
- {
- "url": "no pic"
- }
- ]
- }
- },
- "result": {
- "params": {
- "domain": "media_player",
- "service": "play_media",
- "service_data": {
- "media_content_id": "https://radiorecord.hostingradio.ru/chillhouse96.aacp",
- "media_content_type": "music",
- "extra": {
- "metadata": ""
- },
- "entity_id": [
- "media_player.living_room_speaker"
- ]
- },
- "target": {
- "entity_id": [
- "media_player.living_room_speaker"
- ]
- }
- },
- "running_script": false,
- "limit": 10
- }
- }
- ],
- "sequence/3": [
- {
- "path": "sequence/3",
- "timestamp": "2022-03-28T09:48:04.440730+00:00",
- "result": {
- "choice": 0
- }
- }
- ],
- "sequence/3/choose/0": [
- {
- "path": "sequence/3/choose/0",
- "timestamp": "2022-03-28T09:48:04.441063+00:00",
- "result": {
- "result": true
- }
- }
- ],
- "sequence/3/choose/0/conditions/0": [
- {
- "path": "sequence/3/choose/0/conditions/0",
- "timestamp": "2022-03-28T09:48:04.441112+00:00",
- "result": {
- "result": true,
- "entities": []
- }
- }
- ],
- "sequence/3/choose/0/sequence/0": [
- {
- "path": "sequence/3/choose/0/sequence/0",
- "timestamp": "2022-03-28T09:48:04.442498+00:00",
- "result": {
- "params": {
- "domain": "group",
- "service": "set",
- "service_data": {
- "object_id": "resume_action_false_ghresume_77149785f0e1b9898d09caa19a6572eb",
- "name": "Entities with actions which should not be resumed",
- "icon": "mdi:alert-octagon",
- "entities": []
- },
- "target": {}
- },
- "running_script": false,
- "limit": 10
- }
- }
- ],
- "sequence/4": [
- {
- "path": "sequence/4",
- "timestamp": "2022-03-28T09:48:04.445953+00:00",
- "result": {
- "params": {
- "domain": "group",
- "service": "set",
- "service_data": {
- "object_id": "resume_active_ghresume_77149785f0e1b9898d09caa19a6572eb",
- "name": "Entities currently active with Google Home Resume script",
- "icon": "mdi:autorenew",
- "entities": []
- },
- "target": {}
- },
- "running_script": false,
- "limit": 10
- }
- }
- ],
- "sequence/5": [
- {
- "path": "sequence/5",
- "timestamp": "2022-03-28T09:48:04.450496+00:00",
- "result": {
- "choice": 0
- }
- }
- ],
- "sequence/5/choose/0": [
- {
- "path": "sequence/5/choose/0",
- "timestamp": "2022-03-28T09:48:04.450869+00:00",
- "result": {
- "result": true
- }
- }
- ],
- "sequence/5/choose/0/conditions/0": [
- {
- "path": "sequence/5/choose/0/conditions/0",
- "timestamp": "2022-03-28T09:48:04.450924+00:00",
- "result": {
- "result": true,
- "entities": []
- }
- }
- ],
- "sequence/5/choose/0/sequence/0": [
- {
- "path": "sequence/5/choose/0/sequence/0",
- "timestamp": "2022-03-28T09:48:04.452447+00:00",
- "result": {
- "params": {
- "domain": "group",
- "service": "set",
- "service_data": {
- "object_id": "resume_script_active_ghresume_77149785f0e1b9898d09caa19a6572eb",
- "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 - Perform resume",
- "description": "Helper script to perform the resume for the Google Home Resume script",
- "icon": "mdi:cast-audio",
- "mode": "parallel",
- "max": 20,
- "sequence": [
- {
- "alias": "State changed since script started?",
- "wait_template": "{{ event_script or \n ((states[player.entity_id].last_changed > as_datetime(start_time)) and is_state(player.entity_id, 'playing')) \n}}\n",
- "timeout": "00:00:30"
- },
- {
- "alias": "Add entity to the resume active group",
- "service": "group.set",
- "data": {
- "object_id": "resume_active_ghresume_{{ context.id }}",
- "name": "Entities which will be resumed by the Google Home Resume script",
- "icon": "mdi:autorenew",
- "entities": "{%- set current = state_attr('group.resume_active', 'entity_id') %} {%- set current = [] if current == none else current | list %} {{ \n ( current + [ player.entity_id ] ) | unique | list\n}}\n"
- }
- },
- {
- "alias": "Resume needed?",
- "choose": [
- {
- "conditions": [
- {
- "alias": "State changed since script started?",
- "condition": "template",
- "value_template": "{{ wait.completed }}"
- }
- ],
- "sequence": [
- {
- "alias": "Set variables",
- "variables": {
- "spotify": "{{ player.app_name == 'Spotify' }}\n",
- "youtube": "{{ player.app_name in ['YouTube', 'YouTube Music'] }}\n",
- "stream": "{%- set y = ytube_music_data\n | rejectattr('target', 'in', players_to_resume)\n | map(attribute='target')\n | list\n%} {{\n player.media_content_id is defined\n and player.media_content_id.startswith('http')\n and not player.entity_id in y\n}}\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 expand(checklist) | rejectattr('state', 'in', ['idle', 'off']) | list | count == 0\n and current | select('eq', player.entity_id) | list | count == 0\n}}\n"
- },
- {
- "alias": "Set volume to old volume if needed",
- "choose": [
- {
- "conditions": [
- {
- "alias": "Volume restore needed",
- "condition": "template",
- "value_template": "{{\n player.volume_level | round(2, default=0)\n != state_attr(player.entity_id, 'volume_level') | round(2, default=0)\n}}\n"
- }
- ],
- "sequence": [
- {
- "alias": "Player is group?",
- "choose": [
- {
- "conditions": "{{ player.type == 'group' }}",
- "sequence": [
- {
- "alias": "Restore volume of members",
- "repeat": {
- "count": "{{ player.members | count }}",
- "sequence": [
- {
- "alias": "Set volume back to old state",
- "service": "media_player.volume_set",
- "target": {
- "entity_id": "{{ player.members[repeat.index -1] }}"
- },
- "data": {
- "volume_level": "{{\n member_data\n | selectattr('entity_id', 'eq', player.members[repeat.index-1])\n | map(attribute='volume_level')\n | join\n}}\n"
- }
- }
- ]
- }
- }
- ]
- }
- ],
- "default": [
- {
- "alias": "Set volume back to old state",
- "service": "media_player.volume_set",
- "target": {
- "entity_id": "{{ player.entity_id }}"
- },
- "data": {
- "volume_level": "{{ player.volume_level }}"
- }
- }
- ]
- }
- ]
- }
- ]
- },
- {
- "alias": "Resume playing",
- "choose": [
- {
- "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": " { \"app_name\": \"youtube\", \"media_id\": \"{{ player.media_content_id }}\" }"
- }
- },
- {
- "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"
- },
- {
- "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": [
- {
- "alias": "Primary spotcast account?",
- "choose": [
- {
- "conditions": "{{ player.spotcast == 'primary_account' }}",
- "sequence": [
- {
- "alias": "Resume spotify with primary spotcast account",
- "service": "spotcast.start",
- "data": {
- "entity_id": "{{ player.entity_id }}",
- "force_playback": true
- }
- }
- ]
- }
- ],
- "default": [
- {
- "alias": "Resume spotify with specific account",
- "service": "spotcast.start",
- "data": {
- "entity_id": "{{ player.entity_id }}",
- "account": "{{ player.spotcast }}",
- "force_playback": true
- }
- }
- ]
- }
- ]
- },
- {
- "alias": "Stream?",
- "conditions": "{{ stream }}",
- "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": "{{ medadata if picture_url == 'no pic' else dict(metadata, **picture) }}\n"
- }
- }
- }
- ]
- }
- ]
- }
- ]
- }
- ]
- },
- {
- "alias": "Check if resume_action_false group exists",
- "choose": [
- {
- "conditions": "{{ \n integration_entities('group') \n | select('search', 'resume_action_false_ghresume_' ~ context.id)\n | list \n | count > 0 \n}}\n",
- "sequence": [
- {
- "alias": "Remove entity from group",
- "service": "group.set",
- "data": {
- "object_id": "resume_action_false_ghresume_{{ context.id }}",
- "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, 'entity_id') %} {{ iif(current == none, [], current) | reject('eq', player.entity_id) | list }}\n"
- }
- }
- ]
- }
- ]
- },
- {
- "alias": "Remove entity from group",
- "service": "group.set",
- "data": {
- "object_id": "resume_active_ghresume_{{ context.id }}",
- "name": "Entities currently active with Google Home Resume script",
- "icon": "mdi:autorenew",
- "entities": "{%- set current = state_attr('group.resume_active', 'entity_id') %} {{ iif(current == none, [], current) | reject('eq', player.entity_id) | list }}\n"
- }
- },
- {
- "alias": "Check if resume_script_active group exists",
- "choose": [
- {
- "conditions": "{{ \n integration_entities('group') \n | select('search', 'resume_script_active_ghresume_' ~ context.id)\n | list \n | count > 0 \n}}\n",
- "sequence": [
- {
- "alias": "Remove entity from group",
- "service": "group.set",
- "data": {
- "object_id": "resume_script_active_ghresume_{{ context.id }}",
- "name": "Entities currently active with Google Home Resume script",
- "icon": "mdi:play-box",
- "entities": "{%- set current = state_attr('group.resume_active_ghresume' ~ context.id, 'entity_id') %} {{ iif(current == none, [], current) | reject('eq', player.entity_id) | list }}\n"
- }
- }
- ]
- }
- ]
- }
- ]
- },
- "blueprint_inputs": null,
- "context": {
- "id": "77149785f0e1b9898d09caa19a6572eb",
- "parent_id": null,
- "user_id": "50437e77880745a2a2a14f3daae510ee"
- }
- },
- "logbookEntries": [
- {
- "when": "2022-03-28T09:48:02.858349+00:00",
- "name": "00 🔊 Google Home Resume - Perform resume",
- "state": "on",
- "entity_id": "script.google_home_resume_perform_resume",
- "icon": "mdi:cast-audio",
- "context_user_id": "50437e77880745a2a2a14f3daae510ee",
- "message": "turned on"
- },
- {
- "when": "2022-03-28T09:48:02.918672+00:00",
- "name": "Living Room speaker",
- "state": "idle",
- "entity_id": "media_player.living_room_speaker",
- "context_user_id": "50437e77880745a2a2a14f3daae510ee",
- "context_entity_id": "script.google_home_resume_perform_resume",
- "context_entity_id_name": "00 🔊 Google Home Resume - Perform resume",
- "context_event_type": "state_changed",
- "message": "changed to Idle"
- },
- {
- "when": "2022-03-28T09:48:03.288104+00:00",
- "name": "Living Room speaker",
- "state": "playing",
- "entity_id": "media_player.living_room_speaker",
- "context_user_id": "50437e77880745a2a2a14f3daae510ee",
- "context_entity_id": "script.google_home_resume_perform_resume",
- "context_entity_id_name": "00 🔊 Google Home Resume - Perform resume",
- "context_event_type": "state_changed",
- "message": "changed to Playing"
- },
- {
- "when": "2022-03-28T09:48:04.423581+00:00",
- "name": "Living Room speaker",
- "state": "idle",
- "entity_id": "media_player.living_room_speaker",
- "context_user_id": "50437e77880745a2a2a14f3daae510ee",
- "context_entity_id": "script.google_home_resume_perform_resume",
- "context_entity_id_name": "00 🔊 Google Home Resume - Perform resume",
- "context_event_type": "state_changed",
- "message": "changed to Idle"
- },
- {
- "when": "2022-03-28T09:48:04.455943+00:00",
- "name": "00 🔊 Google Home Resume - Perform resume",
- "state": "off",
- "entity_id": "script.google_home_resume_perform_resume",
- "icon": "mdi:cast-audio",
- "context_user_id": "50437e77880745a2a2a14f3daae510ee",
- "context_entity_id": "script.google_home_resume_perform_resume",
- "context_entity_id_name": "00 🔊 Google Home Resume - Perform resume",
- "context_event_type": "state_changed",
- "message": "turned off"
- },
- {
- "when": "2022-03-28T09:48:04.889294+00:00",
- "name": "00 🔊 Google Home Resume",
- "state": "off",
- "entity_id": "script.google_home_resume",
- "icon": "mdi:cast-audio",
- "context_user_id": "50437e77880745a2a2a14f3daae510ee",
- "context_entity_id": "script.google_home_resume_perform_resume",
- "context_entity_id_name": "00 🔊 Google Home Resume - Perform resume",
- "context_event_type": "state_changed",
- "message": "turned off"
- },
- {
- "when": "2022-03-28T09:48:04.891411+00:00",
- "name": "TTS TEST",
- "state": "off",
- "entity_id": "script.tts_2",
- "context_user_id": "50437e77880745a2a2a14f3daae510ee",
- "context_entity_id": "script.google_home_resume_perform_resume",
- "context_entity_id_name": "00 🔊 Google Home Resume - Perform resume",
- "context_event_type": "state_changed",
- "message": "turned off"
- },
- {
- "when": "2022-03-28T09:48:05.252872+00:00",
- "name": "Living Room speaker",
- "state": "playing",
- "entity_id": "media_player.living_room_speaker",
- "context_user_id": "50437e77880745a2a2a14f3daae510ee",
- "context_entity_id": "script.google_home_resume_perform_resume",
- "context_entity_id_name": "00 🔊 Google Home Resume - Perform resume",
- "context_event_type": "state_changed",
- "message": "changed to Playing"
- }
- ]
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement