commit
e3d4d30a9d
2 changed files with 93 additions and 0 deletions
@ -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 |
||||||
|
``` |
||||||
|
|
||||||
@ -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 '<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; |
||||||
|
|
||||||
Loading…
Reference in new issue