Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kodi.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
kodicommand: {value: ""}
},
inputs: 1,
outputs: 0,
outputs: 1,
align: 'right',
icon: "bridge-dash.png",
label: function () {
Expand Down
18 changes: 12 additions & 6 deletions kodi.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,18 @@ module.exports = function (RED) {
}
}

node.send(payload, function (err) {
node.sendToKodi(payload, function (err, data) {
if (err) {
node.error('send error: ' + err);
}
if (typeof(msg.cb) === 'function')
msg.cb(err);
if(!err){
node.send({
topic: 'kodi',
payload: data
});
}
});

});
Expand Down Expand Up @@ -165,18 +171,18 @@ module.exports = function (RED) {
fsm.on('reconnect', nodeStatusReconnect);
});

this.send = function (data, callback) {
this.sendToKodi = function (data, callback) {
DEBUG && RED.comms.publish("debug", {name: node.name, msg: 'send data[' + JSON.stringify(data) + ']'});
//node.log('send data[' + data + ']');
//node.log('sendToKodi data[' + data + ']');
// init a new one-off connection from the effectively singleton KodiController
// there seems to be no way to reuse the outgoing conn in adreek/node-kodijs
controllerNode.initializeKodiConnection(function (fsm) {
try {
DEBUG && RED.comms.publish("debug", {name: node.name, msg: "send: " + JSON.stringify(data)});
data.cmd = data.cmd || data.method;
data.args = data.args || data.params;
fsm.connection.run(data.cmd, data.args).then(function () {
callback && callback();
fsm.connection.run(data.cmd, data.args).then(function (data) {
callback && callback(null, data);
}, function (err) {
callback && callback(err);
});
Expand Down Expand Up @@ -268,4 +274,4 @@ module.exports = function (RED) {
}

RED.nodes.registerType("kodi-in", KodiIn);
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-kodi",
"version": "0.2.8",
"version": "0.3.0",
"description": "Node-RED nodes for communicating with a Kodi (former XBMC).",
"repository": {
"type": "git",
Expand Down