/yamaha-receiver-api

Creates REST endpoint for invoking Yamaha Receiver API actions

Primary LanguageJavaScriptMIT LicenseMIT

API for Yamaha Receiver (RX-A730)

Stand up a REST service using Express and NodeJS (primarily) to interact with a Yamaha RX-A730 Home Theater Receiver.

Creates local webservice endpoints which process functions against the Yamaha Receiver. This can be used in conjunction with any front end client you may desire such as Google Home, Alexa, iOS shortcut, or write an app for your devices.

Supports Common usage

This is what will be wired up to Google Home Webhooks (eventually)

  • Volume Up by sending POST to /receiver/turnItUp
  • Volume Down by sending POST to /receiver/turnItDown
  • Power On by sending POST to /receiver/powerOn
  • Power Off by sending POST to /receiver/powerOff
  • Get Volume by sending GET to /receiver/getVolume
  • Get Power Status by sending GET to /receiver/getPowerStatus

Examples

All assuming that the webservice is running 192.168.1.2:6969

  • Get the current volume level

Request: curl http://192.168.1.2:6969/receiver/getVolume Response: Volume is: -350dB

  • Get the current power status

Request: curl http://192.168.1.2:6969/receiver/getPowerStatus Response: Power Status is: Standby

  • Increase the volume up by 15 DB (1.5 unit on receiver)

Request: curl -X POST http://192.168.1.2:6969/receiver/turnItUp Response: Volume adjusted from -350 to -335 successfully.

Requires

Setup

Clone this repo, install the dependencies from package.json, start the webServer.

git clone https://github.com/cps5155/yamaha-receiver-api.git

Traverse into the project folder

cd yamaha-receiver-api

Use npm to install the required libraries

npm install

Start the webserver using the appropriate syntax & supply it your yamaha-receiver's MAC address. This depends on what you're using to run

  • For Windows (git bash)
node ./lib/webServer.js -MAC=AA:BB:CC:DD:EE:FF
  • For MacOS (zshrc)
node ./lib/webServer.js --MAC=AA:BB:CC:DD:EE:FF
  • For other OS, try a combination of the above or use a lowercase mac address as needed

If you start the server on a network where the MAC address provided via CLI is not found, it will default to use localhost:80 as the "target". When you are using localhost as your target, you should be running the receiver-mockResponse.js in the background so that the mock responses are sent back to the webServer as if the receiver was on the network. Future enhancement will start the receiver-mockResponse.js as a child process of the webserver when localhost is being used (so you don't have to remember to start/stop it manually to test).

Logs can be found in ./logs/ directory.

TODO

  • any security, whatsoever
  • start mock webserver subprocess when localhost is being used
  • add init.d example for auto daemon startup on Raspi

Tested on

  • Raspi 1st gen (running Wheezy)
  • Git bash on Windows
  • Yamaha RX-A730 Home Theater Receiver