The first post here. And my first script in Home Assistant. I have installed Mopidy and Snapcast on my server and have a couple of orange pi's to run snapcastclient to get multiroom audio.
On the bathroom I have this orange pi with a 433mhz plug switch connected to the Aux in on my Pinell Supersound II Radio. I want to have a switch on the Home Assistant UI to turn the orange pi and pinell on and select the right source on the radio.
Some googling and trial and error.. I found that this is working:
I have this in the scripts.yaml file:
musikk_bad_on:
alias: musikk bad on
sequence:
- service: media_player.turn_on
entity_id:
- media_player.pinell_supersound_002261086da2
- service: switch.turn_on
entity_id:
- switch.musikk_bad_switch
- service: media_player.select_source
data:
entity_id: media_player.pinell_supersound_002261086da2
source: 'AUX inngang'
musikk_bad_off:
alias: musikk bad off
sequence:
- service: media_player.turn_off
entity_id:
- media_player.pinell_supersound_002261086da2
- service: switch.turn_off
entity_id:
- switch.musikk_bad_switch
And I did put this under switch in my configuration.yaml file.
- platform: template
switches:
musikkbad:
friendly_name: "Musikk bad"
value_template: "{{ is_state('switch.musikk_bad_switch', 'on') }}"
turn_on:
service: script.turn_on
entity_id: script.musikk_bad_on
turn_off:
service: script.turn_on
entity_id: script.musikk_bad_off
On the bathroom I have this orange pi with a 433mhz plug switch connected to the Aux in on my Pinell Supersound II Radio. I want to have a switch on the Home Assistant UI to turn the orange pi and pinell on and select the right source on the radio.
Some googling and trial and error.. I found that this is working:
I have this in the scripts.yaml file:
musikk_bad_on:
alias: musikk bad on
sequence:
- service: media_player.turn_on
entity_id:
- media_player.pinell_supersound_002261086da2
- service: switch.turn_on
entity_id:
- switch.musikk_bad_switch
- service: media_player.select_source
data:
entity_id: media_player.pinell_supersound_002261086da2
source: 'AUX inngang'
musikk_bad_off:
alias: musikk bad off
sequence:
- service: media_player.turn_off
entity_id:
- media_player.pinell_supersound_002261086da2
- service: switch.turn_off
entity_id:
- switch.musikk_bad_switch
And I did put this under switch in my configuration.yaml file.
- platform: template
switches:
musikkbad:
friendly_name: "Musikk bad"
value_template: "{{ is_state('switch.musikk_bad_switch', 'on') }}"
turn_on:
service: script.turn_on
entity_id: script.musikk_bad_on
turn_off:
service: script.turn_on
entity_id: script.musikk_bad_off