Code Monkey home page Code Monkey logo

yamaha-nodejs's Introduction

Yamaha-nodejs

NPM Downloads Dependency Status

A node module to control your yamaha receiver. Tested with RX-V775, should work with all yamaha receivers with a network interface.

Install

npm install yamaha-nodejs

Example

var YamahaAPI = require("yamaha-nodejs");
var yamaha = new YamahaAPI("192.168.0.100");
yamaha.powerOn().then(function(){
	console.log("powerOn");
	yamaha.setMainInputTo("NET RADIO").then( function(){
		console.log("Switched to Net Radio");
		yamaha.selectWebRadioListItem(1).then(function(){
			console.log("Selected Favorites");
			yamaha.selectWebRadioListItem(1).then(function(){});
		});

	});
});

Prerequisites

  • To power on the yamaha, network standby has to be enabled
  • The Yamaha reveiver is stateful. Some commands only work work if the receiver is in the right state. E.g. to get web radio channels, the "NET RADIO" input has to be selected.

Methods

var yamaha = new Yamaha("192.168.0.100")
var yamaha = new Yamaha() // Auto-Discovery
yamaha.powerOff(zone) // or "System" for sytem power
yamaha.powerOn(zone)  // or "System" for sytem power
yamaha.isOn(zone)
yamaha.isOff(zone)

//Volume
yamaha.setVolumeTo(-500, zone) // Value must be divisble by 5 or value will be rejected
yamaha.volumeUp(50, zone)
yamaha.volumeDown(50, zone)
yamaha.muteOn(zone)
yamaha.muteOff(zone)

//Extended Volume Settings
yamaha.setBassTo(60)          //-60 to 60 (may depend on model)
yamaha.setTrebleTo(60)        //-60 to 60 (may depend on model)
yamaha.setSubwooferTrimTo(60) //-60 to 60 (may depend on model)
yamaha.setDialogLiftTo(5)     //0 to 5 (may depend on model)
yamaha.setDialogLevelTo(3)    //0 to 3 (may depend on model)
yamaha.YPAOVolumeOn()
yamaha.YPAOVolumeOff()
yamaha.extraBassOn()
yamaha.extraBassOff()
yamaha.adaptiveDRCOn()
yamaha.adaptiveDRCOff()

//Playback
yamaha.stop(zone)
yamaha.pause(zone)
yamaha.play(zone)
yamaha.skip(zone)
yamaha.rewind(zone)

//Remote (Case Sensitive Values)
yamaha.remoteCursor(command) // 'Up', 'Down', 'Left', 'Right', 'Return', 'Sel'
yamaha.remoteMenu(command)   // 'Option', 'Display'

//Switch Input
yamaha.setInputTo("USB", 2)
yamaha.setMainInputTo("NET RADIO")

//Party Mode
yamaha.partyModeOn()
yamaha.partyModeOff()
yamaha.partyModeUp()
yamaha.partyModeDown()

//Basic
yamaha.SendXMLToReceiver()

//Get Info
yamaha.getBasicInfo(zone).done(function(basicInfo){
    basicInfo.getVolume();
    basicInfo.isMuted();
    basicInfo.isOn();
    basicInfo.isOff();
    basicInfo.getCurrentInput();
    basicInfo.isPartyModeEnabled();
    basicInfo.isPureDirectEnabled();
    basicInfo.getBass();
    basicInfo.getTreble();
    basicInfo.getSubwooferTrim();
    basicInfo.getDialogueLift();
    basicInfo.getDialogueLevel();
		basicInfo.getZone();
    basicInfo.isYPAOVolumeEnabled();
    basicInfo.isExtraBassEnabled();
    basicInfo.isAdaptiveDRCEnabled();
})

yamaha.isHeadphoneConnected()
yamaha.getSystemConfig()
yamaha.getAvailableInputs()
yamaha.isMenuReady("NET_RADIO")

// FM Tuner
yamaha.getTunerInfo()
yamaha.getTunerPresetList()
yamaha.selectTunerPreset(1)
yamaha.selectTunerFrequency(band, frequency)

//Select Menu Items
yamaha.selectUSBListItem(1)
yamaha.selectWebRadioListItem(1)

// Single Commands, receiver has to be in the right state
yamaha.getWebRadioList()
yamaha.selectWebRadioListItem(1)

// Chained Commands, they ensure the receiver is in the right state
yamaha.switchToFavoriteNumber()
yamaha.gotoFolder('/NET_RADIO/Radio/Favorites', 'NET_RADIO')

// Find the index of a list item to select using the name of the item,
// returns -1 if not found. Will move the list page down so index will always
// between 1 and 8.
yamaha.getIndexOfMenuItem(
    await yamaha.getWebRadioList(), 
    'BBC Radio 1', 
    'NET_RADIO'
)

// Zone Commands
yamaha.getAvailableZones()
yamaha.getZoneConfig(zone)

Zones

The zone parameter is optional, you can pass a number or a string

Promises

All these methods return a promise:

yamaha.isOn().then(function(result){
	console.log("Receiver is:"+result);
})

Execute Tests

mocha mochatest.js --ip 192.168.0.25
or with autodiscovery
mocha mochatest.js

Discovery

If the IP is omitted in the constructor, the module will try to discover the yamaha ip via a SSDP call. Thanks @soef @mwittig

Changelog

0.8:

  • FIX Remove get request delays

yamaha-nodejs's People

Contributors

pseitz avatar northernman54 avatar acdr avatar maxcanna avatar charlie89 avatar anthony-ngu avatar alanbacon avatar novagl avatar pietervisser avatar soef avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.