You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.6 KiB
70 lines
1.6 KiB
### 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 '<YAMAHA_AV cmd="GET"><Main_Zone><Basic_Status>GetParam</Basic_Status></Main_Zone></YAMAHA_AV>' 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 "<YAMAHA_AV cmd=\"PUT\"><Main_Zone><Volume><Lvl><Val>$1</Val><Exp>1</Exp><Unit>dB</Unit></Lvl></Volume></Main_Zone></YAMAHA_AV>" http://$YAMAHA_IP/YamahaRemoteControl/ctrl
|
|
}
|
|
|
|
power_on() {
|
|
curl -X POST -d '<YAMAHA_AV cmd="PUT"><Main_Zone><Power_Control><Power>On</Power></Power_Control></Main_Zone></YAMAHA_AV>' http://$YAMAHA_IP/YamahaRemoteControl/ctrl
|
|
}
|
|
|
|
power_off() {
|
|
curl -X POST -d '<YAMAHA_AV cmd="PUT"><Main_Zone><Power_Control><Power>Standby</Power></Power_Control></Main_Zone></YAMAHA_AV>' 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;
|
|
|
|
|