From e3d4d30a9d20cf66070ab02863dbdc4851cd3cdb Mon Sep 17 00:00:00 2001 From: czoczo Date: Thu, 23 May 2019 21:41:42 +0200 Subject: [PATCH] Initial commit --- README.md | 23 +++++++++++++++++ yamahactrl.sh | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 README.md create mode 100755 yamahactrl.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..501d6fc --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# yamahactrl + +## What is it? +Small simple bash script for basic control of Yamaha RX-V amplituner series. + +## Why? +I've written it just because the only other application I found was written in node js, which I've found to be an overkill for my simple needs. + +If you need more functionality, you should probably check out this: https://github.com/ttu/node-yamaha-avr + +## Usage +``` +./yamahactrl.sh +Bash script to control Yamaha Amplituner RX-V series. +Usage: ./yamaha.sh command + +Possible commands: + -volup Set volume up by 1 + -voldown Set volume down by 1 + -on Set power on + -off Set power off +``` + diff --git a/yamahactrl.sh b/yamahactrl.sh new file mode 100755 index 0000000..123df72 --- /dev/null +++ b/yamahactrl.sh @@ -0,0 +1,70 @@ +### CONFIG + +YAMAHA_IP="192.168.0.50" + +### END CONFIG +read_dom() { + local IFS=\> + read -d \< ENTITY CONTENT +} +get_volume() { + while read_dom; do + if [[ $ENTITY = "Val" ]]; then + echo $CONTENT + exit + fi + done < <(curl -s -X POST -d 'GetParam' http://$YAMAHA_IP/YamahaRemoteControl/ctrl) +} + +volume_up() { + set_volume "$(( $(get_volume) - 10 ))" +} + +volume_down() { + set_volume "$(( $(get_volume) + 10 ))" +} + +set_volume() { + curl -s -X POST -d "$11dB" http://$YAMAHA_IP/YamahaRemoteControl/ctrl +} + +power_on() { + curl -X POST -d 'On' http://$YAMAHA_IP/YamahaRemoteControl/ctrl +} + +power_off() { + curl -X POST -d 'Standby' http://$YAMAHA_IP/YamahaRemoteControl/ctrl +} + +print_help() { + echo -e "Bash script to control Yamaha Amplituner RX-V series." + echo -e "Usage: $0 command\n" + echo -e "Possible commands:" + echo -e " -volup\t\t Set volume up by 1" + echo -e " -voldown\t Set volume down by 1" + echo -e " -on\t\t Set power on" + echo -e " -off\t\t Set power off" + exit 0 +} + +# check arguments +case "$1" in + -on) + power_on + ;; + -off) + power_off + ;; + -volup) + volume_up + ;; + -voldown) + volume_down + ;; + *) + print_help +esac + + +exit 0; +