#!/bin/bash
### 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
}
set_input() {
echo "dsfsd $1"
curl -s -X POST -d "HDMI$1" 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 " -input \t Set input source 1-4"
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
;;
-input)
set_input "$2"
;;
*)
print_help
esac
exit 0;