358 lines
10 KiB
YAML
358 lines
10 KiB
YAML
- alias: Musicbox - Controls
|
|
description: ''
|
|
triggers:
|
|
- topic: musicbox/controls
|
|
trigger: mqtt
|
|
conditions: []
|
|
actions:
|
|
- variables:
|
|
action: '{{ trigger.payload }}'
|
|
- choose:
|
|
- alias: Volume Up
|
|
conditions:
|
|
- condition: template
|
|
value_template: '{{ action == ''volume_up'' }}'
|
|
sequence:
|
|
- action: media_player.volume_up
|
|
metadata: {}
|
|
data: {}
|
|
target:
|
|
entity_id:
|
|
- media_player.spotify_tobias_munzert
|
|
- media_player.music_player_daemon
|
|
- media_player.49pus6401
|
|
- alias: Volume Down
|
|
conditions:
|
|
- condition: template
|
|
value_template: '{{ action == ''volume_down'' }}'
|
|
sequence:
|
|
- action: media_player.volume_down
|
|
metadata: {}
|
|
data: {}
|
|
target:
|
|
entity_id:
|
|
- media_player.49pus6401
|
|
- media_player.music_player_daemon
|
|
- media_player.spotify_tobias_munzert
|
|
- alias: Repeat (Play/Pause)
|
|
conditions:
|
|
- condition: template
|
|
value_template: '{{ action == ''playpause'' }}'
|
|
sequence:
|
|
- choose:
|
|
- conditions:
|
|
- condition: state
|
|
entity_id: media_player.music_player_daemon
|
|
attribute: repeat
|
|
state: all
|
|
sequence:
|
|
- action: media_player.repeat_set
|
|
metadata: {}
|
|
data:
|
|
repeat: one
|
|
target:
|
|
entity_id:
|
|
- media_player.music_player_daemon
|
|
- media_player.spotify_tobias_munzert
|
|
default:
|
|
- action: media_player.repeat_set
|
|
metadata: {}
|
|
data:
|
|
repeat: all
|
|
target:
|
|
entity_id:
|
|
- media_player.music_player_daemon
|
|
- choose:
|
|
- conditions:
|
|
- condition: state
|
|
entity_id: media_player.spotify_tobias_munzert
|
|
attribute: source
|
|
state: sk61
|
|
sequence:
|
|
- action: media_player.repeat_set
|
|
metadata: {}
|
|
data:
|
|
repeat: one
|
|
target:
|
|
entity_id: media_player.spotify_tobias_munzert
|
|
- alias: Previous Song
|
|
conditions:
|
|
- condition: template
|
|
value_template: '{{ action == ''prev'' }}'
|
|
sequence:
|
|
- choose:
|
|
- conditions:
|
|
- condition: device
|
|
device_id: 524a3b4d21dbe5984af4e0b2bd2c3a5d
|
|
domain: media_player
|
|
entity_id: 81920bfa76a06fe06068b75dfb2b912b
|
|
type: is_playing
|
|
sequence:
|
|
- action: media_player.media_previous_track
|
|
metadata: {}
|
|
data: {}
|
|
target:
|
|
entity_id: media_player.music_player_daemon
|
|
- conditions:
|
|
- condition: device
|
|
device_id: a5ba5cb5fa2d0828600fca7fd1d30e2e
|
|
domain: media_player
|
|
entity_id: 44286d1faf0e2fd39b95ed26fe57cdcb
|
|
type: is_playing
|
|
- condition: state
|
|
entity_id: media_player.spotify_tobias_munzert
|
|
attribute: source
|
|
state: sk61
|
|
sequence:
|
|
- action: media_player.media_previous_track
|
|
metadata: {}
|
|
data: {}
|
|
target:
|
|
entity_id: media_player.spotify_tobias_munzert
|
|
- alias: Next Song
|
|
conditions:
|
|
- condition: template
|
|
value_template: '{{ action == ''next'' }}'
|
|
sequence:
|
|
- choose:
|
|
- conditions:
|
|
- condition: device
|
|
device_id: 524a3b4d21dbe5984af4e0b2bd2c3a5d
|
|
domain: media_player
|
|
entity_id: 81920bfa76a06fe06068b75dfb2b912b
|
|
type: is_playing
|
|
sequence:
|
|
- action: media_player.media_next_track
|
|
metadata: {}
|
|
data: {}
|
|
target:
|
|
entity_id: media_player.music_player_daemon
|
|
- conditions:
|
|
- condition: device
|
|
device_id: a5ba5cb5fa2d0828600fca7fd1d30e2e
|
|
domain: media_player
|
|
entity_id: 44286d1faf0e2fd39b95ed26fe57cdcb
|
|
type: is_playing
|
|
- condition: state
|
|
entity_id: media_player.spotify_tobias_munzert
|
|
attribute: source
|
|
state: sk61
|
|
sequence:
|
|
- action: media_player.media_next_track
|
|
metadata: {}
|
|
data: {}
|
|
target:
|
|
entity_id: media_player.spotify_tobias_munzert
|
|
default:
|
|
- action: system_log.write
|
|
metadata: {}
|
|
data:
|
|
level: error
|
|
message: 'Unknown action: {{ action }}'
|
|
mode: single
|
|
- alias: Musicbox MPD Single Playback
|
|
description: Pause other media players when one starts playing.
|
|
triggers:
|
|
- entity_id:
|
|
- media_player.music_player_daemon
|
|
to: playing
|
|
trigger: state
|
|
conditions:
|
|
- condition: state
|
|
entity_id: media_player.spotify_tobias_munzert
|
|
attribute: source
|
|
state: sk61
|
|
actions:
|
|
- action: media_player.media_pause
|
|
metadata: {}
|
|
data: {}
|
|
target:
|
|
entity_id: media_player.spotify_tobias_munzert
|
|
mode: single
|
|
- alias: Musicbox - Playback Controller
|
|
description: ''
|
|
triggers:
|
|
- topic: musicbox/playback
|
|
trigger: mqtt
|
|
actions:
|
|
- variables:
|
|
data: '{{ trigger.payload | from_json }}
|
|
|
|
'
|
|
data_id: '{{ data.id }}
|
|
|
|
'
|
|
action: '{{ data.action }}
|
|
|
|
'
|
|
content_tag: '{{ data.content }}
|
|
|
|
'
|
|
content_ha: '{{ state_attr(''tag.'' + (data_id | string), ''friendly_name'')
|
|
}}
|
|
|
|
'
|
|
content: '{{ content_tag or content_ha}}
|
|
|
|
'
|
|
content_uri: '{{ content.split('':'') }}
|
|
|
|
'
|
|
content_domain: '{{ content_uri[0] }}
|
|
|
|
'
|
|
content_type: '{{ content_uri[1] }}
|
|
|
|
'
|
|
content_id: '{{ content_uri[2] }}
|
|
|
|
'
|
|
- choose:
|
|
- conditions:
|
|
- condition: template
|
|
value_template: '{{ content_ha == ''Tag '' + (data_id | string) }}'
|
|
- condition: template
|
|
value_template: '{{ content_tag != '''' }}'
|
|
sequence: []
|
|
- choose:
|
|
- conditions:
|
|
- condition: template
|
|
value_template: '{{ action == ''start_playback'' }}'
|
|
alias: action == 'start_playback'
|
|
sequence:
|
|
- alias: Start Playback
|
|
choose:
|
|
- conditions:
|
|
- condition: template
|
|
value_template: '{{ content_domain == ''spotify'' }}'
|
|
alias: content_domain == 'spotify'
|
|
sequence:
|
|
- action: automation.trigger
|
|
metadata: {}
|
|
data:
|
|
variables:
|
|
content: '{{ content }}'
|
|
content_type: '{{ content_type }}'
|
|
content_id: '{{ content_id }}'
|
|
target:
|
|
entity_id: automation.musicbox_spotify_start_playback
|
|
alias: Trigger Spotify Start Playback
|
|
alias: Domain - Spotify
|
|
- conditions:
|
|
- condition: template
|
|
value_template: '{{ content_domain == ''mpd'' }}'
|
|
alias: content_domain == 'mpd'
|
|
sequence:
|
|
- action: automation.trigger
|
|
metadata: {}
|
|
data:
|
|
variables:
|
|
content: '{{ content }}'
|
|
content_type: '{{ content_type }}'
|
|
content_id: '{{ content_id }}'
|
|
target:
|
|
entity_id: automation.musicbox_start_playback_mpd
|
|
alias: Trigger MPD Start Playback
|
|
alias: Domain - MPD
|
|
alias: Action - Start Playback
|
|
- conditions:
|
|
- condition: template
|
|
value_template: '{{ action == ''resume_playback'' }}'
|
|
alias: action == 'resume_playback'
|
|
sequence:
|
|
- alias: Resume Playback
|
|
choose:
|
|
- conditions:
|
|
- condition: template
|
|
value_template: '{{ content_domain == ''spotify'' }}'
|
|
alias: content_domain == 'spotify'
|
|
sequence:
|
|
- action: automation.trigger
|
|
metadata: {}
|
|
data:
|
|
variables:
|
|
content: '{{ content }}'
|
|
target:
|
|
entity_id: automation.musicbox_spotify_resume_playback
|
|
alias: Trigger Spotify Resume Playback
|
|
alias: Domain - Spotify
|
|
- conditions:
|
|
- condition: template
|
|
value_template: '{{ content_domain == ''mpd'' }}'
|
|
alias: content_domain == 'mpd'
|
|
sequence:
|
|
- action: automation.trigger
|
|
metadata: {}
|
|
data:
|
|
variables:
|
|
content: '{{ content }}'
|
|
target:
|
|
entity_id: automation.musicbox_mpd_resume_playback
|
|
alias: Trigger MPD Resume Playback
|
|
alias: Domain - MPD
|
|
alias: Action - Resume Playback
|
|
- conditions:
|
|
- condition: template
|
|
value_template: '{{ action == ''pause_playback'' }}'
|
|
alias: action == 'pause_playback'
|
|
sequence:
|
|
- alias: Pause Playback
|
|
choose:
|
|
- conditions:
|
|
- condition: template
|
|
value_template: '{{ content_domain == ''spotify'' }}'
|
|
alias: content_domain == 'spotify'
|
|
sequence:
|
|
- action: automation.trigger
|
|
metadata: {}
|
|
data:
|
|
variables:
|
|
content: '{{ content }}'
|
|
target:
|
|
entity_id: automation.musicbox_spotify_pause_playback
|
|
alias: Trigger Spotify Pause Playback
|
|
alias: Domain - Spotify
|
|
- conditions:
|
|
- condition: template
|
|
value_template: '{{ content_domain == ''mpd'' }}'
|
|
alias: content_domain == 'mpd'
|
|
sequence:
|
|
- action: automation.trigger
|
|
metadata: {}
|
|
data:
|
|
variables:
|
|
content: '{{ content }}'
|
|
target:
|
|
entity_id: automation.musicbox_mpd_pause_playback
|
|
alias: Trigger MPD Pause Playback
|
|
alias: Domain - MPD
|
|
alias: Action - Pause Playback
|
|
default:
|
|
- data:
|
|
name: Musicbox Controller
|
|
message: 'Unsupported action {{ action }} or domain {{ content_domain }}
|
|
|
|
'
|
|
action: logbook.log
|
|
alias: Log Unsupported
|
|
mode: single
|
|
- alias: Musicbox Spotify Single Playback
|
|
description: Pause other media players when one starts playing.
|
|
triggers:
|
|
- entity_id:
|
|
- media_player.spotify_tobias_munzert
|
|
to: playing
|
|
trigger: state
|
|
conditions:
|
|
- condition: state
|
|
entity_id: media_player.spotify_tobias_munzert
|
|
attribute: source
|
|
state: sk61
|
|
actions:
|
|
- action: media_player.media_pause
|
|
metadata: {}
|
|
data: {}
|
|
target:
|
|
entity_id: media_player.music_player_daemon
|
|
mode: single
|