123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281 |
- <script type="text/javascript">
- ;(function () {
- const calcDuration = (eventType) => {
- // eventType can be 'sunset', 'dusk' etc.
- let hours = Number($(`#node-input-${eventType}OffsetHours`).val())
- let minutes = Number($(`#node-input-${eventType}OffsetMinutes`).val())
- return hours * 3600 + minutes * 60
- }
-
- const eventTypes = [
- 'sunrise',
- 'sunriseEnd',
- 'goldenHourEnd',
- 'solarNoon',
- 'goldenHour',
- 'sunsetStart',
- 'sunset',
- 'dusk',
- 'nauticalDusk',
- 'night',
- 'nadir',
- 'nightEnd',
- 'nauticalDawn',
- 'dawn',
- ]
-
- let defaults = {
- name: { value: '' },
- lat: { value: '', required: true, validate: RED.validators.number() },
- lon: { value: '', required: true, validate: RED.validators.number() },
- replay: { value: false },
- ejectScheduleOnUpdate: { value: false },
- }
-
- eventTypes.forEach((eventType) => {
- defaults[`${eventType}Payload`] = {
- value: '',
- validate: RED.validators.typedInput('payloadType'),
- }
- defaults[`${eventType}PayloadType`] = { value: 'string' }
- defaults[`${eventType}Topic`] = { value: '', required: false }
- defaults[`${eventType}OffsetType`] = { value: 1, required: true }
- defaults[`${eventType}OffsetHours`] = { value: 0, required: true }
- defaults[`${eventType}OffsetMinutes`] = { value: 0, required: true }
- defaults[`${eventType}Offset`] = { value: 0 }
- })
-
- RED.nodes.registerType('suncron', {
- category: 'smart home',
- color: '#FFCC66',
- defaults: defaults,
- inputs: 1,
- outputs: 1,
- icon: 'font-awesome/fa-sun-o',
- label: function () {
- return this.name || 'suncron'
- },
- oneditprepare: function () {
- $('#geolocate').click(() => {
- if ('geolocation' in navigator) {
- $('#node-input-lat').val('???')
- $('#node-input-lon').val('???')
- $('#geolocate > i').removeClass('fa-location-arrow')
- $('#geolocate > i').addClass('fa-hourglass')
- navigator.geolocation.getCurrentPosition((position) => {
- $('#node-input-lat').val(position.coords.latitude)
- $('#node-input-lon').val(position.coords.longitude)
- $('#geolocate > i').removeClass('fa-hourglass')
- $('#geolocate > i').addClass('fa-location-arrow')
- })
- } else {
- alert('Sorry, your browser does not support geolocation')
- }
- })
-
- eventTypes.forEach((eventType) => {
- const payloadName = `${eventType}Payload`
- const payloadType = `${eventType}PayloadType`
-
- if (this[payloadType] == null) {
- if (this[payloadType] == '') {
- this[payloadType] = 'date'
- } else {
- this[payloadType] = 'str'
- }
- } else if (
- this[payloadType] === 'string' ||
- this[payloadType] === 'none'
- ) {
- this[payloadType] = 'str'
- }
- $(`#node-input-${payloadType}`).val(this[payloadType])
- $(`#node-input-${payloadName}`).typedInput({
- default: 'str',
- typeField: $(`#node-input-${payloadType}`),
- types: ['str', 'num', 'bool', 'json'],
- })
- $(`#node-input-${payloadName}`).typedInput('type', this[payloadType])
- })
- },
- oneditsave: function () {
- eventTypes.forEach((eventType) => {
- $(`#node-input-${eventType}Offset`).val(calcDuration(eventType))
- })
- },
- })
- })()
- </script>
- <style>
- .form-row label {
- width: 130px !important;
- }
- </style>
-
- <script type="text/x-red" data-template-name="suncron">
- <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>
-
- <div class="form-row">
- <label for="node-input-lat"><i class="fa fa-globe"></i> Location</label>
- lat: <input type="text" id="node-input-lat" placeholder="latitude" style="width:100px">
- lon: <input type="text" id="node-input-lon" placeholder="longitude" style="width:100px">
- <button id="geolocate"><i class="fa fa-location-arrow"></i></button>
- </div>
-
- <div class="form-row">
- <label for="node-input-replay"><i class="fa fa-rocket"></i> Startup</label>
- <input type="checkbox" id="node-input-replay" style="width:30px; margin:0px"> Emit preceding event on startup
- </div>
-
- <div class="form-row">
- <label for="node-input-ejectScheduleOnUpdate"><i class="fa fa-repeat"></i> Schedule</label>
- <input type="checkbox" id="node-input-ejectScheduleOnUpdate" style="width:30px; margin:0px"> Emit schedule when updated <i class="fa fa-info-circle" title="When enabled, this will emit a message with the topic "suncron:schedule" and the schedule object as payload"></i>
- </div>
-
- <hr />
-
- <!-- sunrise -->
- <div class="form-row">
- <label for="node-input-sunrise"><i class="fa fa-clock-o"></i> Sunrise</label>
- <span>Top edge of the sun appears over the horizon</span>
- </div>
-
- <div class="form-row">
- <label for="node-input-sunrisePayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload">Payload</span></label>
- <input type="text" id="node-input-sunrisePayload" style="width:70%">
- <input type="hidden" id="node-input-sunrisePayloadType">
- </div>
-
- <div class="form-row">
- <label for="node-input-sunriseTopic"><i class="fa fa-tasks"></i> <span>Topic</span></label>
- <input type="text" id="node-input-sunriseTopic">
- </div>
-
- <div class="form-row">
- <label for="node-input-sunriseOffsetType"><i class="fa fa-sliders"></i> <span>Offset</span></label>
- <select style="width:50px; margin-left:0px;" id="node-input-sunriseOffsetType">
- <option value="1">+</option>
- <option value="-1">-</option>
- </select>
- <select style="width:50px; margin-left:0px;" id="node-input-sunriseOffsetHours">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="11">11</option>
- <option value="12">12</option>
- <option value="13">13</option>
- <option value="14">14</option>
- <option value="15">15</option>
- <option value="16">16</option>
- <option value="17">17</option>
- <option value="18">18</option>
- <option value="19">19</option>
- <option value="20">20</option>
- <option value="21">21</option>
- <option value="22">22</option>
- <option value="23">23</option>
- </select> hours
- <select style="width:50px; margin-left:0px;" id="node-input-sunriseOffsetMinutes">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="15">15</option>
- <option value="20">20</option>
- <option value="25">25</option>
- <option value="30">30</option>
- <option value="35">35</option>
- <option value="40">40</option>
- <option value="45">45</option>
- <option value="50">50</option>
- <option value="55">55</option>
- </select> minutes
- <input type="hidden" id="node-input-sunriseOffset">
- </div>
-
- <hr />
-
- <!-- sunriseEnd -->
- <div class="form-row">
- <label for="node-input-sunriseEnd"><i class="fa fa-clock-o"></i> Sunrise End</label>
- <span>Bottom edge of the sun touches the horizon</span>
- </div>
-
- <div class="form-row">
- <label for="node-input-sunriseEndPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload">Payload</span></label>
- <input type="text" id="node-input-sunriseEndPayload" style="width:70%">
- <input type="hidden" id="node-input-sunriseEndPayloadType">
- </div>
-
- <div class="form-row">
- <label for="node-input-sunriseEndTopic"><i class="fa fa-tasks"></i> <span>Topic</span></label>
- <input type="text" id="node-input-sunriseEndTopic">
- </div>
-
- <div class="form-row">
- <label for="node-input-sunriseEndOffsetType"><i class="fa fa-sliders"></i> <span>Offset</span></label>
- <select style="width:50px; margin-left:0px;" id="node-input-sunriseEndOffsetType">
- <option value="1">+</option>
- <option value="-1">-</option>
- </select>
- <select style="width:50px; margin-left:0px;" id="node-input-sunriseEndOffsetHours">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="11">11</option>
- <option value="12">12</option>
- <option value="13">13</option>
- <option value="14">14</option>
- <option value="15">15</option>
- <option value="16">16</option>
- <option value="17">17</option>
- <option value="18">18</option>
- <option value="19">19</option>
- <option value="20">20</option>
- <option value="21">21</option>
- <option value="22">22</option>
- <option value="23">23</option>
- </select> hours
- <select style="width:50px; margin-left:0px;" id="node-input-sunriseEndOffsetMinutes">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="15">15</option>
- <option value="20">20</option>
- <option value="25">25</option>
- <option value="30">30</option>
- <option value="35">35</option>
- <option value="40">40</option>
- <option value="45">45</option>
- <option value="50">50</option>
- <option value="55">55</option>
- </select> minutes
- <input type="hidden" id="node-input-sunriseEndOffset">
- </div>
-
- <hr />
-
- <!-- goldenHourEnd -->
- <div class="form-row">
- <label for="node-input-goldenHourEnd"><i class="fa fa-clock-o"></i> Golden Hour End</label>
- <span>Morning golden hour (soft light, best time for photography) ends</span>
- </div>
-
- <div class="form-row">
- <label for="node-input-goldenHourEndPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload">Payload</span></label>
- <input type="text" id="node-input-goldenHourEndPayload" style="width:70%">
- <input type="hidden" id="node-input-goldenHourEndPayloadType">
- </div>
-
- <div class="form-row">
- <label for="node-input-goldenHourEndTopic"><i class="fa fa-tasks"></i> <span>Topic</span></label>
- <input type="text" id="node-input-goldenHourEndTopic">
- </div>
-
- <div class="form-row">
- <label for="node-input-goldenHourEndOffsetType"><i class="fa fa-sliders"></i> <span>Offset</span></label>
- <select style="width:50px; margin-left:0px;" id="node-input-goldenHourEndOffsetType">
- <option value="1">+</option>
- <option value="-1">-</option>
- </select>
- <select style="width:50px; margin-left:0px;" id="node-input-goldenHourEndOffsetHours">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="11">11</option>
- <option value="12">12</option>
- <option value="13">13</option>
- <option value="14">14</option>
- <option value="15">15</option>
- <option value="16">16</option>
- <option value="17">17</option>
- <option value="18">18</option>
- <option value="19">19</option>
- <option value="20">20</option>
- <option value="21">21</option>
- <option value="22">22</option>
- <option value="23">23</option>
- </select> hours
- <select style="width:50px; margin-left:0px;" id="node-input-goldenHourEndOffsetMinutes">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="15">15</option>
- <option value="20">20</option>
- <option value="25">25</option>
- <option value="30">30</option>
- <option value="35">35</option>
- <option value="40">40</option>
- <option value="45">45</option>
- <option value="50">50</option>
- <option value="55">55</option>
- </select> minutes
- <input type="hidden" id="node-input-goldenHourEndOffset">
- </div>
-
- <hr />
-
- <!-- solarNoon -->
- <div class="form-row">
- <label for="node-input-solarNoon"><i class="fa fa-clock-o"></i> Solar Noon</label>
- <span>Sun is in the highest position</span>
- </div>
-
- <div class="form-row">
- <label for="node-input-solarNoonPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload">Payload</span></label>
- <input type="text" id="node-input-solarNoonPayload" style="width:70%">
- <input type="hidden" id="node-input-solarNoonPayloadType">
- </div>
-
- <div class="form-row">
- <label for="node-input-solarNoonTopic"><i class="fa fa-tasks"></i> <span>Topic</span></label>
- <input type="text" id="node-input-solarNoonTopic">
- </div>
-
- <div class="form-row">
- <label for="node-input-solarNoonOffsetType"><i class="fa fa-sliders"></i> <span>Offset</span></label>
- <select style="width:50px; margin-left:0px;" id="node-input-solarNoonOffsetType">
- <option value="1">+</option>
- <option value="-1">-</option>
- </select>
- <select style="width:50px; margin-left:0px;" id="node-input-solarNoonOffsetHours">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="11">11</option>
- <option value="12">12</option>
- <option value="13">13</option>
- <option value="14">14</option>
- <option value="15">15</option>
- <option value="16">16</option>
- <option value="17">17</option>
- <option value="18">18</option>
- <option value="19">19</option>
- <option value="20">20</option>
- <option value="21">21</option>
- <option value="22">22</option>
- <option value="23">23</option>
- </select> hours
- <select style="width:50px; margin-left:0px;" id="node-input-solarNoonOffsetMinutes">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="15">15</option>
- <option value="20">20</option>
- <option value="25">25</option>
- <option value="30">30</option>
- <option value="35">35</option>
- <option value="40">40</option>
- <option value="45">45</option>
- <option value="50">50</option>
- <option value="55">55</option>
- </select> minutes
- <input type="hidden" id="node-input-solarNoonOffset">
- </div>
-
- <hr />
-
- <!-- goldenHour -->
- <div class="form-row">
- <label for="node-input-goldenHour"><i class="fa fa-clock-o"></i> Golden Hour</label>
- <span>Evening golden hour starts</span>
- </div>
-
- <div class="form-row">
- <label for="node-input-goldenHourPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload">Payload</span></label>
- <input type="text" id="node-input-goldenHourPayload" style="width:70%">
- <input type="hidden" id="node-input-goldenHourPayloadType">
- </div>
-
- <div class="form-row">
- <label for="node-input-goldenHourTopic"><i class="fa fa-tasks"></i> <span>Topic</span></label>
- <input type="text" id="node-input-goldenHourTopic">
- </div>
-
- <div class="form-row">
- <label for="node-input-goldenHourOffsetType"><i class="fa fa-sliders"></i> <span>Offset</span></label>
- <select style="width:50px; margin-left:0px;" id="node-input-goldenHourOffsetType">
- <option value="1">+</option>
- <option value="-1">-</option>
- </select>
- <select style="width:50px; margin-left:0px;" id="node-input-goldenHourOffsetHours">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="11">11</option>
- <option value="12">12</option>
- <option value="13">13</option>
- <option value="14">14</option>
- <option value="15">15</option>
- <option value="16">16</option>
- <option value="17">17</option>
- <option value="18">18</option>
- <option value="19">19</option>
- <option value="20">20</option>
- <option value="21">21</option>
- <option value="22">22</option>
- <option value="23">23</option>
- </select> hours
- <select style="width:50px; margin-left:0px;" id="node-input-goldenHourOffsetMinutes">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="15">15</option>
- <option value="20">20</option>
- <option value="25">25</option>
- <option value="30">30</option>
- <option value="35">35</option>
- <option value="40">40</option>
- <option value="45">45</option>
- <option value="50">50</option>
- <option value="55">55</option>
- </select> minutes
- <input type="hidden" id="node-input-goldenHourOffset">
- </div>
-
- <hr />
-
- <!-- sunsetStart -->
- <div class="form-row">
- <label for="node-input-sunsetStart"><i class="fa fa-clock-o"></i> Sunset Start</label>
- <span>Bottom edge of the sun touches the horizon</span>
- </div>
-
- <div class="form-row">
- <label for="node-input-sunsetStartPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload">Payload</span></label>
- <input type="text" id="node-input-sunsetStartPayload" style="width:70%">
- <input type="hidden" id="node-input-sunsetStartPayloadType">
- </div>
-
- <div class="form-row">
- <label for="node-input-sunsetStartTopic"><i class="fa fa-tasks"></i> <span>Topic</span></label>
- <input type="text" id="node-input-sunsetStartTopic">
- </div>
-
- <div class="form-row">
- <label for="node-input-sunsetStartOffsetType"><i class="fa fa-sliders"></i> <span>Offset</span></label>
- <select style="width:50px; margin-left:0px;" id="node-input-sunsetStartOffsetType">
- <option value="1">+</option>
- <option value="-1">-</option>
- </select>
- <select style="width:50px; margin-left:0px;" id="node-input-sunsetStartOffsetHours">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="11">11</option>
- <option value="12">12</option>
- <option value="13">13</option>
- <option value="14">14</option>
- <option value="15">15</option>
- <option value="16">16</option>
- <option value="17">17</option>
- <option value="18">18</option>
- <option value="19">19</option>
- <option value="20">20</option>
- <option value="21">21</option>
- <option value="22">22</option>
- <option value="23">23</option>
- </select> hours
- <select style="width:50px; margin-left:0px;" id="node-input-sunsetStartOffsetMinutes">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="15">15</option>
- <option value="20">20</option>
- <option value="25">25</option>
- <option value="30">30</option>
- <option value="35">35</option>
- <option value="40">40</option>
- <option value="45">45</option>
- <option value="50">50</option>
- <option value="55">55</option>
- </select> minutes
- <input type="hidden" id="node-input-sunsetStartOffset">
- </div>
-
- <hr />
-
- <!-- sunset -->
- <div class="form-row">
- <label for="node-input-sunset"><i class="fa fa-clock-o"></i> Sunset</label>
- <span>Sun disappears below the horizon, evening civil twilight starts</span>
- </div>
-
- <div class="form-row">
- <label for="node-input-sunsetPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload">Payload</span></label>
- <input type="text" id="node-input-sunsetPayload" style="width:70%">
- <input type="hidden" id="node-input-sunsetPayloadType">
- </div>
-
- <div class="form-row">
- <label for="node-input-sunsetTopic"><i class="fa fa-tasks"></i> <span>Topic</span></label>
- <input type="text" id="node-input-sunsetTopic">
- </div>
-
- <div class="form-row">
- <label for="node-input-sunsetOffsetType"><i class="fa fa-sliders"></i> <span>Offset</span></label>
- <select style="width:50px; margin-left:0px;" id="node-input-sunsetOffsetType">
- <option value="1">+</option>
- <option value="-1">-</option>
- </select>
- <select style="width:50px; margin-left:0px;" id="node-input-sunsetOffsetHours">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="11">11</option>
- <option value="12">12</option>
- <option value="13">13</option>
- <option value="14">14</option>
- <option value="15">15</option>
- <option value="16">16</option>
- <option value="17">17</option>
- <option value="18">18</option>
- <option value="19">19</option>
- <option value="20">20</option>
- <option value="21">21</option>
- <option value="22">22</option>
- <option value="23">23</option>
- </select> hours
- <select style="width:50px; margin-left:0px;" id="node-input-sunsetOffsetMinutes">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="15">15</option>
- <option value="20">20</option>
- <option value="25">25</option>
- <option value="30">30</option>
- <option value="35">35</option>
- <option value="40">40</option>
- <option value="45">45</option>
- <option value="50">50</option>
- <option value="55">55</option>
- </select> minutes
- <input type="hidden" id="node-input-sunsetOffset">
- </div>
-
- <hr />
-
- <!-- dusk -->
- <div class="form-row">
- <label for="node-input-dusk"><i class="fa fa-clock-o"></i> Dusk</label>
- <span>Evening nautical twilight starts</span>
- </div>
-
- <div class="form-row">
- <label for="node-input-duskPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload">Payload</span></label>
- <input type="text" id="node-input-duskPayload" style="width:70%">
- <input type="hidden" id="node-input-duskPayloadType">
- </div>
-
- <div class="form-row">
- <label for="node-input-duskTopic"><i class="fa fa-tasks"></i> <span>Topic</span></label>
- <input type="text" id="node-input-duskTopic">
- </div>
-
- <div class="form-row">
- <label for="node-input-duskOffsetType"><i class="fa fa-sliders"></i> <span>Offset</span></label>
- <select style="width:50px; margin-left:0px;" id="node-input-duskOffsetType">
- <option value="1">+</option>
- <option value="-1">-</option>
- </select>
- <select style="width:50px; margin-left:0px;" id="node-input-duskOffsetHours">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="11">11</option>
- <option value="12">12</option>
- <option value="13">13</option>
- <option value="14">14</option>
- <option value="15">15</option>
- <option value="16">16</option>
- <option value="17">17</option>
- <option value="18">18</option>
- <option value="19">19</option>
- <option value="20">20</option>
- <option value="21">21</option>
- <option value="22">22</option>
- <option value="23">23</option>
- </select> hours
- <select style="width:50px; margin-left:0px;" id="node-input-duskOffsetMinutes">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="15">15</option>
- <option value="20">20</option>
- <option value="25">25</option>
- <option value="30">30</option>
- <option value="35">35</option>
- <option value="40">40</option>
- <option value="45">45</option>
- <option value="50">50</option>
- <option value="55">55</option>
- </select> minutes
- <input type="hidden" id="node-input-duskOffset">
- </div>
-
- <hr />
-
- <!-- nauticalDusk -->
- <div class="form-row">
- <label for="node-input-nauticalDusk"><i class="fa fa-clock-o"></i> Nautical Dusk</label>
- <span>Evening astronomical twilight starts</span>
- </div>
-
- <div class="form-row">
- <label for="node-input-nauticalDuskPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload">Payload</span></label>
- <input type="text" id="node-input-nauticalDuskPayload" style="width:70%">
- <input type="hidden" id="node-input-nauticalDuskPayloadType">
- </div>
-
- <div class="form-row">
- <label for="node-input-nauticalDuskTopic"><i class="fa fa-tasks"></i> <span>Topic</span></label>
- <input type="text" id="node-input-nauticalDuskTopic">
- </div>
-
- <div class="form-row">
- <label for="node-input-nauticalDuskOffsetType"><i class="fa fa-sliders"></i> <span>Offset</span></label>
- <select style="width:50px; margin-left:0px;" id="node-input-nauticalDuskOffsetType">
- <option value="1">+</option>
- <option value="-1">-</option>
- </select>
- <select style="width:50px; margin-left:0px;" id="node-input-nauticalDuskOffsetHours">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="11">11</option>
- <option value="12">12</option>
- <option value="13">13</option>
- <option value="14">14</option>
- <option value="15">15</option>
- <option value="16">16</option>
- <option value="17">17</option>
- <option value="18">18</option>
- <option value="19">19</option>
- <option value="20">20</option>
- <option value="21">21</option>
- <option value="22">22</option>
- <option value="23">23</option>
- </select> hours
- <select style="width:50px; margin-left:0px;" id="node-input-nauticalDuskOffsetMinutes">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="15">15</option>
- <option value="20">20</option>
- <option value="25">25</option>
- <option value="30">30</option>
- <option value="35">35</option>
- <option value="40">40</option>
- <option value="45">45</option>
- <option value="50">50</option>
- <option value="55">55</option>
- </select> minutes
- <input type="hidden" id="node-input-nauticalDuskOffset">
- </div>
-
- <hr />
-
- <!-- night -->
- <div class="form-row">
- <label for="node-input-night"><i class="fa fa-clock-o"></i> Night</label>
- <span>Dark enough for astronomical observations</span>
- </div>
-
- <div class="form-row">
- <label for="node-input-nightPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload">Payload</span></label>
- <input type="text" id="node-input-nightPayload" style="width:70%">
- <input type="hidden" id="node-input-nightPayloadType">
- </div>
-
- <div class="form-row">
- <label for="node-input-nightTopic"><i class="fa fa-tasks"></i> <span>Topic</span></label>
- <input type="text" id="node-input-nightTopic">
- </div>
-
- <div class="form-row">
- <label for="node-input-nightOffsetType"><i class="fa fa-sliders"></i> <span>Offset</span></label>
- <select style="width:50px; margin-left:0px;" id="node-input-nightOffsetType">
- <option value="1">+</option>
- <option value="-1">-</option>
- </select>
- <select style="width:50px; margin-left:0px;" id="node-input-nightOffsetHours">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="11">11</option>
- <option value="12">12</option>
- <option value="13">13</option>
- <option value="14">14</option>
- <option value="15">15</option>
- <option value="16">16</option>
- <option value="17">17</option>
- <option value="18">18</option>
- <option value="19">19</option>
- <option value="20">20</option>
- <option value="21">21</option>
- <option value="22">22</option>
- <option value="23">23</option>
- </select> hours
- <select style="width:50px; margin-left:0px;" id="node-input-nightOffsetMinutes">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="15">15</option>
- <option value="20">20</option>
- <option value="25">25</option>
- <option value="30">30</option>
- <option value="35">35</option>
- <option value="40">40</option>
- <option value="45">45</option>
- <option value="50">50</option>
- <option value="55">55</option>
- </select> minutes
- <input type="hidden" id="node-input-nightOffset">
- </div>
-
- <hr />
-
- <!-- nadir -->
- <div class="form-row">
- <label for="node-input-nadir"><i class="fa fa-clock-o"></i> Nadir</label>
- <span>Darkest moment of the night, sun is in the lowest position</span>
- </div>
-
- <div class="form-row">
- <label for="node-input-nadirPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload">Payload</span></label>
- <input type="text" id="node-input-nadirPayload" style="width:70%">
- <input type="hidden" id="node-input-nadirPayloadType">
- </div>
-
- <div class="form-row">
- <label for="node-input-nadirTopic"><i class="fa fa-tasks"></i> <span>Topic</span></label>
- <input type="text" id="node-input-nadirTopic">
- </div>
-
- <div class="form-row">
- <label for="node-input-nadirOffsetType"><i class="fa fa-sliders"></i> <span>Offset</span></label>
- <select style="width:50px; margin-left:0px;" id="node-input-nadirOffsetType">
- <option value="1">+</option>
- <option value="-1">-</option>
- </select>
- <select style="width:50px; margin-left:0px;" id="node-input-nadirOffsetHours">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="11">11</option>
- <option value="12">12</option>
- <option value="13">13</option>
- <option value="14">14</option>
- <option value="15">15</option>
- <option value="16">16</option>
- <option value="17">17</option>
- <option value="18">18</option>
- <option value="19">19</option>
- <option value="20">20</option>
- <option value="21">21</option>
- <option value="22">22</option>
- <option value="23">23</option>
- </select> hours
- <select style="width:50px; margin-left:0px;" id="node-input-nadirOffsetMinutes">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="15">15</option>
- <option value="20">20</option>
- <option value="25">25</option>
- <option value="30">30</option>
- <option value="35">35</option>
- <option value="40">40</option>
- <option value="45">45</option>
- <option value="50">50</option>
- <option value="55">55</option>
- </select> minutes
- <input type="hidden" id="node-input-nadirOffset">
- </div>
-
- <hr />
-
- <!-- nightEnd -->
- <div class="form-row">
- <label for="node-input-nightEnd"><i class="fa fa-clock-o"></i> Night End</label>
- <span>Morning astronomical twilight starts</span>
- </div>
-
- <div class="form-row">
- <label for="node-input-nightEndPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload">Payload</span></label>
- <input type="text" id="node-input-nightEndPayload" style="width:70%">
- <input type="hidden" id="node-input-nightEndPayloadType">
- </div>
-
- <div class="form-row">
- <label for="node-input-nightEndTopic"><i class="fa fa-tasks"></i> <span>Topic</span></label>
- <input type="text" id="node-input-nightEndTopic">
- </div>
-
- <div class="form-row">
- <label for="node-input-nightEndOffsetType"><i class="fa fa-sliders"></i> <span>Offset</span></label>
- <select style="width:50px; margin-left:0px;" id="node-input-nightEndOffsetType">
- <option value="1">+</option>
- <option value="-1">-</option>
- </select>
- <select style="width:50px; margin-left:0px;" id="node-input-nightEndOffsetHours">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="11">11</option>
- <option value="12">12</option>
- <option value="13">13</option>
- <option value="14">14</option>
- <option value="15">15</option>
- <option value="16">16</option>
- <option value="17">17</option>
- <option value="18">18</option>
- <option value="19">19</option>
- <option value="20">20</option>
- <option value="21">21</option>
- <option value="22">22</option>
- <option value="23">23</option>
- </select> hours
- <select style="width:50px; margin-left:0px;" id="node-input-nightEndOffsetMinutes">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="15">15</option>
- <option value="20">20</option>
- <option value="25">25</option>
- <option value="30">30</option>
- <option value="35">35</option>
- <option value="40">40</option>
- <option value="45">45</option>
- <option value="50">50</option>
- <option value="55">55</option>
- </select> minutes
- <input type="hidden" id="node-input-nightEndOffset">
- </div>
-
- <hr />
-
- <!-- nauticalDawn -->
- <div class="form-row">
- <label for="node-input-nauticalDawn"><i class="fa fa-clock-o"></i> Nautical Dawn</label>
- <span>Morning nautical twilight starts</span>
- </div>
-
- <div class="form-row">
- <label for="node-input-nauticalDawnPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload">Payload</span></label>
- <input type="text" id="node-input-nauticalDawnPayload" style="width:70%">
- <input type="hidden" id="node-input-nauticalDawnPayloadType">
- </div>
-
- <div class="form-row">
- <label for="node-input-nauticalDawnTopic"><i class="fa fa-tasks"></i> <span>Topic</span></label>
- <input type="text" id="node-input-nauticalDawnTopic">
- </div>
-
- <div class="form-row">
- <label for="node-input-nauticalDawnOffsetType"><i class="fa fa-sliders"></i> <span>Offset</span></label>
- <select style="width:50px; margin-left:0px;" id="node-input-nauticalDawnOffsetType">
- <option value="1">+</option>
- <option value="-1">-</option>
- </select>
- <select style="width:50px; margin-left:0px;" id="node-input-nauticalDawnOffsetHours">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="11">11</option>
- <option value="12">12</option>
- <option value="13">13</option>
- <option value="14">14</option>
- <option value="15">15</option>
- <option value="16">16</option>
- <option value="17">17</option>
- <option value="18">18</option>
- <option value="19">19</option>
- <option value="20">20</option>
- <option value="21">21</option>
- <option value="22">22</option>
- <option value="23">23</option>
- </select> hours
- <select style="width:50px; margin-left:0px;" id="node-input-nauticalDawnOffsetMinutes">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="15">15</option>
- <option value="20">20</option>
- <option value="25">25</option>
- <option value="30">30</option>
- <option value="35">35</option>
- <option value="40">40</option>
- <option value="45">45</option>
- <option value="50">50</option>
- <option value="55">55</option>
- </select> minutes
- <input type="hidden" id="node-input-nauticalDawnOffset">
- </div>
-
- <hr />
-
- <!-- dawn -->
- <div class="form-row">
- <label for="node-input-dawn"><i class="fa fa-clock-o"></i> Dawn</label>
- <span>Morning nautical twilight ends, morning civil twilight starts</span>
- </div>
-
- <div class="form-row">
- <label for="node-input-dawnPayload"><i class="fa fa-envelope"></i> <span data-i18n="common.label.payload">Payload</span></label>
- <input type="text" id="node-input-dawnPayload" style="width:70%">
- <input type="hidden" id="node-input-dawnPayloadType">
- </div>
-
- <div class="form-row">
- <label for="node-input-dawnTopic"><i class="fa fa-tasks"></i> <span>Topic</span></label>
- <input type="text" id="node-input-dawnTopic">
- </div>
-
- <div class="form-row">
- <label for="node-input-dawnOffsetType"><i class="fa fa-sliders"></i> <span>Offset</span></label>
- <select style="width:50px; margin-left:0px;" id="node-input-dawnOffsetType">
- <option value="1">+</option>
- <option value="-1">-</option>
- </select>
- <select style="width:50px; margin-left:0px;" id="node-input-dawnOffsetHours">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="11">11</option>
- <option value="12">12</option>
- <option value="13">13</option>
- <option value="14">14</option>
- <option value="15">15</option>
- <option value="16">16</option>
- <option value="17">17</option>
- <option value="18">18</option>
- <option value="19">19</option>
- <option value="20">20</option>
- <option value="21">21</option>
- <option value="22">22</option>
- <option value="23">23</option>
- </select> hours
- <select style="width:50px; margin-left:0px;" id="node-input-dawnOffsetMinutes">
- <option value="0">00</option>
- <option value="1">01</option>
- <option value="2">02</option>
- <option value="3">03</option>
- <option value="4">04</option>
- <option value="5">05</option>
- <option value="6">06</option>
- <option value="7">07</option>
- <option value="8">08</option>
- <option value="9">09</option>
- <option value="10">10</option>
- <option value="15">15</option>
- <option value="20">20</option>
- <option value="25">25</option>
- <option value="30">30</option>
- <option value="35">35</option>
- <option value="40">40</option>
- <option value="45">45</option>
- <option value="50">50</option>
- <option value="55">55</option>
- </select> minutes
- <input type="hidden" id="node-input-dawnOffset">
- </div>
-
- <hr />
- </script>
-
- <script type="text/x-red" data-help-name="suncron">
- <p>This node emits configurable outgoing messages based on the position of the sun.</p>
- <h3>Sun event outputs</h3>
- <dl class="message-properties">
- <dt>msg.payload
- <span class="property-type">string | bool | number | obj</span>
- </dt>
- <dt>msg.topic
- <span class="property-type">string</span>
- </dt>
- <dt>msg.schedule
- <span class="property-type">obj</span>
- </dt>
- <dt>msg.next
- <span class="property-type">obj</span>
- </dt>
- </dl>
- <h4>Details</h4>
- <p>
- For each significant sun event (e.g. sunrise, noon, dusk etc.) a <code>msg.payload</code> and <code>msg.topic</code> can be
- specified which the node will emit once the event fires.
- </p>
- <p>
- You can configure a positive or negative offset to adjust each event.
- </p>
- <h4>Schedule</h4>
- <p>
- The <code>msg.schedule</code> attribute contains an object with details about the
- schedule of the current date. The schedule contains only events which have been configured with a payload.
- Each event has the following attributes:
- <ul>
- <li><code>event</code> is the name of the sun event</li>
- <li><code>sunEventTime</code> refers to the unadjusted time of the respective sun event.</li>
- <li><code>cronTime</code> refers to the adjusted time, i.e. taking the offset into account.</li>
- </ul>
- </p>
- <h5>Example <code>msg.schedule</code> object</h5>
- <pre>
- {
- "sunrise": {
- "event": "sunrise",
- "sunEventTime": "2019-09-08T06:29:51",
- "cronTime": "2019-09-08T07:31:51"
- },
- "sunriseEnd": {
- "event": "sunriseEnd",
- "sunEventTime": "2019-09-08T06:33:24",
- "cronTime": "2019-09-08T03:33:24"
- },
- "dawn": {
- "event": "dawn",
- "sunEventTime": "2019-09-08T05:54:49",
- "cronTime": "2019-09-08T06:54:49"
- }
- ...
- }
- </pre>
- <h4>Next</h4>
- <p>
- The <code>msg.next</code> attribute contains the event object of the schedule which is coming up next.
- </p>
- <h3>Schedule event outputs</h3>
- <p>
- If the checkbox "Emit schedule when updated" is ticked, the node will emit additional messages whenever
- the schedule gets updated. This happens on startup, when offsets are overridden at runtime, and shortly
- after midnight. Those messages will contain the schedule object as <code>msg.payload</code> (same structure as above)
- and the string "suncron:schedule" as <code>msg.topic</code>.
- </p>
- <dl class="message-properties">
- <dt>msg.payload
- <span class="property-type">obj</span>
- </dt>
- <dt>msg.topic
- <span class="property-type">"suncron:schedule"</span>
- </dt>
- </dl>
- </script>
|