Giter VIP home page Giter VIP logo

onkyo.js's Introduction

onkyo.js

CircleCI NPM dependencies Status Coverage Status Greenkeeper

NPM

Promise based library and cli to control Onkyo & Pioneer AV-receivers via EISCMP protocol.

Tested with TX-NR809

Changes log:

See releases here

CLI

NOTE: To use cli it's recommend to install library globally (npm i -g onkyo.js). Otherwise you can start cli by calling ./cli.js in project root folder.

$ onkyo.js

Keys
1 - set FM
2 - set CBL/SAT
3 - set BD/DVD
5 - set CD
6 - set NET
+ - volUp
- - volDown
p - pwrToggle
c - set ÇD
s - set Stereo
d - set direct
t - set Thx
m - toggle Mute
ctrl+c - Exit

Example:

discover first Onkyo/Pioneer receiver and use it

const {OnkyoDiscover} = require('onkyo.js');
OnkyoDiscover.DiscoverFirst()
  .then((onkyo) => {
      return onkyo.powerOn();
  });

use Onkyo by it's address

const {Onkyo} = require('onkyo.js');
const onkyo = Onkyo({address: '192.168.0.100'});
onkyo.powerOn();

API

new OnkyoDiscover({options})

options:

  • logger (optional, e.g wiston instance)
  • broadcastPort (optional)
  • broadcastAddress (optional)

API's

  • discover
  • discoverFirst or OnkyoDiscover.DiscoverFirst() without instance
  • close
  • listen

OnkyoDiscover instance inherits EventEmitter and trigger following events:

  • detected
  • error

new Onkyo({options})

options:

  • logger (optional, e.g wiston instance)
  • name (optional)
  • address / ip
  • port (optional, default 60128)

Onkyo instance inherits EventEmitter and trigger following events:

  • connected When connection is established
  • disconnect When connection is lost
  • error When something wrong happens or received message that library cannot handle

e.g.

const {OnkyoCmds, Onkyo} = require('onkyo.js');
const onkyo = new Onkyo({ip: '196.168.0.10'});

Sending pre-defined commands:

onkyo.sendCommand(<group>, <command>);

Where group is one of string from OnkyoCmds.getGroups() and command is one of string from OnkyoCmds.getGroupCommands(group) .

Sending raw command:

onkyo.sendRawCommand(<data>)

Basic API:

// power
<Promise> onkyo.isOn(<zone>)              // resolves true if powers on
<Promise> onkyo.isOff(<zone>)             // resolves true if powers off
<Promise> onkyo.pwrToggle(<zone>)         // toggle power, resolves when ready
<Promise> onkyo.pwrOn(<zone>)             // power on, resolves when ready
<Promise> onkyo.pwrOff(<zone>)            // power off, resolves when ready

// volume
<Promise> onkyo.volUp(<zone>)             // volume +1, resolves when ready
<Promise> onkyo.volDown(<zone>)           // volume -1, resolves when ready
<Promise> onkyo.setVolume(<volume>, <zone>) // volume between 0-100, resolves when ready
<Promise> onkyo.getVolume(<zone>)         // resolves current volume

// mute
<Promise> onkyo.mute(<zone>)              // mute, resolves when ready
<Promise> onkyo.unMute(<zone>)            // unmute, resolves when ready
<Promise> onkyo.getMute(<zone>)           // resolves true if mute is on

// source/input
<Promise> onkyo.getSource(<zone>)         // resolves current source/input
<Promise> onkyo.setSource(<source>, <zone>) // source selection, resolves when ready

// sound mode
<Promise> onkyo.getSoundMode(<zone>)         // resolves current sound mode
<Promise> onkyo.setSoundMode(<mode>, <zone>) // sound mode selection, resolves when ready

// remote control keys
<Promise> onkyo.sendRemoteKey(<key>)  // possible values: MENU, UP, DOWN, LEFT, RIGHT, ENTER, EXIT, VIDEO, AUDIO, HOME 

* <zone> is optional and by default control main zone, for other zones add "zone2"or "zone3".

Onkyo instance generates public API's based on onkyo.commands.js -file and contains following Promise API's:

powerOn()
powerOff()
powerStatus()
audioMute()
audioUnMute()
audioVolumeUp()
audioVolumeDown()
audioVolumeUp1()
audioVolumeDown1()
audioStatusVol()
audioStatusMute()
cinemaFilterOff()
cinemaFilterOn()
cinemaFilterUp()
dimmerBright()
dimmerDim()
dimmerDark()
dimmerShutOff()
dimmerBrightLedOff()
sourceSelectVideo1()
sourceSelectVideo2()
sourceSelectCblSat()
sourceSelectGame()
sourceSelectAux()
sourceSelectVideo5()
sourceSelectPc()
sourceSelectVideo6()
sourceSelectVideo7()
sourceSelectBdDvd()
sourceSelectStream()
sourceSelectTape1()
sourceSelectTape2()
sourceSelectPhono()
sourceSelectCd()
sourceSelectFm()
sourceSelectAm()
sourceSelectTuner()
sourceSelectMusicserver()
sourceSelectInternetradio()
sourceSelectUsb()
sourceSelectUsbRear()
sourceSelectUsbC()
sourceSelectAirplay()
sourceSelectBt()
sourceSelectMultich()
sourceSelectXm()
sourceSelectSirius()
sourceSelectNet()
sourceSelectSelectorPositionWrapAroundUp()
sourceSelectSelectorPositionWrapAroundDown()
sourceSelectStatus()
soundModeStereo()
soundModeDirect()
soundModeSurround()
soundModeFilm()
soundModeThx()
soundModeAction()
soundModeMusical()
soundModeMonoMovie()
soundModeOrchestra()
soundModeUnplugged()
soundModeStudioMix()
soundModeTvLogic()
soundModeAllChStereo()
soundModeTheaterDimensional()
soundModeEnhanced7Enhance()
soundModeMono()
soundModePureAudio()
soundModeMultiplex()
soundModeFullMono()
soundModeDolbyVirtual()
soundMode51ChSurround()
soundModeStraightDecode1()
soundModeDolbyExDtsEs()
soundModeDolbyEx2()
soundModeThxCinema()
soundModeThxSurroundEx()
soundModeU2S2CinemaCinema2()
soundModeMusicMode()
soundModeGamesMode()
soundModePliiPliIxMovie()
soundModePliiPliIxMusic()
soundModeNeo6Cinema()
soundModeNeo6Music()
soundModePliiPliIxThxCinema()
soundModeNeo6ThxCinema()
soundModePliiPliIxGame()
soundModeNeuralSurr3()
soundModeNeuralThx()
soundModePliiThxGames()
soundModeNeo6ThxGames()
soundModeListeningModeWrapAroundUp()
soundModeListeningModeWrapAroundDown()
soundModeStatus()
speakerAbControlSpeakerAOff()
speakerAbControlSpeakerAOn()
speakerAbControlSpeakerBOff()
speakerAbControlSpeakerBOn()
speakerAbControlStatusA()
speakerAbControlStatusB()
zone2PowerOn()
zone2PowerStandby()
zone2PowerStatus()
zone2AudioMute()
zone2AudioUnmute()
zone2AudioMuteQstn()
zone2AudioVolUp()
zone2AudioVolDown()
zone2AudioVolUp1()
zone2AudioVolDown1()
zone2AudioVolQstn()
zone2AudioStatusVol()
zone2AudioStatusMute()
zone2SourceSelectCblSat()
zone2SourceSelectGame()
zone2SourceSelectAux()
zone2SourceSelectBdDvd()
zone2SourceSelectStrmBox()
zone2SourceSelectTv()
zone2SourceSelectPhono()
zone2SourceSelectCd()
zone2SourceSelectFm()
zone2SourceSelectAm()
zone2SourceSelectTuner()
zone2SourceSelectUsbFront()
zone2SourceSelectNet()
zone2SourceSelectUsbRear()
zone2SourceSelectBt()
zone2SourceSelectHdmi5()
zone2SourceSelectQstn()
zone2SourceSelectUp()
zone2SourceSelectDown()
zone2SourceSelectStatus()
zone2NetPlay()
zone2NetStop()
zone2NetPause()
zone2NetPlayPause()
zone2NetTrackUp()
zone2NetTrackDown()
zone2NetChannelUp()
zone2NetChannelDown()
zone2NetFf()
zone2NetRew()
zone2NetRepeat()
zone2NetRandom()
zone2NetRepeatShuffle()
zone2NetDisplay()
zone2NetMemory()
zone2NetRight()
zone2NetLeft()
zone2NetUp()
zone2NetDown()
zone2NetSelect()
zone2NetReturn()
zone3PowerOn()
zone3PowerStandby()
zone3PowerStatus()
zone3AudioMute()
zone3AudioUnmute()
zone3AudioMuteQstn()
zone3AudioVolUp()
zone3AudioVolDown()
zone3AudioVolUp1()
zone3AudioVolDown1()
zone3AudioVolQstn()
zone3AudioStatusVol()
zone3AudioStatusMute()
zone3SourceSelectCblSat()
zone3SourceSelectGame()
zone3SourceSelectAux()
zone3SourceSelectBdDvd()
zone3SourceSelectStrmBox()
zone3SourceSelectTv()
zone3SourceSelectPhono()
zone3SourceSelectCd()
zone3SourceSelectFm()
zone3SourceSelectAm()
zone3SourceSelectTuner()
zone3SourceSelectUsbFront()
zone3SourceSelectNet()
zone3SourceSelectUsbRear()
zone3SourceSelectBt()
zone3SourceSelectHdmi5()
zone3SourceSelectQstn()
zone3SourceSelectUp()
zone3SourceSelectDown()
zone3SourceSelectStatus()
zone3NetPlay()
zone3NetStop()
zone3NetPause()
zone3NetPlayPause()
zone3NetTrackUp()
zone3NetTrackDown()
zone3NetChannelUp()
zone3NetChannelDown()
zone3NetFf()
zone3NetRew()
zone3NetRepeat()
zone3NetRandom()
zone3NetRepeatShuffle()
zone3NetDisplay()
zone3NetMemory()
zone3NetRight()
zone3NetLeft()
zone3NetUp()
zone3NetDown()
zone3NetSelect()
zone3NetReturn()
pwrToggle()
muteToggle()

