Skip to content

Commit

Permalink
Fix context id
Browse files Browse the repository at this point in the history
  • Loading branch information
ybizeul committed Nov 30, 2020
1 parent 07b7e77 commit 5fb3ddc
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions Sources/node-red-contrib-streamdeck-ws/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ module.exports = function(RED) {
RED.nodes.createNode(this,config);
var node = this;
node.on('input', function(msg) {
fcontext = this.context().flow

contexts = this.context().flow.get("streamdeckContexts")
if (!contexts || !contexts[msg.streamdeckID]) {
this.status({fill:"red",shape:"ring",text:"Context is unknown"});
return
}

// Payload
if (typeof(msg.payload) != "object") {
Expand All @@ -13,17 +18,14 @@ module.exports = function(RED) {
msg.payload.payload={}
}
if (config["streamdeckID"]) {
msg.payload.context = fcontext.streamdeckContexts[config["streamdeckID"]]
}
else {
contexts = this.context().flow.get("streamdeckContexts")
if (!contexts) {
contexts = {}
}
if (!contexts[msg.streamdeckID]) {
this.status({fill:"red",shape:"ring",text:"Context is unknown"});
return
}
msg.payload.context = contexts[config["streamdeckID"]]
}
else {

msg.payload.context = contexts[msg.streamdeckID]
}

Expand Down

0 comments on commit 5fb3ddc

Please sign in to comment.