Socket
Socket
Sign inDemoInstall

node-red-contrib-sun-position

Package Overview
Dependencies
1
Maintainers
1
Versions
136
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.4 to 0.4.0

CHANGELOG.md

24

blind_control.md

@@ -28,2 +28,3 @@ # Blind Controller

* [rules](#rules)
* [rules with blind position minimum or maximum](#rules-with-blind-position-minimum-or-maximum)
* [rules example](#rules-example)

@@ -230,2 +231,5 @@ * [Samples](#samples)

* **13** - sun is not in window (maximize mode), min blind position used
* **14** - change is below defined minimum delta
* **15** - blind position is below defined minimum blind position by rule
* **16** - blind position is above defined maximum blind position by rule
* `blindCtrl.reason.state` a short text (same as node status text) representing the reason for the blind position

@@ -244,3 +248,3 @@ * `blindCtrl.reason.description` a text, describe the reason for the blind position

* `blindCtrl.rule.active` - `true` if a rule applies
* `blindCtrl.rule.ruleId` - number of the rule who applies (is `-1` if no rule has applied)
* `blindCtrl.rule.id` - number of the rule who applies (is `-1` if no rule has applied)
* `blindCtrl.rule.level` - the blind level defined by the rule [exists only if a rule applies]

@@ -251,2 +255,12 @@ * `blindCtrl.rule.conditional` - `true` if the rule has a condition [exists only if a rule applies]

* `blindCtrl.rule.time` - __object__ with additional data about the time [exists only if `blindCtrl.rule.timeLimited` is true] - good for debugging purpose
* `blindCtrl.rule.mimimum` - exists only if a minimum rule exists
* `blindCtrl.rule.mimimum.id` - number of the minimum rule who applies
* `blindCtrl.rule.mimimum.level` - the minimum blind level defined by the rule
* `blindCtrl.rule.mimimum.conditon` - __object__ with additional data about the condition
* `blindCtrl.rule.mimimum.time` - __object__ with additional data about the time
* `blindCtrl.rule.maximum` - exists only if a maximum rule exists
* `blindCtrl.rule.maximum.id` - number of the maximum rule who applies
* `blindCtrl.rule.maximum.level` - the maximum blind level defined by the rule
* `blindCtrl.rule.maximum.conditon` - __object__ with additional data about the condition
* `blindCtrl.rule.maximum.time` - __object__ with additional data about the time
* `blindCtrl.sunPosition` - calculated sub-position data - exists only if sun position is calculated

@@ -271,5 +285,5 @@ * `blindCtrl.sunPosition.InWindow` - `true` if sun is in window, otherwise `false`

The rules are not easy to understand.
The rules are not easy to understand. For simplicity, in the following description, the type of the blind position is absolute.
There are basically 4 types of rules:
There are basically 4 generic types of rules (absolute blind position):

@@ -304,2 +318,6 @@ * absolute rule

### rules with blind position minimum or maximum
### rules example

@@ -306,0 +324,0 @@

143

nodes/blind-control.js

@@ -211,18 +211,16 @@ /********************************************

if (type === 'levelFixed') {
if (value.includes('close')) {
return node.blindData.levelClosed;
} else if (value === '75%') {
return posPrcToAbs_(node, 0.75);
} else if (value === '66%') {
return posPrcToAbs_(node, 0.66666);
} else if (value === '50%') {
return posPrcToAbs_(node, 0.5);
} else if (value === '33%') {
return posPrcToAbs_(node, 0.33333);
} else if (value === '25%') {
return posPrcToAbs_(node, 0.25);
} else if (value === '10%') {
return posPrcToAbs_(node, 0.1);
} else if (value.includes('open')) {
return node.blindData.levelOpen;
const val = parseFloat(value);
if (isNaN(val)) {
if (value.includes('close')) {
return node.blindData.levelClosed;
} else if (value.includes('open')) {
return node.blindData.levelOpen;
}
} else {
if (val < 1) {
return node.blindData.levelClosed;
} else if (val > 99) {
return node.blindData.levelOpen;
}
return (val / 100);
}

@@ -447,3 +445,3 @@ throw new Error('unknown value "'+ value + '" of type "' + type + '"' );

node.blindData.level = node.blindData.levelMin;
node.blindData.levelInverse = node.blindData.levelMax;
node.blindData.levelInverse = getInversePos_(node, node.blindData.level); // node.blindData.levelMax;
node.reason.code = 13;

@@ -483,3 +481,3 @@ node.reason.state = RED._('blind-control.states.sunNotInWinMin');

node.blindData.level = node.blindData.levelMax;
node.blindData.levelInverse = node.blindData.levelMin;
node.blindData.levelInverse = getInversePos_(node, node.blindData.level); // node.blindData.levelMin;
node.reason.code = 12;

@@ -504,2 +502,5 @@ node.reason.state = RED._('blind-control.states.sunInWinMax');

}
const delta = Math.abs(node.previousData.level - node.blindData.level);
if ((node.smoothTime > 0) && (node.sunData.changeAgain > now.getTime())) {

@@ -512,2 +513,8 @@ node.debug(`no change smooth - smoothTime= ${node.smoothTime} changeAgain= ${node.sunData.changeAgain}`);

node.blindData.levelInverse = node.previousData.levelInverse;
} else if ((node.sunData.minDelta > 0) && (delta < node.sunData.minDelta) && (node.blindData.level > node.blindData.levelClosed) && (node.blindData.level < node.blindData.levelOpen)) {
node.reason.code = 14;
node.reason.state = RED._('blind-control.states.sunMinDelta', { pos: node.blindData.level.toString()});
node.reason.description = RED._('blind-control.reasons.sunMinDelta', { pos: node.blindData.level.toString()});
node.blindData.level = node.previousData.level;
node.blindData.levelInverse = node.previousData.levelInverse;
} else {

@@ -527,3 +534,3 @@ node.reason.code = 9;

node.blindData.level = node.blindData.levelMin;
node.blindData.levelInverse = node.blindData.levelMax;
node.blindData.levelInverse = getInversePos_(node, node.blindData.level); // node.blindData.levelMax;
} else if (node.blindData.level > node.blindData.levelMax) {

@@ -536,3 +543,3 @@ // max

node.blindData.level = node.blindData.levelMax;
node.blindData.levelInverse = node.blindData.levelMin;
node.blindData.levelInverse = getInversePos_(node, node.blindData.level); // node.blindData.levelMin;
}

@@ -599,3 +606,3 @@ node.debug(`calcBlindSunPosition end pos=${node.blindData.level} reason=${node.reason.code} description=${node.reason.description}`);

}
rule.timeData = node.positionConfig.getTimeProp(node, msg, rule.timeType, rule.timeValue, rule.offsetType, rule.offsetValue, rule.multiplier);
rule.timeData = node.positionConfig.getTimeProp(node, msg, rule.timeType, rule.timeValue, rule.offsetType, rule.offsetValue, rule.multiplier, false);
if (rule.timeData.error) {

@@ -616,2 +623,4 @@ hlp.handleError(node, RED._('blind-control.errors.error-time', { message: rule.timeData.error }), undefined, rule.timeData.error);

let ruleSel = null;
let ruleSelMin = null;
let ruleSelMax = null;
// node.debug('first loop ' + node.rulesCount);

@@ -621,7 +630,13 @@ for (let i = 0; i < node.rulesCount; ++i) {

// node.debug('rule ' + rule.timeOp + ' - ' + (rule.timeOp !== 1) + ' - ' + util.inspect(rule, {colors:true, compact:10}));
if (rule.timeOp !== 0) { continue; }
if (rule.timeOp === 1) { break; } // { continue; } - Until timeOp === 0
const res = fkt(rule, (r,h) => (r >= h));
if (res) {
ruleSel = res;
break;
if (res.levelOp === 1 && (!ruleSelMin)) {
ruleSelMin = res;
} else if (res.levelOp === 2 && (!ruleSelMax)) {
ruleSelMax = res;
} else {
ruleSel = res;
break;
}
}

@@ -634,13 +649,38 @@ }

// node.debug('rule ' + rule.timeOp + ' - ' + (rule.timeOp !== 1) + ' - ' + util.inspect(rule, {colors:true, compact:10}));
if (rule.timeOp === 0) { continue; }
if (rule.timeOp === 0) { break; } // { continue; } - From timeOp === 1
const res = fkt(rule, (r,h) => (r <= h));
if (res) {
ruleSel = res;
break;
if (res.levelOp === 1 && (!ruleSelMin)) {
ruleSelMin = res;
} else if (res.levelOp === 2 && (!ruleSelMax)) {
ruleSelMax = res;
} else {
ruleSel = res;
break;
}
}
}
}
if (ruleSelMin) {
livingRuleData.minimum = {
id: ruleSelMin.pos,
level: getBlindPosFromTI(node, msg, ruleSelMin.levelType, ruleSelMin.levelValue, node.blindData.levelDefault),
conditional: ruleSelMin.conditional,
timeLimited: ruleSelMin.timeLimited,
conditon: ruleSelMin.conditonData,
time: ruleSelMin.timeData
};
}
if (ruleSelMax) {
livingRuleData.maximum = {
id: ruleSelMax.pos,
level: getBlindPosFromTI(node, msg, ruleSelMax.levelType, ruleSelMax.levelValue, node.blindData.levelDefault),
conditional: ruleSelMax.conditional,
timeLimited: ruleSelMax.timeLimited,
conditon: ruleSelMax.conditonData,
time: ruleSelMax.timeData
};
}
if (ruleSel) {
ruleSel.text = '';
// ruleSel.text = '';
// node.debug('ruleSel ' + util.inspect(ruleSel, {colors:true, compact:10}));

@@ -727,2 +767,3 @@ livingRuleData.id = ruleSel.pos;

minAltitude: Number(hlp.chkValueFilled(config.sunMinAltitude, 0)),
minDelta: Number(hlp.chkValueFilled(config.sunMinDelta, 0)),
changeAgain: 0

@@ -786,2 +827,12 @@ };

}
if ((typeof config.oversteer3ValueType !== 'undefined') && (config.oversteer3ValueType !== 'none')) {
node.oversteerData.push({
value: config.oversteer3Value || '',
valueType: config.oversteer3ValueType || 'none',
operator: config.oversteer3Compare,
thresholdValue: config.oversteer3Threshold || '',
thresholdType: config.oversteer3ThresholdType,
blindPos: getBlindPosFromTI(node, undefined, config.oversteer3BlindPosType, config.oversteer3BlindPos, node.blindData.levelOpen)
});
}
}

@@ -874,2 +925,19 @@

}
if (blindCtrl.rule.minimum && (node.blindData.level < blindCtrl.rule.minimum.level)) {
// min
node.debug(`${node.blindData.level} is below rule minimum ${blindCtrl.rule.minimum.level}`);
node.reason.code = 15;
node.reason.state = RED._('blind-control.states.ruleMin', { org: node.reason.state, rule: blindCtrl.rule.minimum.id });
node.reason.description = RED._('blind-control.reasons.ruleMin', { org: node.reason.description, level: node.blindData.level, rule: blindCtrl.rule.minimum.id });
node.blindData.level = blindCtrl.rule.minimum.level;
node.blindData.levelInverse = getInversePos_(node, node.blindData.level);
} else if (blindCtrl.rule.maximum && (node.blindData.level > blindCtrl.rule.maximum.level)) {
// max
node.debug(`${node.blindData.level} is above rule maximum ${blindCtrl.rule.maximum.level}`);
node.reason.code = 26;
node.reason.state = RED._('blind-control.states.ruleMax', { org: node.reason.state, rule: blindCtrl.rule.maximum.id });
node.reason.description = RED._('blind-control.reasons.ruleMax', { org: node.reason.description, level: node.blindData.level, rule: blindCtrl.rule.maximum.id });
node.blindData.level = blindCtrl.rule.maximum.level;
node.blindData.levelInverse = getInversePos_(node, node.blindData.level);
}
if (node.blindData.level < node.blindData.levelClosed) {

@@ -951,4 +1019,2 @@ node.debug(`${node.blindData.level} is below ${node.blindData.levelClosed}`);

node.debug('initialize');
node.rulesCount = node.rulesData.length;
node.rulesTemp = [];
const getName = (type, value) => {

@@ -989,5 +1055,7 @@ if (type === 'num') {

};
node.rulesCount = node.rulesData.length;
for (let i = 0; i < node.rulesCount; ++i) {
const rule = node.rulesData[i];
rule.timeOp = Number(rule.timeOp);
rule.timeOp = Number(rule.timeOp) || 0;
rule.levelOp = Number(rule.levelOp) || 0;
rule.pos = i + 1;

@@ -1013,2 +1081,13 @@ rule.conditional = (rule.validOperandAType !== 'none');

}
node.rulesData.sort((a, b) => {
const res = (a.timeLimited - b.timeLimited);
if (res !== 0) {
return res; // not timeLimited before timeLimited
}
if ((!a.timeLimited && !b.timeLimited) || (a.timeOp === b.timeOp)) {
return a.pos - b.pos;
}
// both timeLimited:
return a.timeOp - b.timeOp;
});
}

@@ -1015,0 +1094,0 @@ initialize();

@@ -24,2 +24,5 @@ {

"ruleBlindLevel": "Rollladenposition",
"ruleLevelAbs": "👌 - Absolut",
"ruleLevelMin": "👇 - Minimum",
"ruleLevelMax": "☝️ - Maximum",
"sunControlMode": "Modus",

@@ -31,2 +34,3 @@ "sunControlOff": "keine Beschränkung, Sonnenstands unabhängig",

"sunMinAltitude": "Minimaler Höhenwinkel",
"sunMinDelta": "Mindeständerung",
"oversteerValue": "Übersteuerung",

@@ -59,2 +63,3 @@ "oversteerThreshold": "Schwelle",

"sunMinAltitude": "(opt) minimaler Höhenwinkel der Sonne",
"sunMinDelta": "(opt) mindest Änderung der Behanghöhe",
"oversteerValue": "Wert zum Vergleich",

@@ -79,4 +84,16 @@ "oversteerThreshold": "Schwelle für den Vergleich",

"sunControlMaximization":"<ul><li>Wenn keine Regel oder Überschreiben (Override) zutrifft,<ul><li>Wenn die Sonne <em>nicht</ em> in das Fenster scheint, wird die Rollladenhöhe die definierte <strong>Minimalposition</ strong> gesetzt. (Übersteuern wird ignoriert)</ li><li>Wenn sich die Sonne im Fenster befindet</ li><li>Wenn eine Übersteueruzng aufgesetzt ist und die bedingung zutrifft, wird der Behang auf die Höhe des Übersteuerns gesetzt.< / li><li>Andernfalls wird die Behanghöhe auf die definierte <strong>Maximalposition</ strong> gesetzt.</ li></ ul></ li></ ul>",
"sunControlRestriction": "Wenn keine Regel oder Überschreiben (Override) zutrifft, berechnet der Knoten die entsprechende Blindposition, um die Menge des direkten Sonnenlichts, das in den Raum fällt, zu begrenzen."
"sunControlRestriction": "Wenn keine Regel oder Überschreiben (Override) zutrifft, berechnet der Knoten die entsprechende Blindposition, um die Menge des direkten Sonnenlichts, das in den Raum fällt, zu begrenzen.",
"sunCtrlLoF": "Definition inwieweit direktes Sonnenlicht durch das Fenster in den Raum gelangen darf (als Länge auf dem Boden).",
"sunCtrlRestrict": "Begrenzen Sie die Häufigkeit von Änderungen nach Zeit und / oder Änderungsgröße (Delta). Minimaler Höhenwinkel (altitude in Grad) der Sonne."
},
"typeOptions": {
"100": "offen (max)",
"75": "75%",
"66": "66%",
"50": "50%",
"33": "33%",
"25": "25%",
"10": "10%",
"0": "geschlossen (min)"
},
"tips": {

@@ -94,2 +111,3 @@ "sunPosControl": "<a href=\"https: //github.com/rdmtc/node-red-contrib-sun-position/blob/HEAD/blind_control.md\">Dokumentation und Beispiele</a>"

"sunMinAltitude": "Sonne ist niedriger als der minimale Höhenwinkel",
"sunMinDelta": "Änderung ist geringer als die minimale Behanghöhenänderung",
"sunNotInWin": "Sonne scheint nicht in das Fenster",

@@ -113,2 +131,3 @@ "sunCtrl": "Rollladenposition wird durch den Sonnenstand bestimmt",

"sunMinAltitude": "minimaler Höhenwinkel",
"sunMinDelta": "Änderung zu gering",
"sunNotInWin": "Sonne scheint nicht ins Fenster",

@@ -118,3 +137,3 @@ "sunCtrl": "durch Sonnenstand",

"sunCtrlMax": "__org__ (max)",
"oversteer": "Wolken",
"oversteer": "Übersteuert",
"smooth": "Änderung zu __pos__ verhindert",

@@ -121,0 +140,0 @@ "sunInWinMax":"Sonne scheint ins Fenster (max)",

@@ -21,2 +21,8 @@ {

"addPayload3Offset": "Offset",
"addPayload1Next": "Zeitpunkt",
"addPayload2Next": "Zeitpunkt",
"addPayload3Next": "Zeitpunkt",
"addPayload1Next2": "nächstes Vorkommen",
"addPayload2Next2": "nächstes Vorkommen",
"addPayload3Next2": "nächstes Vorkommen",
"addPayload1Format": "Zeitformat",

@@ -47,2 +53,3 @@ "addPayload2Format": "Zeitformat",

"addPayloadOffset": "Offset des Wertes",
"addPayloadNext": "markiert=nächstes auftreten; unmarkiert=aktueller Tag, auch wenn in der Vergangenheit",
"addPayloadFormat": "format des Wertes",

@@ -49,0 +56,0 @@ "recalcTime": "Intervall in dem eine Neuberechnung des Zeitpunktes zum Senden der Nachricht stattfinden soll.",

@@ -24,2 +24,5 @@ {

"ruleBlindLevel": "blind position",
"ruleLevelAbs": "👌 - absolute",
"ruleLevelMin": "👇 - minimum",
"ruleLevelMax": "☝️ - maximum",
"sunControlMode": "mode",

@@ -31,2 +34,3 @@ "sunControlOff": "no restriction, no sun control",

"sunMinAltitude": "min altitude threshold",
"sunMinDelta": "min delta",
"oversteerValue": "oversteer",

@@ -59,2 +63,3 @@ "oversteerThreshold": "Threshold",

"sunMinAltitude": "(opt) minimum altitude of the sun for determination of blind position",
"sunMinDelta": "(opt) define the minimum change of the blind position",
"oversteerValue": "value to compare",

@@ -79,4 +84,16 @@ "oversteerThreshold": "threshold for the compare",

"sunControlMaximization":"<ul><li>If no rule or override matches<ul><li>If the sun is <em>not</em> in the window the blind will set to defined <strong>min position</strong>. (oversteer will be ignored)</li><li>If the sun is in the window</li><li>If any oversteer data are setup and oversteer conditions are fulfilled the blind will set to the defined oversteer blind position.</li><li>otherwise the blind level is set to defined <strong>max position</strong>.</li></ul></li></ul>",
"sunControlRestriction": "If no rule or override matches, the node calculates the appropriate blind position to restrict the amount of direct sunlight entering the room."
"sunControlRestriction": "If no rule or override matches, the node calculates the appropriate blind position to restrict the amount of direct sunlight entering the room.",
"sunCtrlLoF": "The limit to what extent direct sunlight is to be allowed into the room through the window, defined as a length on the floor.",
"sunCtrlRestrict": "Limit the frequency of changes by time and/or delta; set the minimum altitude (in degree) of the sun"
},
"typeOptions": {
"100": "open (max)",
"75": "75%",
"66": "66%",
"50": "50%",
"33": "33%",
"25": "25%",
"10": "10%",
"0": "closed (min)"
},
"tips": {

@@ -94,2 +111,3 @@ "sunPosControl": "<a href=\"https: //github.com/rdmtc/node-red-contrib-sun-position/blob/HEAD/blind_control.md\">Documentation and examples</a>"

"sunMinAltitude": "sun below minimum altitude",
"sunMinDelta": "change is less ad min delta",
"sunNotInWin": "Sun not in window",

@@ -102,3 +120,5 @@ "sunCtrl": "sun control",

"sunInWinMax": "Sun in window (Level is maximum)",
"sunNotInWinMin": "Sun not in window (Level is minimum)"
"sunNotInWinMin": "Sun not in window (Level is minimum)",
"ruleMin": "__org__ (__level__ is below minimum) [rule __number__]",
"ruleMax": "__org__ (__level__ is above maximum) [rule __number__]"
},

@@ -114,2 +134,3 @@ "states": {

"sunMinAltitude": "min altitude",
"sunMinDelta": "min delta",
"sunNotInWin": "no sun in window",

@@ -122,3 +143,5 @@ "sunCtrl": "sun control",

"sunInWinMax":"Sun in window (max)",
"sunNotInWinMin": "Sun not in window (min)"
"sunNotInWinMin": "Sun not in window (min)",
"ruleMin": "__org__ [min rule __number__]",
"ruleMax": "__org__ [max rule __number__]"
},

@@ -125,0 +148,0 @@ "errors": {

@@ -28,4 +28,46 @@ {

"levelfix":"Level",
"levelfree": "Level entered"
"levelfree": "Level entered",
"levelfixMin": "minimum Level",
"levelfreeMin": "minimum Level entered"
},
"typeOptions": {
"moonRise": "moon rise",
"moonSet": "moon set",
"astronomicalDawn": "astronomical dawn",
"amateurDawn": "amateur dawn",
"nauticalDawn": "nautical dawn",
"blueHourDawnStart": "blue hour dawn start",
"civilDawn": "civil dawn",
"blueHourDawnEnd": "blue hour dawn end",
"goldenHourDawnStart": "golden hour dawn start",
"sunrise": "sunrise",
"sunriseEnd": "sunrise end",
"goldenHourDawnEnd": "golden hour dawn end",
"solarNoon": "solar noon",
"goldenHourDuskStart": "golden hour dusk start",
"sunsetStart": "sunset start",
"sunset": "sunset",
"goldenHourDuskEnd": "golden hour dusk end",
"blueHourDuskStart": "blue hour dusk start",
"civilDusk": "civil dusk",
"blueHourDuskEnd": "blue hour dusk end",
"nauticalDusk": "nautical dusk",
"amateurDusk": "amateur dusk",
"astronomicalDusk": "astronomical dusk",
"nadir": "nadir",
"fMon": "first Monday",
"fTue": "first Tuesday",
"fWed": "first Wednesday",
"fThu": "first Thursday",
"fFri": "first Friday",
"fSat": "first Saturday",
"fSun": "first Sunday",
"lMon": "last Monday",
"lTue": "last Tuesday",
"lWed": "last Wednesday",
"lThu": "last Thursday",
"lFri": "last Friday",
"lSat": "last Saturday",
"lSun": "last Sunday"
},
"multiselectLbl": {

@@ -32,0 +74,0 @@ "operatorTypes": "include into compare"

@@ -21,2 +21,8 @@ {

"addPayload3Offset": "Offset",
"addPayload1Next": "occur",
"addPayload2Next": "occur",
"addPayload3Next": "occur",
"addPayload1Next2": "next occurrence",
"addPayload2Next2": "next occurrence",
"addPayload3Next2": "next occurrence",
"addPayload1Format": "time format",

@@ -47,2 +53,3 @@ "addPayload2Format": "time format",

"addPayloadOffset": "Offset to the value",
"addPayloadNext": "checked=next occurence, unchecked=current day even if in the past",
"addPayloadFormat": "format of the output",

@@ -49,0 +56,0 @@ "recalcTime": "recalculation interval of the defined times",

@@ -167,10 +167,4 @@ /********************************************

result.value = hlp.addOffset(new Date(result.value), offset, multiplier);
if (next && !isNaN(next) && result.value.getTime() <= now.getTime()) {
if (next === 1) {
result = Object.assign(result, this.sunTimesTomorow[value]);
} else if (next > 1) {
this._checkCoordinates();
const date = (new Date()).addDays(next);
result = Object.assign(result, sunCalc.getSunTimes(date, this.latitude, this.longitude)[value]);
}
if (next && result.value.getTime() <= now.getTime()) {
result = Object.assign(result, this.sunTimesTomorow[value]);
result.value = hlp.addOffset(new Date(result.value), offset, multiplier);

@@ -211,11 +205,4 @@ }

result.value = hlp.addOffset(new Date(this.moonTimesToday[value]), offset, multiplier);
if (next && !isNaN(next) && result.value.getTime() <= now.getTime()) {
if (next === 1) {
result.value = hlp.addOffset(new Date(this.moonTimesTomorow[value]), offset, multiplier);
} else if (next > 1) {
this._checkCoordinates();
const date = (new Date()).addDays(next);
const times = sunCalc.getMoonTimes(date, this.latitude, this.longitude);
result.value = hlp.addOffset(new Date(times[value]), offset, multiplier);
}
if (next && result.value.getTime() <= now.getTime()) {
result.value = hlp.addOffset(new Date(this.moonTimesTomorow[value]), offset, multiplier);
}

@@ -309,4 +296,4 @@

/*******************************************************************************************************/
getOutDataProp(_srcNode, msg, vType, value, format, offset, offsetType, multiplier, days) {
_srcNode.debug(`getOutDataProp type=${vType} value=${value} format=${format} offset=${offset} offset=${offsetType} multiplier=${multiplier} tzOffset=${this.tzOffset}`);
getOutDataProp(_srcNode, msg, vType, value, format, offset, offsetType, multiplier, next, days) {
_srcNode.debug(`getOutDataProp type=${vType} value=${value} format=${format} offset=${offset} offsetType=${offsetType} multiplier=${multiplier} next=${next} days=${days} tzOffset=${this.tzOffset}`);
let result = null;

@@ -332,6 +319,6 @@ if (vType === null || vType === 'none' || vType === '' || (typeof vType === 'undefined')) {

const offsetX = this.getFloatProp(_srcNode, msg, offsetType, offset, 0);
result = this.getSunTime((new Date()), value, offsetX, multiplier, 1, days);
result = this.getSunTime((new Date()), value, offsetX, multiplier, next, days);
} else if (vType === 'pdmTime') { // moon
const offsetX = this.getFloatProp(_srcNode, msg, offsetType, offset, 0);
result = this.getMoonTime((new Date()), value, offsetX, multiplier, 1, days);
result = this.getMoonTime((new Date()), value, offsetX, multiplier, next, days);
}

@@ -345,3 +332,3 @@ if (result && result.value && !result.error) {

const offsetX = this.getFloatProp(_srcNode, msg, offsetType, offset, 0);
result = hlp.normalizeDate(result, offsetX, multiplier, undefined, days);
result = hlp.normalizeDate(result, offsetX, multiplier, next, days);
return hlp.getFormattedDateOut(result, format, (this.tzOffset === 0), this.tzOffset);

@@ -898,3 +885,3 @@ } else if (vType === 'dayOfMonth') {

try {
obj = posConfig.getOutDataProp(posConfig, undefined, req.query.type, req.query.value, req.query.format, req.query.offset, req.query.offsetType, req.query.multiplier, req.query.days);
obj = posConfig.getOutDataProp(posConfig, undefined, req.query.type, req.query.value, req.query.format, req.query.offset, req.query.offsetType, req.query.multiplier, req.query.next, req.query.days);
} catch(err) {

@@ -901,0 +888,0 @@ obj.value = NaN;

@@ -181,26 +181,51 @@ /************************************************************************/

},
TimePredefined: {
value: 'TimePredefined',
label: node._('node-red-contrib-sun-position/position-config:common.types.timepredefined','fixed times'),
options: ['next midnight', 'next noon']
},
DayOfMonth: {
value: 'DayOfMonth',
label: node._('node-red-contrib-sun-position/position-config:common.types.dayofmonth','day of month'),
options: [
'first Monday',
'first Tuesday',
'first Wednesday',
'first Thursday',
'first Friday',
'first Saturday',
'first Sunday',
'last Monday',
'last Tuesday',
'last Wednesday',
'last Thursday',
'last Friday',
'last Saturday',
'last Sunday'
]
options: [{
value: 'astronomicalDawn',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.astronomicalDawn')
}, {
value: 'fMon',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.fMon')
}, {
value: 'fTue',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.fTue')
}, {
value: 'fWed',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.fWed')
}, {
value: 'fThu',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.fThu')
}, {
value: 'fFri',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.fFri')
}, {
value: 'fSat',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.fSat')
}, {
value: 'fSun',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.fSun')
}, {
value: 'lMon',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.lMon')
}, {
value: 'lTue',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.lTue')
}, {
value: 'lWed',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.lWed')
}, {
value: 'lThu',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.lThu')
}, {
value: 'lFri',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.lFri')
}, {
value: 'lSat',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.lSat')
}, {
value: 'lSun',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.lSun')
}]
},

@@ -211,6 +236,69 @@ TimeSun: {

icon: 'icons/node-red-contrib-sun-position/inputTypeSunClock.png',
options: [ 'astronomicalDawn', 'amateurDawn', 'nauticalDawn', 'blueHourDawnStart', 'civilDawn', 'blueHourDawnEnd',
'goldenHourDawnStart', 'sunrise', 'sunriseEnd', 'goldenHourDawnEnd', 'solarNoon', 'goldenHourDuskStart',
'sunsetStart', 'sunset', 'goldenHourDuskEnd', 'blueHourDuskStart', 'civilDusk', 'blueHourDuskEnd',
'nauticalDusk', 'amateurDusk', 'astronomicalDusk', 'nadir']
options: [{
value: 'astronomicalDawn',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.astronomicalDawn')
}, {
value: 'amateurDawn',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.amateurDawn')
}, {
value: 'nauticalDawn',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.nauticalDawn')
}, {
value: 'blueHourDawnStart',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.blueHourDawnStart')
}, {
value: 'civilDawn',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.civilDawn')
}, {
value: 'blueHourDawnEnd',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.blueHourDawnEnd')
}, {
value: 'goldenHourDawnStart',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.goldenHourDawnStart')
}, {
value: 'sunrise',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.sunrise')
}, {
value: 'sunriseEnd',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.sunriseEnd')
}, {
value: 'goldenHourDawnEnd',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.goldenHourDawnEnd')
}, {
value: 'solarNoon',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.solarNoon')
}, {
value: 'goldenHourDuskStart',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.goldenHourDuskStart')
}, {
value: 'sunsetStart',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.sunsetStart')
}, {
value: 'sunset',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.sunset')
}, {
value: 'goldenHourDuskEnd',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.goldenHourDuskEnd')
}, {
value: 'blueHourDuskStart',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.blueHourDuskStart')
}, {
value: 'civilDusk',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.civilDusk')
}, {
value: 'blueHourDuskEnd',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.blueHourDuskEnd')
}, {
value: 'nauticalDusk',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.nauticalDusk')
}, {
value: 'amateurDusk',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.amateurDusk')
}, {
value: 'astronomicalDusk',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.astronomicalDusk')
}, {
value: 'nadir',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.nadir')
}]
},

@@ -221,3 +309,9 @@ TimeMoon: {

icon: 'icons/node-red-contrib-sun-position/inputTypeMoonClock.png',
options: ['rise', 'set']
options: [{
value: 'rise',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.moonRise', 'rise')
}, {
value: 'set',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.moonSet', 'set')
}]
},

@@ -224,0 +318,0 @@ SunCalc: {

@@ -38,3 +38,3 @@ /********************************************

} else {
resultObj = node.positionConfig.getOutDataProp(node, msg, config.result1ValueType, config.result1Value, config.result1Format, config.result1Offset, config.result1OffsetType, config.result1Multiplier);
resultObj = node.positionConfig.getOutDataProp(node, msg, config.result1ValueType, config.result1Value, config.result1Format, config.result1Offset, config.result1OffsetType, config.result1Multiplier, true);
}

@@ -41,0 +41,0 @@

@@ -26,6 +26,11 @@ /********************************************

function tsSetAddProp(node, msg, type, name, valueType, value, format, offset, offsetType, multiplier, days) {
function tsSetAddProp(node, msg, type, name, valueType, value, format, offset, offsetType, multiplier, days, next) {
if (typeof next === 'undefined' || next === null || next === true || next === 'true') {
next = true;
} else if (next === 'false' || next === false) {
next = false;
}
// node.debug(`tsSetAddProp ${msg}, ${type}, ${name}, ${valueType}, ${value}, ${format}, ${offset}, ${offsetType}, ${multiplier}, ${days}`);
if (type !== 'none') {
const res = node.positionConfig.getOutDataProp(node, msg, valueType, value, format, offset, offsetType, multiplier, days);
const res = node.positionConfig.getOutDataProp(node, msg, valueType, value, format, offset, offsetType, multiplier, next, days);
if (res === null || (typeof res === 'undefined')) {

@@ -102,3 +107,3 @@ throw new Error('could not evaluate ' + valueType + '.' + value);

if (node.timeType !== 'none' && node.positionConfig) {
node.nextTimeData = node.positionConfig.getTimeProp(node, undefined, node.timeType, node.time, node.offsetType, node.offset, node.offsetMultiplier, 1, node.timeDays);
node.nextTimeData = node.positionConfig.getTimeProp(node, undefined, node.timeType, node.time, node.offsetType, node.offset, node.offsetMultiplier, true, node.timeDays);
if (node.nextTimeData.error) {

@@ -123,3 +128,3 @@ errorStatus = 'could not evaluate time';

// (_srcNode, msg, vType, value, offset, offsetType, multiplier, next, days)
node.nextTimeAltData = node.positionConfig.getTimeProp(node, undefined, node.timeAltType, node.timeAlt, node.timeAltOffsetType, node.timeAltOffset, node.timeAltOffsetMultiplier, 1, node.timeAltDays);
node.nextTimeAltData = node.positionConfig.getTimeProp(node, undefined, node.timeAltType, node.timeAlt, node.timeAltOffsetType, node.timeAltOffset, node.timeAltOffsetMultiplier, true, node.timeAltDays);
if (node.nextTimeAltData.error) {

@@ -267,3 +272,3 @@ errorStatus = 'could not evaluate alternate time';

}
const value = node.positionConfig.getOutDataProp(node, msg, config.payloadType, config.payload, config.payloadTimeFormat, node.payloadOffset, config.payloadOffsetType, config.payloadOffsetMultiplier);
const value = node.positionConfig.getOutDataProp(node, msg, config.payloadType, config.payload, config.payloadTimeFormat, node.payloadOffset, config.payloadOffsetType, config.payloadOffsetMultiplier, true);
if (value === null || (typeof value === 'undefined')) {

@@ -278,7 +283,7 @@ throw new Error('could not evaluate ' + config.payloadType + '.' + config.payload);

tsSetAddProp(this, msg, config.addPayload1Type, config.addPayload1, config.addPayload1ValueType, config.addPayload1Value,
config.addPayload1Format, config.addPayload1Offset, config.addPayload1OffsetType, config.addPayload1OffsetMultiplier, config.addPayload1Days);
config.addPayload1Format, config.addPayload1Offset, config.addPayload1OffsetType, config.addPayload1OffsetMultiplier, config.addPayload1Days, config.addPayload1Next);
tsSetAddProp(this, msg, config.addPayload2Type, config.addPayload2, config.addPayload2ValueType, config.addPayload2Value,
config.addPayload2Format, config.addPayload2Offset, config.addPayload2OffsetType, config.addPayload2OffsetMultiplier, config.addPayload2Days);
config.addPayload2Format, config.addPayload2Offset, config.addPayload2OffsetType, config.addPayload2OffsetMultiplier, config.addPayload2Days, config.addPayload2Next);
tsSetAddProp(this, msg, config.addPayload3Type, config.addPayload3, config.addPayload3ValueType, config.addPayload3Value,
config.addPayload3Format, config.addPayload3Offset, config.addPayload3OffsetType, config.addPayload3OffsetMultiplier, config.addPayload3Days);
config.addPayload3Format, config.addPayload3Offset, config.addPayload3OffsetType, config.addPayload3OffsetMultiplier, config.addPayload3Days, config.addPayload3Next);

@@ -285,0 +290,0 @@ node.send(msg);

@@ -272,3 +272,3 @@ /********************************************

} else {
resultObj = node.positionConfig.getOutDataProp(node, msg, config.result1ValueType, config.result1Value, config.result1Format, config.result1Offset, config.result1OffsetType, config.result1Multiplier);
resultObj = node.positionConfig.getOutDataProp(node, msg, config.result1ValueType, config.result1Value, config.result1Format, config.result1Offset, config.result1OffsetType, config.result1Multiplier, true);
}

@@ -275,0 +275,0 @@ // to

{
"name": "node-red-contrib-sun-position",
"version": "0.3.4",
"version": "0.4.0",
"description": "NodeRED nodes to get sun and moon position",

@@ -5,0 +5,0 @@ "keywords": [

@@ -24,2 +24,3 @@ # node-red-contrib-sun-position for NodeRED

* [Table of contents](#table-of-contents)
* [Preconditions](#preconditions)
* [Installation](#installation)

@@ -65,2 +66,6 @@ * [General](#general)

## Preconditions
These nodes need at least Node-Red with Version 0.18! Any early Version of Node-Red will not work!
## Installation

@@ -67,0 +72,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc