Comments (5)
Probably same as #7
Did you try catching and handling the errors from the promise?
from yamaha-nodejs.
I don't know how to do this :(.
I find the line with prom.catch method:
Yamaha.prototype.SendXMLToReceiver = function(xml) {
var self = this;
return this.getOrDiscoverIP().then(ip => {
var isPutCommand = xml.indexOf("cmd=\"PUT\"" >= 0);
var delay = isPutCommand ? this.responseDelay * 1000 : 0;
var req = {
method: 'POST',
uri: 'http://' + ip + '/YamahaRemoteControl/ctrl',
body: xml
};
if (this.requestTimeout) req.timeout = this.requestTimeout;
var prom = request.postAsync(req).delay(delay).then(response => response.body)
if (self.catchRequestErrors === true) prom.catch(console.log.bind(console));
return prom
})
};
prom.catch method is fired on timeout error, but i don't know to do in callback , to stop exit app.listen.
It's not the same as #7. I receive ETIMEOUT error from nodejs server.
from yamaha-nodejs.
I meant same as in #7 as the errors are not handled by the user.
The lib returns bluebird promises: http://bluebirdjs.com/docs/api-reference.html
Catch all errors:
yamaha.setMainInputTo("HDMI2").then(function() {
return yamaha.getCurrentInput();
}).catch(function(e) {
});
With the catchRequestErrors the lib swallows errors and prints them.
from yamaha-nodejs.
I did now like this:
var yamahaApi = require("yamaha.api")
var yamahaCtrl = new yamahaApi("192.168.1.2");
and the call
yamaha.getBasicInfo(zone).then(function (info) {
res.send(info);
}).catch(function (error) {
res.send(error);
});
and server still exit with error ETIMEDOUT.
from yamaha-nodejs.
I think I solved. with the solution above.
I added a lot of commands on yamaha.simple.commands.api.js.:
Yamaha.prototype.getRepeatInfo = function (input) {
var command = '<YAMAHA_AV cmd="GET"><' + input + '><Play_Control><Play_Mode>GetParam</Play_Mode></Play_Control></' + input + '></YAMAHA_AV>';
return this.SendXMLToReceiver(command).then(xml2js.parseStringAsync);
};
Yamaha.prototype.repeatOff = function (input) {
var command = '<YAMAHA_AV cmd="PUT"><' + input + '><Play_Control><Play_Mode>Off</Play_Mode></Play_Control></' + input + '></YAMAHA_AV>';
return this.SendXMLToReceiver(command);
};
Yamaha.prototype.repeatAll = function (input) {
var command = '<YAMAHA_AV cmd="PUT"><' + input + '><Play_Control><Play_Mode>All</Play_Mode></Play_Control></' + input + '></YAMAHA_AV>';
return this.SendXMLToReceiver(command);
};
Yamaha.prototype.repeatOne = function (input) {
var command = '<YAMAHA_AV cmd="PUT"><' + input + '><Play_Control><Play_Mode>One</Play_Mode></Play_Control></' + input + '></YAMAHA_AV>';
return this.SendXMLToReceiver(command);
};
Yamaha.prototype.getShuffleInfo= function (input) {
var command = '<YAMAHA_AV cmd="GET"><' + input + '><Play_Control><Play_Mode>GetParam</Play_Mode></Play_Control></' + input + '></YAMAHA_AV>';
return this.SendXMLToReceiver(command).then(xml2js.parseStringAsync);
};
Yamaha.prototype.shuffleOn = function (input) {
var command = '<YAMAHA_AV cmd="PUT"><' + input + '><Play_Control><Play_Mode>On</Play_Mode></Play_Control></' + input + '></YAMAHA_AV>';
return this.SendXMLToReceiver(command);
};
Yamaha.prototype.shuffleOff = function (input) {
var command = '<YAMAHA_AV cmd="PUT"><' + input + '><Play_Control><Play_Mode>Off</Play_Mode></Play_Control></' + input + '></YAMAHA_AV>';
return this.SendXMLToReceiver(command);
};
Yamaha.prototype.menuCursorMove = function (listname, move) {
if (["Return", "Up", "Down"].indexOf(move) === -1) throw "Cursor move can be only Retur, Up or Down";
var command = '<YAMAHA_AV cmd="PUT"><' + listname + '><List_Control>' + move + '</List_Control></' + listname + '></YAMAHA_AV>';
return this.SendXMLToReceiver(command);
};
Yamaha.prototype.menuPageMove = function (listname, move) {
if (["Up", "Down"].indexOf(move) === -1) throw "Cursor move can be only Retur, Up or Down";
var command = '<YAMAHA_AV cmd="PUT"><' + listname + '><List_Control>' + move + '</List_Control></' + listname + '></YAMAHA_AV>';
return this.SendXMLToReceiver(command);
};
Yamaha.prototype.getSERVERList = function () {
return this.getList("SERVER");
};
from yamaha-nodejs.
Related Issues (16)
- Integration with homebridge HOT 2
- Can't import the module HOT 2
- How to figure out the RC-Codes? HOT 7
- Offical API found HOT 3
- Issue with OpenSSL between yams and alexandra install HOT 2
- Zone B Control HOT 1
- delay is inserted regardless of PUT or GET HOT 2
- Extracting the ID or ULR of an Album_Art HOT 5
- Scene Feature suggestion. HOT 4
- NPM version doesn't match GitHub HOT 4
- Tailor to multiple zones HOT 7
- Can we make PRs that use http requests? HOT 2
- What does that mean? HOT 2
- Error: socket hang up HOT 1
- Yamaha AVR Discovery HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yamaha-nodejs.