Forked from daemonp/roon-ropieee-mqtt-amp-trigger.sh
Created
September 5, 2024 08:37
-
-
Save volschin/a4e9e8398432671e2488be5f079f4aa8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # monitor asound status changes and trigger mqtt events | |
| SND_STATUS="/proc/asound/card1/pcm0p/sub0/status" | |
| MQTT_TOPIC="shellies/shelly1-xxxxx/relay/0/command" | |
| MQTT_HOST="mqtt.home" | |
| 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 on amp | |
| 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 off amp | |
| mosquitto_pub -h $MQTT_HOST -t MQTT_TOPIC -m $status | |
| fi | |
| sleep 1 | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment