mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
make sunrise/sunset second output ONLY trigger on actual transitions and not at startup.
This commit is contained in:
parent
a4c649ade7
commit
d49ec9deab
@ -54,8 +54,8 @@
|
|||||||
<script type="text/x-red" data-help-name="sunrise">
|
<script type="text/x-red" data-help-name="sunrise">
|
||||||
<p>Uses the suncalc module to generate an output at sunrise and sunset based on a specified location.</p>
|
<p>Uses the suncalc module to generate an output at sunrise and sunset based on a specified location.</p>
|
||||||
<p>Several choices of definition of sunrise and sunset are available, see the <i><a href = "https://github.com/mourner/suncalc" target="_new">suncalc</a></i> module for details.</p>
|
<p>Several choices of definition of sunrise and sunset are available, see the <i><a href = "https://github.com/mourner/suncalc" target="_new">suncalc</a></i> module for details.</p>
|
||||||
<p>The first output emits a <b>msg.payload</b> of <i>1</i> or <i>0</i> every minute depending if between selected times or not.
|
<p>The first output emits a <b>msg.payload</b> of <i>1</i> or <i>0</i> every minute depending if in between selected times or not.
|
||||||
The second output emits only on the transition between night to day (<i>1</i>) or day to night (<i>0</i>), and also once at the (re)start of the flow.</p>
|
The second output emits only on the transition between night to day (<i>-> 1</i>) or day to night (<i>-> 0</i>).</p>
|
||||||
<p>Also sets <b>msg.topic</b> to <i>sun</i> and <b>msg.moon</b> to the fraction of the moon between 0 and 1.</p>
|
<p>Also sets <b>msg.topic</b> to <i>sun</i> and <b>msg.moon</b> to the fraction of the moon between 0 and 1.</p>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ function SunNode(n) {
|
|||||||
var moon = parseInt(SunCalc.getMoonFraction(now)*100)/100;
|
var moon = parseInt(SunCalc.getMoonFraction(now)*100)/100;
|
||||||
msg = { payload:0, topic:"sun", moon:moon };
|
msg = { payload:0, topic:"sun", moon:moon };
|
||||||
if ((e1 > 0) & (e2 < 0)) { msg.payload = 1; }
|
if ((e1 > 0) & (e2 < 0)) { msg.payload = 1; }
|
||||||
|
if (oldval == null) { oldval = msg.payload; }
|
||||||
if (msg.payload != oldval) {
|
if (msg.payload != oldval) {
|
||||||
oldval = msg.payload;
|
oldval = msg.payload;
|
||||||
msg2 = msg;
|
msg2 = msg;
|
||||||
|
Loading…
Reference in New Issue
Block a user