forked from freakent/node-red-contrib-sunevents
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sunevents-node.html
109 lines (100 loc) · 5.15 KB
/
sunevents-node.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!--
Copyright 2013-2015 Freak Enterprises
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<script type="text/x-red" data-template-name="sun events">
<div class="form-row">
<label for="node-config-input-latitude"><i class="fa fa-globe"></i> Latitude</label>
<input type="text" id="node-input-latitude" placeholder="50.5">
</div>
<div class="form-row">
<label for="node-input-longitude"><i class="fa fa-globe"></i> Longitude</label>
<input type="text" id="node-input-longitude" placeholder="-0.1">
</div>
<div class="form-row">
<label>Modes</label>
<input type="checkbox" id="node-input-verbose" placeholder="once" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-verbose" style="width: 70%;">Log event calculations?</label>
</div>
<div class="form-row">
<label> </label>
<input type="checkbox" id="node-input-testmode" placeholder="once" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-testmode" style="width: 70%;">Make hours seem like minutes? (test mode)</label>
</div>
<div class="form-row">
<label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label>
<input type="text" id="node-input-topic" placeholder="Topic">
</div>
<!-- By convention, most nodes have a 'name' property. The following div -->
<!-- provides the necessary field. -->
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<!-- Next, some simple help text is provided for the node. -->
<script type="text/x-red" data-help-name="sun events">
<p>
A node for node-red that generates events based on the position of the Sun at the appropriate time of day.
</p>
<p>
Outputs an object called <b>msg</b> containing the event name in <b>msg.payload</b> and
the event date & time in the <b>msg.datetime</b>. The <b>msg.topic</b> can be set in the node's configuration
or it will default to the node name or "sun events".
</p>
<p>
Calculations are performed using the excellent SunCalc module (https://github.com/mourner/suncalc)
and the following sun events are output from this node:
</p>
<ul>
<li>sunrise: sunrise (top edge of the sun appears on the horizon)</li>
<li>sunriseEnd: sunrise ends (bottom edge of the sun touches the horizon)</li>
<li>goldenHourEnd: morning golden hour (soft light, best time for photography) ends</li>
<li>solarNoon: solar noon (sun is in the highest position)</li>
<li>goldenHour: evening golden hour starts</li>
<li>sunsetStart: sunset starts (bottom edge of the sun touches the horizon)</li>
<li>sunset: sunset (sun disappears below the horizon, evening civil twilight starts)</li>
<li>dusk: dusk (evening nautical twilight starts)</li>
<li>nauticalDusk: nautical dusk (evening astronomical twilight starts)</li>
<li>night: night starts (dark enough for astronomical observations)</li>
<li>nightEnd: night ends (morning astronomical twilight starts)</li>
<li>nauticalDawn: nautical dawn (morning nautical twilight starts)</li>
<li>dawn: dawn (morning nautical twilight ends, morning civil twilight starts)</li>
<li>nadir: nadir (darkest moment of the night, sun is in the lowest position)</li>
</ul>
</script>
<!-- Finally, the node type is registered along with all of its properties -->
<!-- The example below shows a small subset of the properties that can be set-->
<script type="text/javascript">
RED.nodes.registerType('sun events',{
category: 'input', // the palette category
defaults: { // defines the editable properties of the node
testmode: {value:"N"},
verbose: {value:"N"},
topic: {value:""},
name: {value:""}
},
credentials: {
latitude: {type: "text"}, // {value:"", required: true}, // along with default values.
longitude: {type: "text"} // {value:"", required:true}
},
color:"#FFCC66",
inputs:0, // set the number of inputs - only 0 or 1
outputs:1, // set the number of outputs - 0 to n
icon: "white_golden_sun.png", //"white-globe.png", // set the icon (held in public/icons)
label: function() { // sets the default label contents
return this.name||"sun events";
},
labelStyle: function() { // sets the class to apply to the label
return this.name ? "" : "node_label_italic";
}
});
</script>