correct output for timeswitch

(simple typo)
Also tidied up info etc…
push to close #176
This commit is contained in:
Dave Conway-Jones
2016-02-15 11:12:29 +00:00
parent 952a794db5
commit b33571b240
8 changed files with 50 additions and 47 deletions

View File

@@ -54,9 +54,9 @@
<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 in between selected times or not.
<p>The first output emits a <code>msg.payload</code> 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>
<p>Also sets <code>msg.topic</code> to <i>sun</i> and <code>msg.moon</code> to the fraction of the moon between 0 and 1.</p>
</script>
<script type="text/javascript">

View File

@@ -36,15 +36,15 @@ module.exports = function(RED) {
var endMillis = Date.UTC(times[node.end].getUTCFullYear(),times[node.end].getUTCMonth(),times[node.end].getUTCDate(),times[node.end].getUTCHours(),times[node.end].getUTCMinutes());
var e1 = nowMillis - startMillis;
var e2 = nowMillis - endMillis;
var moon = parseInt(SunCalc.getMoonIllumination(now).fraction*100+0.5)/100;
var msg = { payload:0, topic:"sun", moon:moon };
var moon = parseInt(SunCalc.getMoonIllumination(now).fraction * 100 + 0.5) / 100;
var msg = {payload:0, topic:"sun", moon:moon};
if ((e1 > 0) & (e2 < 0)) { msg.payload = 1; }
if (oldval == null) { oldval = msg.payload; }
if (msg.payload == 1) { node.status({fill:"yellow",shape:"dot",text:"day"}); }
else { node.status({fill:"blue",shape:"dot",text:"night"}); }
if (msg.payload != oldval) {
oldval = msg.payload;
node.send( [msg,msg] );
node.send([msg,msg]);
}
else { node.send(msg); }
}, 60000);
@@ -54,4 +54,4 @@ module.exports = function(RED) {
});
}
RED.nodes.registerType("sunrise",SunNode);
}
};

View File

@@ -16,10 +16,13 @@ Usage
Uses the suncalc npm to generate an output at sunrise and sunset based on a specified location.
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.
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.
The node provide two outputs. The first output emits a <b>msg.payload</b> of <i>1</i> or <i>0</i> every minute depending if day-time (1) or night-time (0).
The node provide two outputs. The first output emits a `msg.payload` of <i>1</i> or <i>0</i> every minute
depending if day-time (1) or night-time (0).
The second output emits only on the transition between night to day (<i>-> 1</i>) or day to night (<i>-> 0</i>).
It also sets the <b>msg.topic</b> to <i>sun</i> and <b>msg.moon</b> to the fraction of the moon currently visible (a value between 0 for no moon and 1 for full moon).</p>
It also sets the `msg.topic` to <i>sun</i> and `msg.moon` to the fraction of the moon currently visible
(a value between 0 for no moon and 1 for full moon).</p>

View File

@@ -1,6 +1,6 @@
{
"name" : "node-red-node-suncalc",
"version" : "0.0.6",
"version" : "0.0.7",
"description" : "A Node-RED node to provide a signal at sunrise and sunset",
"dependencies" : {
"suncalc" : "1.6.*"