Skip to content

Commit

Permalink
Merge pull request #15 from thomaspz/feat/no_msg_on_reset
Browse files Browse the repository at this point in the history
Add Option Message on Reset
  • Loading branch information
ontje authored Mar 27, 2022
2 parents e185fa3 + a408ed0 commit 49721b6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ The node evaluates the following input `msg` types:

## Outputs
The node contains two outputs:
- The **primary output** (upper output) emits an output `msg` at the **countdown start/stop** instant of time. These `msg.payload` contents are configurable
- The **primary output** (upper output) emits an output `msg` at the **countdown start/stop** instant of time. These `msg.payload` contents are configurable. If Option "Send Outputmessage on Reset" ist set, the message is send, when the timer is stopped. Otherwise, the Stop message will only by send, if the timer reaches zero.
- The **secondary output** (lower output) emits the **remaining time every second** during the timer runs. The `msg.payload` holds the remaining counting value


Expand Down
7 changes: 7 additions & 0 deletions countdown.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
<span>Restart countdown if message is received while running</span>&nbsp;
</div>

<div class="form-row">
<label for="node-input-outputOnReset">&nbsp;</label>
<input style="display:inline-block; width:15px; vertical-align:baseline;" type="checkbox" id="node-input-outputOnReset">
<span>Send Outputmessage on Reset</span>&nbsp;
</div>

<div class="form-row">
<label for="node-input-setTimeToNewWhileRunning">&nbsp;</label>
<input style="display:inline-block; width:15px; vertical-align:top;" type="checkbox" id="node-input-setTimeToNewWhileRunning">
Expand Down Expand Up @@ -130,6 +136,7 @@ <h3>Details</h3>
payloadTimerStopType: { value: 'bool' },
timer: { value: 30, validate:RED.validators.number() },
resetWhileRunning: { value: false },
outputOnReset: { value: true },
setTimeToNewWhileRunning: { value: true },
startCountdownOnControlMessage: { value: false }
},
Expand Down
14 changes: 11 additions & 3 deletions countdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = function(RED) {
}
}

function stopTimer() {
function stopTimer(onReset = false) {
node.status({
fill: "red", shape: "dot", text: "Stopped: " + timeout
});
Expand All @@ -67,7 +67,15 @@ module.exports = function(RED) {
if (node.config.payloadTimerStopType == "nul") {
node.send([null, remainingTicksMsg]);
} else {
node.send([msg, remainingTicksMsg]);
if (node.config.outputOnReset) {
node.send([msg, remainingTicksMsg]);
} else {
if (onReset) {
node.send([null, remainingTicksMsg]);
} else {
node.send([msg, remainingTicksMsg]);
}
}
}

endTicker();
Expand Down Expand Up @@ -147,7 +155,7 @@ module.exports = function(RED) {
}

if (msg.payload === false || msg.payload === 0) {
stopTimer();
stopTimer(true);
} else {
if (ticker) {
if (node.config.resetWhileRunning) {
Expand Down
Binary file modified images/node-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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-countdown",
"version": "1.3.1",
"version": "1.3.2",
"description": "A countdown that supports dynamic setting of (future) run time",
"main": "countdown.js",
"scripts": {},
Expand Down

0 comments on commit 49721b6

Please sign in to comment.