Note: List is generated using:

(new (require('onkyo.js').Onkyo)({address:'localhost'})).apis.forEach(api => console.log(api.api+'()'))

LICENSE

MIT

onkyo.js's People

Contributors

dependabot[bot] avatar jupe avatar mattvoss avatar nitaybz avatar snyk-bot avatar vonox avatar wweich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

onkyo.js's Issues

isOn and isOff to promises

Description

  • Type: Enhancement
  • Related Issue: #24

Enhancement

Reason to enhance/problem with existing solution

isOn and isOff rely on cached value and gives boolean

Suggested enhancement

Returns Promise and resolved boolean

Pros
result is always up-to-date

Cons
Breaking change

Enhancement: Add isOn() isOff()

Description

  • Type: Enhancement | Question

Enhancement

Suggested enhancement

Enhance power api like yamaha-nodejs

powerStatus return object like { PWR : true }

Implement or modify existing power api like yamaha package return:

onkyo.isOn()
onkyo.isOff()

What do you think about this feature ?

unknow_msgs

Just some unknow_msgs while testing

RX: unknown event: Error: Unknown data: DIM01
RX: unknown event: Error: Unknown data: RAS00
RX: unknown event: Error: Unrecognised key: SLI12

Timeout when using SPEAKER_AB_CONTROL commands?

Question

How would I use these commands? So far everything is working great but the A/B speaker commands do not work. Everything else does work. I'm trying it like this:

onkyo.speakerAbControlStatusA()

or like this

onkyo.sendCommand("SPEAKER_AB_CONTROL", "STATUS_A")

Both attempts get me

Unhandled rejection Error: connect ETIMEDOUT 196.168.1.176:60128 at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16)

I'm using version 0.8.2. If any more information is required I'd be happy to provide it.

onkyo.js available in Node-Red

Description

  • Type: Question

Question

Have you ever tried to embed this frame work into a node-red node? There are several example out there but none of it is really comfortable.

Add optional port configuration

HI there, am utilising this great little project in conjunction with my NEEO remote but ive ran into an issue. I have two devices and it doesn't seem to play nice as there is what seems to be port contention. ive fixed this in my local copy by duplicating the package and making it onkyo1.js and changed the port manually to accomodate but it would be great if this could be done in the connect function as below

`var onkyo515 = require('onkyo.js');
var onkyo515 = onkyo515.init({ip: '192.168.1.124', PORT: 60129 });
onkyo515.Connect();
module.exports.onkyo515ButtonPressed = function onkyo515ButtonPressed(name, deviceid) {

console.log('[CONTROLLER]', name, 'button was pressed!');
console.log (name);`

OnkyoDiscover class is not exposed

After ES6 Pr merged i have started my work ( Module for domotic software )

The discover function is not exposed and the exemple below is not working.

const {OnkyoDiscover} = require('onkyo.js');
OnkyoDiscover.DiscoverFirst()
  .then((onkyo) => {
      return onkyo.powerOn();
  });

Error

TypeError: Cannot read property 'DiscoverFirst' of undefined

Thank you

Add api to set specific volume levels

Description

  • Type: Enhancement

Enhancement

There is no way to set specific volume ( only +1 or -1 )

It could be usefull to set specific value

Thank you

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.