1
0
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:
Dave C-J 2013-10-19 15:37:20 +01:00
parent a4c649ade7
commit d49ec9deab
2 changed files with 3 additions and 2 deletions

View File

@ -54,8 +54,8 @@
<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>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.
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>
<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>).</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>

View File

@ -40,6 +40,7 @@ function SunNode(n) {
var moon = parseInt(SunCalc.getMoonFraction(now)*100)/100;
msg = { payload:0, topic:"sun", moon:moon };
if ((e1 > 0) & (e2 < 0)) { msg.payload = 1; }
if (oldval == null) { oldval = msg.payload; }
if (msg.payload != oldval) {
oldval = msg.payload;
msg2 = msg;