Skip to content

Commit

Permalink
Add Input option: Process and output on state change (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
datech committed Oct 21, 2019
1 parent 3fe1dfe commit 011cf7c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<option value="0">No</option>
<option value="1">Process</option>
<option value="2">Process and output</option>
<option value="3">Process and output on state change</option>
</select>
</div>
<div class="form-tips">
Expand All @@ -52,7 +53,7 @@
<p>Amazon Echo Hub</p>

<h3>Inputs</h3>
Enable input to allow input payload signals
Enable input processing to allow input payload signals
<dl class="message-properties">
<dt>payload
<span class="property-type">string | buffer</span>
Expand Down
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ module.exports = function(RED) {

var deviceAttributes = setDeviceAttributes(msg.payload.deviceid, msg.payload, meta, hubNode.context());

// Output only if 'Process and output' option is selected and state is changed
if (config.processinput == 2 && Object.keys(deviceAttributes.meta.changes).length > 0) {
// Output if
// 'Process and output' OR
// 'Process and output on state change' option is selected
if (config.processinput == 2 || (config.processinput == 3 && Object.keys(deviceAttributes.meta.changes).length > 0)) {
payloadHandler(hubNode, msg.payload.deviceid);
}

Expand Down Expand Up @@ -462,8 +464,6 @@ module.exports = function(RED) {
msg.deviceid = deviceId;
msg.topic = '';

console.log(msg);

hubNode.send(msg);
}

Expand Down

0 comments on commit 011cf7c

Please sign in to comment.