Is there a preferred way to include custom scripts with Roieee? Perhaps something like AUR for ropieee where users can contribute extensions? Or another way all together within roon that I’ve missed?
For a bit of background, I wanted a way to turn on the amp connected to my ropieee when music is playing and turn it off when it’s not. I have various mqtt enabled switches and relays to turn the devices on and off this accomplished easy enough with the shell script below.
#!/bin/sh
SND_STATUS="/proc/asound/card1/pcm0p/sub0/status"
MQTT_TOPIC="shellies/shelly1-XXXX/relay/0/command"
MQTT_HOST="mqtt.local"
while true ; do
value=`cat $SND_STATUS | egrep 'state|closed'`
if [[ "$value" =~ "RUNNING" ]] && [[ "$status" != "on" ]] ; then
status=on
[[ -t 1 ]] && echo $status
# Fire MQTT to turn amp on
mosquitto_pub -h $MQTT_HOST -t $MQTT_TOPIC -m $status
elif [[ "$value" =~ "closed" ]] && [[ "$status" != "off" ]]; then
status=off
[[ -t 1 ]] && echo $status
# Fire MQTT to turn amp off
mosquitto_pub -h $MQTT_HOST -t $MQTT_TOPIC -m $status
fi
sleep 1
done
@GregD Thanks for that, I had a very simple hassio setup and just expanded to add this it works great.
The automation I’ve settled on in case others are wondering is:
- id: amp-off
alias: livingroom-roon-amp-off
description: turn off amp when roon is idle or paused
trigger:
- platform: state
entity_id: media_player.living_room
to: idle
- platform: state
entity_id: media_player.living_room
to: paused
condition: []
action:
- type: turn_off
device_id: 02a29b23d46740bffa6fac5d87127a91
entity_id: switch.livingroom_amp
domain: switch
mode: single
In case it helps - here is one of mine. The script pauses the player long enough for the tubes in the amp to warm up.
- alias: Hi Fi - power amp on for roon
id: roon_01
trigger:
- platform: state
entity_id: media_player.hi_fi
to: playing
for:
seconds: 3
condition:
condition: state
entity_id: switch.hi_fi_power_amp
state: 'off'
action:
- service: script.turn_on
entity_id: script.roon_hi_fi_on
I have some pending changes to the HA roon integration - which will add discovery - and a more sophisticated play_media command - which should allow you to play anything from a script.