Socket
Socket
Sign inDemoInstall

node-red-contrib-sun-position

Package Overview
Dependencies
Maintainers
1
Versions
136
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-red-contrib-sun-position - npm Package Compare versions

Comparing version 1.2.0 to 1.2.2

.github/dependabot.yml

1

.github/ISSUE_TEMPLATE/support-request.md

@@ -9,3 +9,2 @@ ---

* [RedMatic Slack (chat like WhatsApp or Facebook Messenger)](https://join.slack.com/t/homematicuser/shared_invite/enQtNDgyNDM2OTkyMDA2LWY1YjY0NTE0NmY0OWM3YWUzMzAzMTgxYmRjMTMyOWE3NjkxNDdlMDY5ZjlhYzM5Nzg2N2U2YjdmNzNlYWNhNTU)
* [RedMatic Forum](https://homematic-forum.de/forum/viewforum.php?f=77)

@@ -12,0 +11,0 @@ * [RedMatic Wiki](https://github.com/rdmtc/RedMatic/wiki)

# node-red-contrib-sun-position
#### 1.2.0: rework
# Installation
Install of a specific Version in Node-Red:
- change to the installation directory of Node-Red
- enter the command `npm install node-red-contrib-sun-position@1.2.0`
Install of a specific Version in a Homematic:
- logon per ssh
- enter the commands:
- `source /usr/local/addons/redmatic/home/.profile`
- `cd /usr/local/addons/redmatic/var`
- `npm install --save --no-package-lock --global-style --save-prefix="~" --production node-red-contrib-sun-position@1.2.0`
#### 1.2.2: BugFix
- general
- internal object property `sunset` renamed to `sunsetEnd` and `sunrise` to `sunriseStart` (#213). This leads into problems with backward compatibilities. In any select box where `sunset` or `sunrise` is selected, it needs to reselect the right time.
- blind-control + clock-time
- fix that note settings overwrite by message and payload does not working #233
- fix bug with missing function #223
#### 1.2.1: rework
- general
- changed several links to documentation #151
- replaced all remaining png type graphics with svg
- added examples
- minor bug fixes (#196, )
- blind-control + clock-time
- Standardization and consolidation of the same and similar functions #186
- minor bugs fixed with it
- minor bugs fixed with it (#198, #200)
- blind-control only
- for Blind control the current used mode as operator (#197)
- add a `msg.resetOnSameValue` parameter to reset existing overwrite if `msg.payload` equals to position (`node.previousData.level`) (#223)
- time inject

@@ -23,3 +49,3 @@ - fixed bug, that interval between times does not start when load node and time in in the interval #189

- time-span
- TODO: similar as time-comp
- redesign of the output similar as time-comp

@@ -26,0 +52,0 @@ - within-time-switch

@@ -91,2 +91,11 @@ /********************************************

}
/**
* check if angle is between start and end
*/
function angleBetween_(angle, start, end) {
if(start<end) return start<=angle && angle<=end;
return start<=angle || angle<=end;
}
/******************************************************************************************/

@@ -101,4 +110,3 @@ /**

// node.debug('sunPosition: ' + util.inspect(sunPosition, { colors: true, compact: 10, breakLength: Infinity }));
sunPosition.InWindow = (sunPosition.azimuthDegrees >= node.windowSettings.AzimuthStart) &&
(sunPosition.azimuthDegrees <= node.windowSettings.AzimuthEnd);
sunPosition.InWindow = angleBetween_(sunPosition.azimuthDegrees, node.windowSettings.AzimuthStart, node.windowSettings.AzimuthEnd);
// node.debug(`sunPosition: InWindow=${sunPosition.InWindow} azimuthDegrees=${sunPosition.azimuthDegrees} AzimuthStart=${node.windowSettings.AzimuthStart} AzimuthEnd=${node.windowSettings.AzimuthEnd}`);

@@ -110,6 +118,6 @@ if (node.autoTrigger ) {

node.autoTrigger.type = 4; // Sun not visible
} else if (sunPosition.azimuthDegrees <= node.windowSettings.AzimuthStart) {
} else if (!sunPosition.InWindow) {
node.autoTrigger.time = Math.min(node.autoTrigger.time, cautoTriggerTimeBeforeSun);
node.autoTrigger.type = 5; // sun before in window
} else if (sunPosition.azimuthDegrees <= node.windowSettings.AzimuthEnd) {
} else if (sunPosition.InWindow) {
if (node.smoothTime > 0) {

@@ -255,3 +263,3 @@ node.autoTrigger.time = Math.min(node.autoTrigger.time, node.smoothTime);

const allowRound = (msg.topic ? (msg.topic.includes('roundLevel') || msg.topic.includes('roundLevel')) : false);
if (!ctrlLib.validPosition_(node, newPos, allowRound)) {
if (!ctrlLib.validPosition(node, newPos, allowRound)) {
node.error(RED._('blind-control.errors.invalid-blind-level', { pos: newPos }));

@@ -265,5 +273,10 @@ return false;

const noSameValue = hlp.getMsgBoolValue(msg, 'ignoreSameValue');
const resetOnSameValue = hlp.getMsgBoolValue(msg, 'resetOnSameValue');
if (noSameValue && (node.previousData.level === newPos)) {
node.debug(`overwrite exit true noSameValue=${noSameValue}, newPos=${newPos}`);
node.debug(`overwrite exit true ignoreSameValue=${noSameValue}, newPos=${newPos}`);
return ctrlLib.setOverwriteReason(node);
} if (resetOnSameValue && (node.previousData.level === newPos)) {
node.debug(`resetOnSameValue active, reset overwrite and exit newPos=${newPos}`);
ctrlLib.posOverwriteReset(node);
return ctrlLib.setOverwriteReason(node);
}

@@ -922,50 +935,56 @@ node.level.current = newPos;

switch (msg.topic) {
case 'setSmoothTime':
node.smoothTime = parseFloat(msg.Payload) || node.smoothTime;
/* Blind Settings */
case 'setBlindSettingsTop':
node.nodeData.levelTop = parseFloat(msg.payload) || node.nodeData.levelTop;
break;
case 'setAutoTriggerTime':
node.autoTrigger.defaultTime = parseFloat(msg.Payload) || node.autoTrigger.defaultTime;
case 'setBlindSettingsBottom':
node.nodeData.levelBottom = parseFloat(msg.payload) || node.nodeData.levelBottom;
break;
case 'setStoreName':
node.storeName = msg.Payload || node.storeName;
case 'setBlindSettingsIncrement':
node.nodeData.increment = parseFloat(msg.payload) || node.nodeData.increment;
break;
case 'setSunDataTopic':
node.sunData.topic = msg.Payload || node.sunData.topic;
/* Default Settings */
case 'setBlindSettingsLevel':
node.nodeData.levelDefault = parseFloat(msg.payload) || node.nodeData.levelDefault;
break;
case 'setSunDataFloorLength':
node.sunData.floorLength = parseFloat(msg.Payload) || node.sunData.floorLength;
case 'setSettingsTopic':
node.nodeData.topic = msg.payload || node.nodeData.topic;
break;
case 'setSunDataMinAltitude':
node.sunData.minAltitude = parseFloat(msg.Payload) || node.sunData.minAltitude;
break;
case 'setSunDataMinDelta':
node.sunData.minDelta = parseFloat(msg.Payload) || node.sunData.minDelta;
break;
/* Window Settings */
case 'setWindowSettingsTop':
node.windowSettings.top = parseFloat(msg.Payload) || node.windowSettings.top;
node.windowSettings.top = parseFloat(msg.payload) || node.windowSettings.top;
break;
case 'setWindowSettingsBottom':
node.windowSettings.bottom = parseFloat(msg.Payload) || node.windowSettings.bottom;
node.windowSettings.bottom = parseFloat(msg.payload) || node.windowSettings.bottom;
break;
case 'setWindowSettingsAzimuthStart':
node.windowSettings.AzimuthStart = parseFloat(msg.Payload) || node.windowSettings.AzimuthStart;
node.windowSettings.AzimuthStart = parseFloat(msg.payload) || node.windowSettings.AzimuthStart;
break;
case 'setWindowSettingsAzimuthEnd':
node.windowSettings.AzimuthEnd = parseFloat(msg.Payload) || node.windowSettings.AzimuthEnd;
node.windowSettings.AzimuthEnd = parseFloat(msg.payload) || node.windowSettings.AzimuthEnd;
break;
case 'setBlindSettingsTop':
node.nodeData.levelTop = parseFloat(msg.Payload) || node.nodeData.levelTop;
/* sun Control Settings */
case 'setSunDataTopic':
node.sunData.topic = msg.payload || node.sunData.topic;
break;
case 'setBlindSettingsBottom':
node.nodeData.levelBottom = parseFloat(msg.Payload) || node.nodeData.levelBottom;
case 'setSunDataFloorLength':
node.sunData.floorLength = parseFloat(msg.payload) || node.sunData.floorLength;
break;
case 'setBlindSettingsIncrement':
node.nodeData.increment = parseFloat(msg.Payload) || node.nodeData.increment;
case 'setSunDataMinAltitude':
node.sunData.minAltitude = parseFloat(msg.payload) || node.sunData.minAltitude;
break;
case 'setBlindSettingsLevel':
node.nodeData.levelDefault = parseFloat(msg.Payload) || node.nodeData.levelDefault;
/* minimum changes Settings */
case 'setSunDataMinDelta':
node.sunData.minDelta = parseFloat(msg.payload) || node.sunData.minDelta;
break;
case 'setSettingsTopic':
node.nodeData.topic = msg.Payload || node.nodeData.topic;
case 'setSmoothTime':
node.smoothTime = parseFloat(msg.payload) || node.smoothTime;
break;
/* advanced Settings */
case 'setAutoTriggerTime':
node.autoTrigger.defaultTime = parseFloat(msg.payload) || node.autoTrigger.defaultTime;
break;
case 'setStoreName':
node.storeName = msg.payload || node.storeName;
break;
default:

@@ -972,0 +991,0 @@ break;

@@ -459,9 +459,9 @@ /********************************************

case 'setAutoTriggerTime':
node.autoTrigger.defaultTime = parseFloat(msg.Payload) || node.autoTrigger.defaultTime;
node.autoTrigger.defaultTime = parseFloat(msg.payload) || node.autoTrigger.defaultTime;
break;
case 'setStoreName':
node.storeName = msg.Payload || node.storeName;
node.storeName = msg.payload || node.storeName;
break;
case 'setSettingsTopic':
node.nodeData.topic = msg.Payload || node.nodeData.topic;
node.nodeData.topic = msg.payload || node.nodeData.topic;
break;

@@ -468,0 +468,0 @@ default:

@@ -225,6 +225,6 @@ /*

* @property {suntime} goldenHourDuskEnd - The sun-time for evening golden hour starts
* @property {suntime} sunriseStart - The sun-time for sunrise starts (top edge of the sun appears on the horizon)
* @property {suntime} sunriseEnd - The sun-time for sunrise ends (bottom edge of the sun touches the horizon)
* @property {suntime} sunsetStart - The sun-time for sunset starts (bottom edge of the sun touches the horizon)
* @property {suntime} sunrise - The sun-time for sunrise (top edge of the sun appears on the horizon)
* @property {suntime} sunset - The sun-time for sunset (sun disappears below the horizon, evening civil twilight starts)
* @property {suntime} sunsetEnd - The sun-time for sunset ends (sun disappears below the horizon, evening civil twilight starts)
* @property {suntime} blueHourDawnStart - The sun-time for blue Hour start (time for special photography photos starts)

@@ -248,4 +248,4 @@ * @property {suntime} blueHourDawnEnd - The sun-time for blue Hour end (time for special photography photos end)

* @property {suntime} [goldenHour] - Deprecated: alternate for goldenHourDuskStart
* @property {suntime} [sunsetEnd] - Deprecated: alternate for sunset
* @property {suntime} [sunriseStart] - Deprecated: alternate for sunrise
* @property {suntime} [sunset] - Deprecated: alternate for sunsetEnd
* @property {suntime} [sunrise] - Deprecated: alternate for sunriseStart
* @property {suntime} [goldenHourEnd] - Deprecated: alternate for goldenHourDawnEnd

@@ -259,3 +259,3 @@ * @property {suntime} [goldenHourStart] - Deprecated: alternate for goldenHourDuskStart

[-0.3, 'sunriseEnd', 'sunsetStart'], // SUNRISE_END
[-0.833, 'sunrise', 'sunset'], // SUNRISE
[-0.833, 'sunriseStart', 'sunsetEnd'], // SUNRISE
[-1, 'goldenHourDawnStart', 'goldenHourDuskEnd'], // GOLDEN_HOUR_1

@@ -278,4 +278,4 @@ [-4, 'blueHourDawnEnd', 'blueHourDuskStart'], // BLUE_HOUR

['goldenHour', 'goldenHourDuskStart'],
['sunriseStart', 'sunrise'],
['sunsetEnd', 'sunset'],
['sunrise', 'sunriseStart'],
['sunset', 'sunsetEnd'],
['goldenHourEnd', 'goldenHourDawnEnd'],

@@ -282,0 +282,0 @@ ['goldenHourStart', 'goldenHourDuskStart']

@@ -210,21 +210,25 @@ /********************************************

delete el.thresholdValue;
el.result = node.positionConfig.comparePropValue(node, msg,
{
value: el.operand.value,
type: el.operand.type,
callback: (result, _obj) => { // opCallback
el.operandValue = _obj.value;
return evalTempData(node, _obj.type, _obj.value, result, tempData);
if (el.operand.type === 'sunControlMode') {
el.result = (node.sunData && (node.sunData.mode === el.operand.value));
} else {
el.result = node.positionConfig.comparePropValue(node, msg,
{
value: el.operand.value,
type: el.operand.type,
callback: (result, _obj) => { // opCallback
el.operandValue = _obj.value;
return evalTempData(node, _obj.type, _obj.value, result, tempData);
}
},
el.operator.value,
{
value: el.threshold.value,
type: el.threshold.type,
callback: (result, _obj) => { // opCallback
el.thresholdValue = _obj.value;
return evalTempData(node, _obj.type, _obj.value, result, tempData);
}
}
},
el.operator.value,
{
value: el.threshold.value,
type: el.threshold.type,
callback: (result, _obj) => { // opCallback
el.thresholdValue = _obj.value;
return evalTempData(node, _obj.type, _obj.value, result, tempData);
}
}
);
);
}
rule.conditon = {

@@ -558,2 +562,11 @@ index : i,

};
if (operandAType === 'sunControlMode') {
if (operandAValue === 'off' || operandAValue.charAt(0) === '0') {
el.operand.value = 0;
} else if (operandAValue === 'maximize' || operandAValue.charAt(0) === '1') {
el.operand.value = 1;
} else {
el.operand.value = 2;
}
}
if (el.operandName.length > 25) {

@@ -560,0 +573,0 @@ el.operandNameShort = getNameShort(operandAType, operandAValue);

@@ -48,6 +48,6 @@ {

"sunControlOff": "keine Beschränkung, Sonnenstands unabhängig",
"sunControlRestrict": "Sonnenlicht beschränken (Sommer)",
"sunControlMaximize": "Sonnenlicht maximieren (Winter)",
"sunControlRestrict": "Sonnenlicht beschränken (🌞 Sommer)",
"sunControlMaximize": "Sonnenlicht maximieren (⛄ Winter)",
"sunFloorLength": "Länge auf dem Boden",
"sunMinAltitude": "Minimaler Höhenwinkel",
"sunMinAltitude": "Minimale Sonnenhöhenwinkel",
"sunMinDelta": "Mindeständerung",

@@ -145,3 +145,3 @@ "sunTopic": "Topic 🌞/⛄",

"sunControlMode": "Anstelle der standard Rollladenposition kann das Ausmaß in dem direktes Sonnenlicht in den Raum scheint eingeschränkt werden.",
"windowAzimuth": "Darstellung der Ausrichtung des Fensters zum geografischen Norden (in Grad), wenn die Sonne in das Fenster fällt (Sonnenazimut).",
"windowAzimuth": "Darstellung der Ausrichtung des Fensters zum geografischen Norden (in Grad), wenn die Sonne in das Fenster fällt (Sonnenrichtung/Azimuth).",
"windowPos": "Fenster Eigenschaften, Messung vom Boden bis zum unter und Oberseite des Fensters",

@@ -152,3 +152,3 @@ "oversteer": "erlaubt das Übersteuern der Position in Abhängigkeit von der Sonne unter definierten Bedingungen wie Wetter (z. B. Wolkenhimmel, Beleuchtung, etc.)",

"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."
"sunCtrlRestrict": "Begrenzen Sie die Häufigkeit von Änderungen nach Zeit und / oder Änderungsgröße (Delta). Minimaler Höhenwinkel (Sonnenhöhenwinkel/Altitude in Grad) der Sonne."
},

@@ -155,0 +155,0 @@ "typeOptions": {

{
"moon-position": {
"label": {
"azimuthpos":"azimuth Position",
"azimuthpos":"Moondrichtung",
"between":"zwischen",

@@ -6,0 +6,0 @@ "and":"und"

@@ -33,6 +33,6 @@ {

"suninsky":"Sonne am Himmel (Prozent)",
"sunAzimuth":"Azimuth of sun",
"sunElevation":"Elevation of sun",
"sunAzimuthRad":"Azimuth of sun (rad)",
"sunElevationRad":"Elevation of sun (rad)",
"sunAzimuth":"Sonnenrichtung",
"sunElevation":"Sonnenhöhe",
"sunAzimuthRad":"Sonnenrichtung (rad)",
"sunElevationRad":"Sonnenhöhe (rad)",
"suntime":"Sonnenzeit",

@@ -51,3 +51,7 @@ "suntimes":"Sonnenzeiten",

"DayOfYear":"Tag des Jahres (Zahl)",
"isDayOfYearEven":"gerader Tag des Jahres (true/false)"
"isDayOfYearEven":"gerader Tag des Jahres (true/false)",
"sunControlMode": "Aktueller Modus Sonnensteuerung",
"sunControlOff": "aus",
"sunControlRestrict": "Sonnenlicht beschränken (🌞 Sommer)",
"sunControlMaximize": "Sonnenlicht maximieren (⛄ Winter)"
},

@@ -64,3 +68,3 @@ "typeOptions": {

"goldenHourDawnStart": "Goldene Morgenstunde Begin",
"sunrise": "Sonnenaufgang Begin",
"sunriseStart": "Sonnenaufgang Begin",
"sunriseEnd": "Sonnenaufgang Ende",

@@ -71,3 +75,3 @@ "goldenHourDawnEnd": "Goldene Morgenstunde Ende",

"sunsetStart": "Sonnenuntergang Begin",
"sunset": "Sonnenuntergang Ende",
"sunsetEnd": "Sonnenuntergang Ende",
"goldenHourDuskEnd": "Goldene Abendstunde Ende",

@@ -74,0 +78,0 @@ "blueHourDuskStart": "Blaue Abendstunde Begin",

{
"sun-position": {
"label": {
"azimuthpos":"azimuth Position",
"azimuthpos":"Sonnenrichtung",
"between":"zwischen",

@@ -6,0 +6,0 @@ "and":"und",

@@ -61,3 +61,7 @@ {

"DayOfYear":"day number",
"isDayOfYearEven":"is day even (true/false)"
"isDayOfYearEven":"is day even (true/false)",
"sunControlMode": "current sun control mode",
"sunControlOff": "off",
"sunControlRestrict": "restrict sunlight (🌞 Summer)",
"sunControlMaximize": "maximize sunlight (⛄ Winter)"
},

@@ -74,3 +78,3 @@ "typeOptions": {

"goldenHourDawnStart": "golden hour dawn start",
"sunrise": "sunrise start",
"sunriseStart": "sunrise start",
"sunriseEnd": "sunrise end",

@@ -81,3 +85,3 @@ "goldenHourDawnEnd": "golden hour dawn end",

"sunsetStart": "sunset start",
"sunset": "sunset end",
"sunsetEnd": "sunset end",
"goldenHourDuskEnd": "golden hour dusk end",

@@ -84,0 +88,0 @@ "blueHourDuskStart": "blue hour dusk start",

@@ -137,2 +137,32 @@ /************************************************************************/

/**
* check types of deprecate values
* @param {*} type type to check
* @param {*} value value to check
* @returns original value or replaced one
*/
function checkDeprecatedValues(type, value) {
if (type === 'pdsTime') {
const data = [
['dawn', 'civilDawn'],
['dusk', 'civilDusk'],
['nightEnd', 'astronomicalDawn'],
['night', 'astronomicalDusk'],
['nightStart', 'astronomicalDusk'],
['goldenHour', 'goldenHourDuskStart'],
['sunrise', 'sunriseStart'],
['sunset', 'sunsetEnd'],
['goldenHourEnd', 'goldenHourDawnEnd'],
['goldenHourStart', 'goldenHourDuskStart']
];
for (let index = 0; index < data.length; index++) {
if (value === data[index][0]) {
value = data[index][1];
break;
}
}
}
return value;
}
/**
* get types for typeInputs

@@ -291,4 +321,4 @@ * @param {*} node - node representation for access to i18N function (node._())

}, {
value: 'sunrise',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.sunrise')
value: 'sunriseStart',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.sunriseStart')
}, {

@@ -310,4 +340,4 @@ value: 'sunriseEnd',

}, {
value: 'sunset',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.sunset')
value: 'sunsetEnd',
label: node._('node-red-contrib-sun-position/position-config:common.typeOptions.sunsetEnd')
}, {

@@ -755,10 +785,13 @@ value: 'goldenHourDuskEnd',

const $typeField = $('#node-input-' + data.typeProp);
let type='';
if (typeof node[data.typeProp] === 'undefined' ||
node[data.typeProp] === null) {
if (typeof data.defaultType !== 'undefined') {
node[data.typeProp] = data.defaultType;
$typeField.val(data.defaultType);
type = data.defaultType;
node[data.typeProp] = type;
$typeField.val(type);
}
} else {
$typeField.val(node[data.typeProp]);
type = node[data.typeProp];
$typeField.val(type);
}

@@ -772,2 +805,3 @@ if (typeof node[data.valueProp] === 'undefined' ||

} else {
node[data.valueProp] = checkDeprecatedValues(type, node[data.valueProp]);
$inputField.val(node[data.valueProp]);

@@ -795,2 +829,19 @@ }

/**
* set Data for typed input
* @param {*} $field Typed input field
* @param {*} value value to set
* @param {*} type type to set
*/
function setTInputValue($field, value, type) { // eslint-disable-line no-unused-vars
if (type === 'flow' || type === 'global') {
$field.typedInput('type', 'env'); // env haben alle, bug fix
$field.typedInput('value', checkDeprecatedValues(type, value));
$field.typedInput('type', type);
} else {
$field.typedInput('type', type);
$field.typedInput('value', checkDeprecatedValues(type, value));
}
}
/**
* sets a checkbox matrix

@@ -1026,7 +1077,7 @@ * @param {string} element name of the element as jQuery element name

let res = '';
if (!data || data.type === 'none' || data.type === '' || data.type === 'jsonata' || data.type === 'json' || data.type === 'bin') {
if (!data || data.type === 'none' || data.type === '' || data.type === 'json' || data.type === 'bin') {
res = data.type;
} else if ( data.type === 'bool') {
res = data.value;
} else if (data.type === 'msg' || data.type === 'flow' || data.type === 'global' || data.type === 'env') {
} else if (data.type === 'msg' || data.type === 'env') {
res = data.type + '.' + data.value;

@@ -1033,0 +1084,0 @@ } else if (data.type === 'msgPayload') {

@@ -33,12 +33,15 @@ /********************************************

config.results.push({
p: config.result1 ? config.result1 : 'msgPayload',
pt: config.result1Type ? config.result1Type : 'input',
v: config.result1Value ? config.result1Value : '',
vt: config.result1ValueType ? config.result1ValueType : 'input',
o: config.result1Offset ? config.result1Offset : 1,
oT: (config.result1OffsetType === 0 || config.result1OffsetType === '') ? 'none' : (config.result1OffsetType ? config.result1OffsetType : 'num'),
oM: config.result1OffsetMultiplier ? config.result1OffsetMultiplier : 60000,
f: config.result1Format ? config.result1Format : 0,
next: false,
days: '*'
p : config.result1 ? config.result1 : 'msgPayload',
pt : config.result1Type ? config.result1Type : 'input',
v : config.result1Value ? config.result1Value : '',
vt : config.result1ValueType ? config.result1ValueType : 'input',
o : config.result1Offset ? config.result1Offset : 1,
oT : (config.result1OffsetType === 0 || config.result1OffsetType === '') ? 'none' : (config.result1OffsetType ? config.result1OffsetType : 'num'),
oM : config.result1OffsetMultiplier ? config.result1OffsetMultiplier : 60000,
f : config.result1Format ? config.result1Format : 0,
next : false,
days : '*',
months : '*',
onlyEvenDays: false,
onlyOddDays : false
});

@@ -60,12 +63,15 @@ }

const propNew = {
outType: prop.pt,
outValue: prop.p,
type: prop.vt,
value: prop.v,
format: prop.f,
offsetType: prop.oT,
offset: prop.o,
multiplier: prop.oM,
next: (typeof prop.next === 'undefined' || prop.next === null || prop.next === true || prop.next === 'true') ? true : false,
days: prop.days
outType : prop.pt,
outValue : prop.p,
type : prop.vt,
value : prop.v,
format : prop.f,
offsetType : prop.oT,
offset : prop.o,
multiplier : prop.oM,
next : (typeof prop.next === 'undefined' || prop.next === null || prop.next === true || prop.next === 'true') ? true : false,
days : prop.days,
months : prop.months,
onlyEvenDays: prop.onlyEvenDays,
onlyOddDays : prop.onlyOddDays
};

@@ -147,3 +153,2 @@

}
// node.debug(i + ' rule=' + util.inspect(rule, { colors: true, compact: 10, breakLength: Infinity }));

@@ -262,5 +267,2 @@ let compare = null;

// node.debug(i + ' inputOperant=' + util.inspect(inputOperant, { colors: true, compact: 10, breakLength: Infinity }));
// node.debug(i + ' ruleoperand=' + util.inspect(ruleoperand, { colors: true, compact: 10, breakLength: Infinity }));
result = compare(inputOperant.getTime(), ruleoperand.getTime());

@@ -270,5 +272,2 @@ if (rule.operatorType.indexOf('18') >= 0) {

}
// node.debug(i + ' result=' + util.inspect(result, { colors: true, compact: 10, breakLength: Infinity }));
// node.debug(i + ' inputData=' + util.inspect(inputData, { colors: true, compact: 10, breakLength: Infinity }));
// node.debug(i + ' operand=' + util.inspect(ruleoperand, { colors: true, compact: 10, breakLength: Infinity }));
break;

@@ -275,0 +274,0 @@ }

@@ -174,3 +174,6 @@ /********************************************

next : true,
days : '*'
days : '*',
months: '*',
onlyEvenDays: false,
onlyOddDays: false
});

@@ -188,3 +191,6 @@ if (config.topic) {

next : false,
days : '*'
days : '*',
months: '*',
onlyEvenDays: false,
onlyOddDays: false
});

@@ -206,3 +212,6 @@ }

next : false,
days : config.addPayload1Days ? config.addPayload1Days : '*'
days : config.addPayload1Days ? config.addPayload1Days : '*',
months: '*',
onlyEvenDays: false,
onlyOddDays: false
});

@@ -224,3 +233,6 @@ }

next : false,
days : config.addPayload2Days ? config.addPayload2Days : '*'
days : config.addPayload2Days ? config.addPayload2Days : '*',
months: '*',
onlyEvenDays: false,
onlyOddDays: false
});

@@ -233,12 +245,15 @@ }

config.props.push({
p : config.addPayload3,
pt : config.addPayload3Type,
v : config.addPayload3Value,
vt : config.addPayload3ValueType ? ((config.addPayload3ValueType === 'string') ? 'str' : config.addPayload3ValueType) : (config.addPayload3Value ? 'str' : 'date'),
o : config.addPayload3Offset ? config.addPayload3Offset : 1,
oT : (config.addPayload3Offset === 0 || config.addPayload3Offset === '') ? 'none' : (config.addPayload3OffsetType ? config.addPayload3OffsetType : 'num'),
oM : config.addPayload3OffsetMultiplier ? config.addPayload3OffsetMultiplier : 60000,
f : config.addPayload3Format ? config.addPayload3Format : 0,
p : config.addPayload3,
pt : config.addPayload3Type,
v : config.addPayload3Value,
vt : config.addPayload3ValueType ? ((config.addPayload3ValueType === 'string') ? 'str' : config.addPayload3ValueType) : (config.addPayload3Value ? 'str' : 'date'),
o : config.addPayload3Offset ? config.addPayload3Offset : 1,
oT : (config.addPayload3Offset === 0 || config.addPayload3Offset === '') ? 'none' : (config.addPayload3OffsetType ? config.addPayload3OffsetType : 'num'),
oM : config.addPayload3OffsetMultiplier ? config.addPayload3OffsetMultiplier : 60000,
f : config.addPayload3Format ? config.addPayload3Format : 0,
next : false,
days : config.addPayload3Days ? config.addPayload3Days : '*'
days : config.addPayload3Days ? config.addPayload3Days : '*',
months: '*',
onlyEvenDays: false,
onlyOddDays: false
});

@@ -289,12 +304,15 @@ }

const propNew = {
outType: prop.pt,
outValue: prop.p,
type: prop.vt,
value: prop.v,
format: prop.f,
offsetType: prop.oT,
offset: prop.o,
multiplier: prop.oM,
next: (typeof prop.next === 'undefined' || prop.next === null || prop.next === true || prop.next === 'true') ? true : false,
days: prop.days
outType : prop.pt,
outValue : prop.p,
type : prop.vt,
value : prop.v,
format : prop.f,
offsetType : prop.oT,
offset : prop.o,
multiplier : prop.oM,
next : (typeof prop.next === 'undefined' || prop.next === null || prop.next === true || prop.next === 'true') ? true : false,
days : prop.days,
months : prop.months,
onlyEvenDays: prop.onlyEvenDays,
onlyOddDays : prop.onlyOddDays
};

@@ -488,2 +506,3 @@

case tInj.intervalAmount:
node.debug('initialize - Intervall timer/amount');
if (doEmit) {

@@ -498,2 +517,10 @@ node.emit('input', {

break;
default:
node.debug('initialize - default');
node.doSetStatus(node, 'green');
if (doEmit) {
node.emit('input', {
type: 'once/startup'
}); // will create timeout
}
}

@@ -883,3 +910,2 @@ };

node.status({});
try {

@@ -919,2 +945,3 @@ if (!node.positionConfig) {

}
node.status({});

@@ -921,0 +948,0 @@ node.onceTimeout = setTimeout(() => {

@@ -6,8 +6,3 @@ /********************************************

const util = require('util');
const path = require('path');
const hlp = require(path.join(__dirname, '/lib/dateTimeHelper.js'));
// const path = require('path');
// const hlp = require(path.join(__dirname, '/lib/dateTimeHelper.js'));
const perSecond = 1000;

@@ -271,19 +266,84 @@ const perMinute = 60000;

this.positionConfig = RED.nodes.getNode(config.positionConfig);
this.result1Value = {
type: config.result1ValueType,
value: config.result1Value,
format: config.result1Format,
offsetType: config.result1OffsetType,
offset: config.result1Offset,
multiplier: config.result1Multiplier,
next: true
this.operand1 = {
type: config.operand1Type,
value: config.operand1,
format: config.operand1Format,
offsetType: config.operand1OffsetType,
offset: config.operand1Offset,
multiplier: config.operand1OffsetMultiplier
};
if (this.positionConfig && this.result1Value.type === 'jsonata') {
try {
this.result1Value.expr = this.positionConfig.getJSONataExpression(this, this.result1Value.value);
} catch (err) {
this.error(RED._('node-red-contrib-sun-position/position-config:errors.invalid-expr', { error:err.message }));
this.result1Value.expr = null;
this.operand2 = {
type: config.operand2Type,
value: config.operand2,
format: config.operand2Format,
offsetType: config.operand2OffsetType,
offset: config.operand2Offset,
multiplier: config.operand2OffsetMultiplier
};
if (!Array.isArray(config.results)) {
config.results = [];
if (config.result1Type && config.result1Type !== 'none') {
config.results.push({
p : config.result1 ? config.result1 : 'msgPayload',
pt : config.result1Type ? config.result1Type : 'input',
v : config.result1Value ? config.result1Value : '',
vt : config.result1ValueType ? config.result1ValueType : 'input',
fTs : config.result1TSFormat ? config.result1TSFormat : 1,
o : config.result1Offset ? config.result1Offset : 1,
oT : (config.result1OffsetType === 0 || config.result1OffsetType === '') ? 'none' : (config.result1OffsetType ? config.result1OffsetType : 'num'),
oM : config.result1OffsetMultiplier ? config.result1OffsetMultiplier : 60000,
f : config.result1Format ? config.result1Format : 0,
next : true,
days : '*',
months : '*',
onlyEvenDays: false,
onlyOddDays : false
});
}
delete config.result1;
delete config.result1Type;
delete config.result1Value;
delete config.result1ValueType;
delete config.result1TSFormat;
delete config.result1Format;
delete config.result1Offset;
delete config.result1OffsetType;
delete config.result1OffsetMultiplier;
}
this.results = [];
config.results.forEach(prop => {
const propNew = {
outType : prop.pt,
outValue : prop.p,
type : prop.vt,
value : prop.v,
format : prop.f,
offsetType : prop.oT,
offset : prop.o,
multiplier : prop.oM,
next : (typeof prop.next === 'undefined' || prop.next === null || prop.next === true || prop.next === 'true') ? true : false,
days : prop.days,
months : prop.months,
onlyEvenDays: prop.onlyEvenDays,
onlyOddDays : prop.onlyOddDays
};
if (this.positionConfig && propNew.type === 'jsonata') {
try {
propNew.expr = this.positionConfig.getJSONataExpression(this, propNew.value);
} catch (err) {
this.error(RED._('node-red-contrib-sun-position/position-config:errors.invalid-expr', { error: err.message }));
propNew.expr = null;
}
}
this.results.push(propNew);
});
this.operand = config.operand;
this.rules = config.rules;
this.checkall = config.checkall;
const node = this;

@@ -295,9 +355,10 @@

send = send || function (...args) { node.send.apply(node, args); };
const dNow = new Date();
if (node.positionConfig === null ||
typeof node.positionConfig === 'undefined' ||
config.operand1Type === null ||
typeof config.operand1Type === 'undefined' ||
config.operand2Type === null ||
typeof config.operand2Type === 'undefined') {
node.operand1.type === null ||
typeof node.operand1.type === 'undefined' ||
node.operand2.type === null ||
typeof node.operand2.type === 'undefined') {
node.status({

@@ -312,14 +373,3 @@ fill: 'red',

try {
/* const operand1 = node.positionConfig.getDateFromProp(node, msg, config.operand1Type, config.operand1, config.operand1Format, config.operand1Offset, config.operand1OffsetType, config.operand1OffsetMultiplier);
if (operand1 === null) {
return null;
} */
const operand1 = node.positionConfig.getTimeProp(node, msg, {
type: config.operand1Type,
value: config.operand1,
format: config.operand1Format,
offsetType: config.operand1OffsetType,
offset: config.operand1Offset,
multiplier: config.operand1OffsetMultiplier
});
const operand1 = node.positionConfig.getTimeProp(node, msg, node.operand1);
if (operand1.error) {

@@ -329,14 +379,3 @@ throw new Error(operand1.error);

/* const operand2 = node.positionConfig.getDateFromProp(node, msg, config.operand2Type, config.operand2, config.operand2Format, config.operand2Offset, config.operand2OffsetType, config.operand2OffsetMultiplier);
if (operand2 === null) {
return null;
} */
const operand2 = node.positionConfig.getTimeProp(node, msg, {
type: config.operand2Type,
value: config.operand2,
format: config.operand2Format,
offsetType: config.operand2OffsetType,
offset: config.operand2Offset,
multiplier: config.operand2OffsetMultiplier
});
const operand2 = node.positionConfig.getTimeProp(node, msg, node.operand2);
if (operand2.error) {

@@ -350,32 +389,35 @@ throw new Error(operand2.error);

let timeSpan = operand1.value.getTime() - operand2.value.getTime();
if (config.operand === 0) {
if (node.operand === 0) {
timeSpan = Math.abs(timeSpan);
}
if (config.result1Type !== 'none') {
for (let i = 0; i < node.results.length; i++) {
const prop = node.results[i];
// node.debug(`prepOutMsg-${i} node.results[${i}]=${util.inspect(prop, { colors: true, compact: 10, breakLength: Infinity })}`);
let resultObj = null;
if (node.result1Value.type === 'timespan') {
resultObj = getFormattedTimeSpanOut(node, operand1.value, operand2.value, config.result1TSFormat);
resultObj = getFormattedTimeSpanOut(node, operand1.value, operand2.value, prop.result1TSFormat);
} else if (node.result1Value.type === 'operand1') {
resultObj = hlp.getFormattedDateOut(operand1.value, config.result1Format);
resultObj = node.positionConfig.formatOutDate(this, msg, operand1.value, prop);
} else if (node.result1Value.type === 'operand2') {
resultObj = hlp.getFormattedDateOut(operand2.value, config.result1Format);
resultObj = node.positionConfig.formatOutDate(this, msg, operand2.value, prop);
} else {
resultObj = node.positionConfig.getOutDataProp(node, msg, node.result1Value);
resultObj = node.positionConfig.getOutDataProp(node, msg, prop, dNow);
}
// node.debug('resultObj=' + util.inspect(resultObj, { colors: true, compact: 10, breakLength: Infinity }));
if (resultObj === null || typeof resultObj === 'undefined') {
throw new Error('could not evaluate ' + node.result1Value.type + '.' + node.result1Value.value);
if (resultObj === null || (typeof resultObj === 'undefined')) {
this.error('Could not evaluate ' + prop.type + '.' + prop.value + '. - Maybe settings outdated (open and save again)!');
} else if (resultObj.error) {
node.error('error on getting result: ' + resultObj.error);
this.error('error on getting result: "' + resultObj.error + '"');
} else {
node.positionConfig.setMessageProp(this, msg, config.result1Type, config.result1, resultObj);
node.positionConfig.setMessageProp(this, msg, prop.outType, prop.outValue, resultObj);
}
// node.debug(`prepOutMsg-${i} msg=${util.inspect(msg, { colors: true, compact: 10, breakLength: Infinity })}`);
}
const resObj = [];
const rules = config.rules;
const rulesLength = rules.length;
const rulesLength = node.rules.length;
for (let i = 0; i < rulesLength; ++i) {
const rule = rules[i];
const rule = node.rules[i];
try {

@@ -386,6 +428,2 @@ let ruleoperand = node.positionConfig.getFloatProp(node, msg, rule.operandType, rule.operandValue, 0);

}
/*
node.debug('operand ' + util.inspect(ruleoperand, { colors: true, compact: 10, breakLength: Infinity }));
node.debug('operator ' + util.inspect(rule.operator, { colors: true, compact: 10, breakLength: Infinity }));
node.debug('operatorType ' + util.inspect(rule.operatorType, { colors: true, compact: 10, breakLength: Infinity })); */

@@ -418,3 +456,3 @@ let result = false;

resObj.push(msg);
if (config.checkall != 'true') { // eslint-disable-line eqeqeq
if (node.checkall != 'true') { // eslint-disable-line eqeqeq
break;

@@ -436,3 +474,2 @@ }

}
}

@@ -439,0 +476,0 @@

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

@@ -72,2 +72,14 @@ "keywords": [

"url": "https://github.com/hypnos3"
},
{
"name": "Marc Hoppe",
"url": "https://github.com/mhop"
},
{
"name": "Mauricio Bonani",
"url": "https://github.com/bonanitech"
},
{
"name": "Tom Hoover",
"url": "https://github.com/tomhoover"
}

@@ -95,5 +107,5 @@ ],

"devDependencies": {
"eslint": "^7.13.0",
"eslint": "^7.20.0",
"eslint-plugin-html": "^6.1.1",
"eslint-plugin-jsdoc": "^30.7.8",
"eslint-plugin-jsdoc": "^31.6.1",
"eslint-plugin-json": "^2.1.2",

@@ -100,0 +112,0 @@ "eslint-plugin-node": "^11.1.0"

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

For bugs, questions and feature requests please use the
[GitHub Issues](https://github.com/rdmtc/node-red-contrib-sun-position/issues), the [Homematic forum](https://homematic-forum.de/forum/viewforum.php?f=77) or the [RedMatic Slack](https://join.slack.com/t/homematicuser/shared_invite/enQtNDgyNDM2OTkyMDA2LWY1YjY0NTE0NmY0OWM3YWUzMzAzMTgxYmRjMTMyOWE3NjkxNDdlMDY5ZjlhYzM5Nzg2N2U2YjdmNzNlYWNhNTU).
[GitHub Issues](https://github.com/rdmtc/node-red-contrib-sun-position/issues), or the [Homematic forum](https://homematic-forum.de/forum/viewforum.php?f=77).

@@ -110,3 +110,2 @@ :moneybag: Donations [![Donate](https://img.shields.io/badge/donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4PCF5YW5ASHBN)

- [newreleases.io](https://newreleases.io/npm/node-red-contrib-sun-position)
- [RedMatic Slack (chat like WhatsApp or Facebook Messenger)](https://join.slack.com/t/homematicuser/shared_invite/enQtNDgyNDM2OTkyMDA2LWY1YjY0NTE0NmY0OWM3YWUzMzAzMTgxYmRjMTMyOWE3NjkxNDdlMDY5ZjlhYzM5Nzg2N2U2YjdmNzNlYWNhNTU)
- [RedMatic Forum](https://homematic-forum.de/forum/viewforum.php?f=77)

@@ -118,1 +117,2 @@ - [RedMatic Wiki](https://github.com/rdmtc/RedMatic/wiki)

- [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/rdmtc/node-red-contrib-sun-position)
- [![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/U7U3315ED)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc