I am trying to get a series of shell commands to work for my pi user inside my virtual environment. Basically, I am trying to launch mkchromecast and then start pianobar. If I run each one of commands inside the virtual environment by themselves, they work and music plays through the required casting group. But when I try and run them through HASS and the Scripts, no music plays. Is there any clear reason as to why the commands aren’t working?
clear_existing_cast: 'sudo rm -f /tmp/mkchromecast.pid'
launch_cast: 'sudo -H -u pi mkchromecast -n {%- if is_state("input_select.media_player", "home_group") -%} "Home Group" {%- elif is_state("input_select.media_player", "living_room") -%} "Living Room" {%- elif is_state("input_select.media_player", "upstairs") -%} "Upstairs" {%- endif -%}'
set_default_output: 'sudo -H -u pi pacmd set-default-sink mkchromecast'
launch_pianobar: 'sudo -H -u pi pianobar'
stop_pianobar: 'sudo -H -u pi /home/pi/.config/pianobar/control-pianobar.sh quit'
pandora_variable_on: sudo -H -u pi sed -i "s/\${u}/{{ states('variable.username') }}/;s/\${p}/{{ states('variable.password') }}/;s/\${n}/{{ states('variable.autostart') }}/;" /home/pi/.config/pianobar/config
pandora_variable_off: sudo -H -u pi sed -i "s/{{ states('variable.username') }}/\${u}/;s/{{ states('variable.password') }}/\${p}/;s/{{ states('variable.autostart')}}/\${n}/;" /home/pi/.config/pianobar/config
start_pandora:
alias: “Pandora On”
sequence:
- service: shell_command.pandora_variable_on
- service: shell_command.clear_existing_cast
- service: shell_command.launch_cast
- service: shell_command.set_default_output
- service: shell_command.launch_pianobar
stop_pandora:
alias: “Pandora Off”
sequence:
- service: shell_command.pandora_variable_off
- service: shell_command.stop_pianobar
- service: homeassistant.turn_off
data:
entity_id: media_player.home_group