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 0.2.0-alpha.2 to 0.2.0-alpha.3

16

nodes/lib/dateTimeHelper.js

@@ -379,3 +379,3 @@ /********************************************

function normalizeDate(d, offset, multiplier, next, days) {
// console.debug('normalizeDate d=' + d + ' offset=' + offset + ' next=' + next + ' days=' + days);
console.debug('normalizeDate d=' + d + ' offset=' + offset + ' next=' + next + ' days=' + days); // eslint-disable-line
d = addOffset(d, offset, multiplier);

@@ -413,3 +413,3 @@ if (next && !isNaN(next)) {

function normalizeDateUTC(d, offset, multiplier, next, days) {
// console.debug('normalizeDateUTC d=' + d + ' offset=' + offset + ' next=' + next + ' days=' + days);
console.debug('normalizeDateUTC d=' + d + ' offset=' + offset + ' next=' + next + ' days=' + days); // eslint-disable-line
d = addOffset(d, offset, multiplier);

@@ -444,3 +444,3 @@ if (next && !isNaN(next)) {

function getTimeOfText(t, date) {
// console.debug('getTimeOfText t=' + t + ' date=' + date);
console.debug('getTimeOfText t=' + t + ' date=' + date); // eslint-disable-line
const d = date || new Date();

@@ -467,2 +467,3 @@ if (t && (t.indexOf('.') === -1) && (t.indexOf('-') === -1)) {

function getDateOfText(dt) {
console.log('getDateOfText dt=' + util.inspect(dt)); // eslint-disable-line
if (dt === null || typeof dt === 'undefined') {

@@ -925,3 +926,3 @@ throw new Error('Could not evaluate as a valid Date or time. Value is null or undefined!');

function getFormattedDateOut(date, format, dayNames, monthNames, dayDiffNames) {
// console.log('getFormattedDateOut ' + date + ' --> ' + format + ' [' + dayNames + '] - [' + monthNames + '] [' + dayDiffNames + ']'); // eslint-disable-line
console.log('getFormattedDateOut date=' + date + ' --> format=' + format + ' [' + dayNames + '] - [' + monthNames + '] [' + dayDiffNames + ']'); // eslint-disable-line
format = format || 0;

@@ -1095,3 +1096,3 @@ if (isNaN(format)) {

function getDateFromFormat(val, format) {
// console.log('getDateFromFormat ' + val + ' --> ' + format); // eslint-disable-line
// console.log('getDateFromFormat val=' + val + ' --> format=' + format); // eslint-disable-line
val = String(val);

@@ -1329,2 +1330,3 @@ format = String(format);

function parseDate(val, preferEuro) {
console.debug('parseDate val=' + val + ' - preferEuro=' + preferEuro); // eslint-disable-line
let res = _parseArray(val, dateFormat.parseDates.general);

@@ -1345,2 +1347,3 @@ if (res !== null) { return res; }

function parseDateTime(val, preferEuro) {
console.debug('parseDateTime val=' + val + ' - preferEuro=' + preferEuro); // eslint-disable-line
function mix(lst1, lst2, result) {

@@ -1377,3 +1380,4 @@ for (let i = 0; i < lst1.length; i++) {

function parseDateFromFormat(date, format, dayNames, monthNames, dayDiffNames) {
console.debug('parseDateFromFormat ' + util.inspect(date) + ' - ' + util.inspect(format) + 'dayNames'); // eslint-disable-line
console.debug('parseDateFromFormat date=' + util.inspect(date) + ' - format=' + util.inspect(format) + ' dayNames'); // eslint-disable-line
// console.log('getFormattedDateOut date=' + date + ' --> format=' + format + ' [' + dayNames + '] - [' + monthNames + '] [' + dayDiffNames + ']'); // eslint-disable-line
if (dayNames) {

@@ -1380,0 +1384,0 @@ dateFormat.i18n.dayNames = dayNames;

@@ -109,3 +109,3 @@ /********************************************

this.getSunTime = (now, value, offset, multiplier, next, days) => {
// node.debug('getSunTime value=' + value + ' offset=' + offset + ' multiplier=' + multiplier + ' next=' + next + ' days=' + days);
node.debug('getSunTime value=' + value + ' offset=' + offset + ' multiplier=' + multiplier + ' next=' + next + ' days=' + days);
let result = sunTimesCheck(node, now);

@@ -152,3 +152,3 @@ result = Object.assign(result, node.sunTimesToday[value]);

this.getMoonTime = (now, value, offset, multiplier, next, days) => {
// node.debug('getMoonTime value=' + value + ' offset=' + offset + ' next=' + next + ' days=' + days);
node.debug('getMoonTime value=' + value + ' offset=' + offset + ' next=' + next + ' days=' + days);
const result = moonTimesCheck(node, now);

@@ -187,2 +187,3 @@ // node.debug('Moon Times today =' + util.inspect(node.moonTimesToday));

this.getFloatProp = (_srcNode, msg, type, value) => {
_srcNode.debug('getFloatProp type='+type+' value='+value);
let data;

@@ -209,3 +210,4 @@ // 'msg', 'flow', 'global', 'num', 'bin', 'env', 'jsonata'

this.getOutDataProp = (srcNode, msg, vType, value, format, offset, multiplier) => {
this.getOutDataProp = (_srcNode, msg, vType, value, format, offset, multiplier) => {
_srcNode.debug('getOutDataProp type='+vType+' value='+value+' format='+format+' offset='+offset+' multiplier='+multiplier);
let result = null;

@@ -246,6 +248,7 @@ if (vType === null || vType === 'none' || vType === '' || vType === 'date') {

}
return RED.util.evaluateNodeProperty(value, vType, srcNode, msg);
return RED.util.evaluateNodeProperty(value, vType, _srcNode, msg);
};
this.getDateFromProp = (srcNode, msg, vType, value, format, offset, multiplier) => {
this.getDateFromProp = (_srcNode, msg, vType, value, format, offset, multiplier) => {
_srcNode.debug('getDateFromProp type='+vType+' value='+value+' format='+format+' offset='+offset+' multiplier='+multiplier);
let result = null;

@@ -283,7 +286,7 @@ if (vType === null || vType === 'none' || vType === '') {

// msg, flow, global, str, num, env
result = RED.util.evaluateNodeProperty(value, vType, srcNode, msg);
result = RED.util.evaluateNodeProperty(value, vType, _srcNode, msg);
}
if (result !== null && typeof result !== 'undefined') {
result = hlp.parseDateFromFormat(result, format, RED._('position-config.days'), RED._('position-config.month'), RED._('position-config.dayDiffNames'));
if (result.value === 'Invalid Date' || isNaN(result.value) || result.value === null) {
if (result === 'Invalid Date' || isNaN(result) || result === null) {
throw new Error('could not evaluate format of ' + result);

@@ -296,4 +299,4 @@ }

this.getTimeProp = (srcNode, msg, vType, value, offset, multiplier, next, days) => {
// node.debug('getTimeProp ' + hlp.getNodeId(srcNode) + ' vType=' + vType + ' value=' + value + ' offset=' + offset + ' multiplier=' + multiplier + ' next=' + next + ' days=' + days);
this.getTimeProp = (_srcNode, msg, vType, value, offset, multiplier, next, days) => {
node.debug('getTimeProp ' + hlp.getNodeId(_srcNode) + ' vType=' + vType + ' value=' + value + ' offset=' + offset + ' multiplier=' + multiplier + ' next=' + next + ' days=' + days);
const now = new Date();

@@ -328,3 +331,3 @@ let result = {

result.fix = (vType === 'json'); // is not a fixed time if can be changed
const res = RED.util.evaluateNodeProperty(value, vType, srcNode, msg);
const res = RED.util.evaluateNodeProperty(value, vType, _srcNode, msg);
if (res) {

@@ -331,0 +334,0 @@ result.value = hlp.getDateOfText(res);

@@ -151,3 +151,3 @@ /************************************************************************/

TimePredefined: {
value: 'predefined',
value: 'TimePredefined',
label: 'time (current day)',

@@ -154,0 +154,0 @@ options: ['midnight (current day)', 'noon (current day)']

@@ -61,3 +61,3 @@ /********************************************

}
// this.error("Input parameter wrong or missing. You need to setup (or give in the input message) the 'url' and 'content type' or the 'message' and 'language'!!");
// this.error("Input parameter wrong or missing. You need to setup (or give in the input message) the 'URL' and 'content type' or the 'message' and 'language'!!");
// this.status({fill:"red",shape:"dot",text:"error - input parameter"});

@@ -64,0 +64,0 @@ });

@@ -0,0 +0,0 @@ /* eslint-disable */

@@ -0,0 +0,0 @@ [{

@@ -22,42 +22,51 @@ /********************************************

this.on('input', msg => {
node.debug('config ' + util.inspect(config)); // eslint-disable-line
node.debug('on input - msg ' + util.inspect(msg)); // eslint-disable-line
if (node.positionConfig === null ||
config.operator === null ||
config.inputType === null) {
node.status({
fill: 'red',
shape: 'ring',
text: 'Configuration is missing!!'
});
throw new Error('Configuration is missing!!');
}
try {
node.debug('input ' + util.inspect(msg));
if (
node.positionConfig === null ||
config.operator === null ||
config.inputType === null
) {
throw new Error('Configuration is missing!!');
}
node.debug('emit ' + util.inspect(msg));
const offset1 = node.positionConfig.getFloatProp(node,msg,config.inputOffsetType, config.inputOffset);
const inputData = node.positionConfig.getDateFromProp(node, msg, config.inputType, config.input, config.inputFormat, offset1, config.inputOffsetMultiplier);
node.debug('inputData ' + util.inspect(inputData));
const offset1 = this.positionConfig.getFloatProp(node,msg,config.inputOffsetType, config.inputOffset);
const inputData = this.positionConfig.getDateFromProp(node, msg, config.inputType, config.input, config.inputFormat, offset1, config.inputOffsetMultiplier);
if (config.result1Type !== 'none' && config.result1Value) {
let resObj = null;
if (config.result1Type !== 'none') {
let resultObj = null;
if (config.result1Type === 'input') {
resObj = hlp.getFormattedDateOut(inputData, config.result1Format, RED._('time-comp.days'), RED._('time-comp.month'), RED._('time-comp.dayDiffNames'));
resultObj = hlp.getFormattedDateOut(inputData, config.result1Format, RED._('time-comp.days'), RED._('time-comp.month'), RED._('time-comp.dayDiffNames'));
} else {
resObj = this.positionConfig.getOutDataProp(node, msg, config.result1ValueType, config.result1Value, config.result1Format, config.result1Offset, config.result1Multiplier);
resultObj = node.positionConfig.getOutDataProp(node, msg, config.result1ValueType, config.result1Value, config.result1Format, config.result1Offset, config.result1Multiplier);
}
node.debug('resObj ' + util.inspect(resObj));
if (resObj === null) {
node.debug('resultObj ' + util.inspect(resultObj)); // eslint-disable-line
if (resultObj === null) {
throw new Error('could not evaluate ' + config.result1ValueType + '.' + config.result1Value);
} else if (resObj.error) {
this.error('error on getting result: ' + resObj.error);
} else if (resultObj.error) {
node.error('error on getting result: ' + resultObj.error);
} else if (config.result1Type === 'msgPayload') {
msg.payload = resObj;
msg.payload = resultObj;
} else if (config.result1Type === 'msgTs') {
msg.ts = resObj;
msg.ts = resultObj;
} else if (config.result1Type === 'msgValue') {
msg.value = resultObj;
} else if (config.result1Type === 'msg') {
RED.util.setMessageProperty(msg, config.result1Value, resObj, true);
RED.util.setMessageProperty(msg, config.result1Value, resultObj, true);
} else if (config.result1Type === 'flow' || config.result1Type === 'global') {
const contextKey = RED.util.parseContextStore(config.result1Value);
node.context()[config.result1Type].set(contextKey.key, resObj, contextKey.store);
node.context()[config.result1Type].set(contextKey.key, resultObj, contextKey.store);
}
}
node.debug('input ' + util.inspect(inputData));
const resObj = null;
node.debug('msg ' + util.inspect(msg)); // eslint-disable-line
const resObj = [];
const rules = config.rules;

@@ -67,2 +76,3 @@ const rulesLength = rules.length;

const rule = rules[i];
node.debug('checking rule ' + util.inspect(rule)); // eslint-disable-line
let operatorValid = true;

@@ -75,3 +85,3 @@ if (rule.propertyType !== 'none') {

if (operatorValid) {
const ruleoperand = this.positionConfig.getDateFromProp(node, msg, rule.operandType, rule.operandValue, rule.format, rule.offsetValue, rule.multiplier);
const ruleoperand = node.positionConfig.getDateFromProp(node, msg, rule.operandType, rule.operandValue, rule.format, rule.offsetValue, rule.multiplier);
node.debug('operand ' + util.inspect(ruleoperand));

@@ -195,5 +205,6 @@ node.debug('operator ' + util.inspect(rule.operator));

resObj.push(msg);
return resObj;
node.debug('result object ' + util.inspect(resObj)); // eslint-disable-line
node.send(resObj);
} catch (err) {
hlp.handleError(this, RED._('time-comp.errors.error-text'), err, RED._('time-comp.errors.error-title'));
hlp.handleError(node, RED._('time-comp.errors.error-text'), err, RED._('time-comp.errors.error-title'));
}

@@ -205,3 +216,3 @@ });

RED.httpAdmin.get('/sun-position/js/*', (_req,_res) => {
RED.httpAdmin.get('/sun-position/js/*', RED.auth.needsPermission('sun-position.read'), (_req,_res) => {
const options = {

@@ -208,0 +219,0 @@ root: __dirname + '/static/',

@@ -16,10 +16,10 @@ /********************************************

const now = new Date();
let millis = time.getTime() - now.getTime();
let milis = time.getTime() - now.getTime();
if (limit) {
while (millis < limit) {
millis += 86400000; // 24h
while (milis < limit) {
milis += 86400000; // 24h
}
}
return millis;
return milis;
}

@@ -196,8 +196,8 @@

let millis = tsGetScheduleTime(node.nextTime, 10);
let milis = tsGetScheduleTime(node.nextTime, 10);
const isAlt = (node.nextTimeAlt);
if (isAlt) {
const millisAlt = tsGetScheduleTime(node.nextTimeAlt, 10);
if (millisAlt < millis) {
millis = millisAlt;
const milisAlt = tsGetScheduleTime(node.nextTimeAlt, 10);
if (milisAlt < milis) {
milis = milisAlt;
isAltFirst = true;

@@ -207,3 +207,3 @@ }

// node.debug('timeout ' + node.nextTime + ' is in ' + millis + 'ms (isAlt=' + isAlt + ' isAltFirst=' + isAltFirst + ')');
// node.debug('timeout ' + node.nextTime + ' is in ' + milis + 'ms (isAlt=' + isAlt + ' isAltFirst=' + isAltFirst + ')');
node.timeOutObj = setTimeout((isAlt, isAltFirst) => {

@@ -247,3 +247,3 @@ const msg = {

node.emit('input', msg);
}, millis, isAlt, isAltFirst);
}, milis, isAlt, isAltFirst);
}

@@ -250,0 +250,0 @@

@@ -298,3 +298,3 @@ /********************************************

function timeCalcNode(config) {
function timeSpanNode(config) {
RED.nodes.createNode(this, config);

@@ -320,4 +320,4 @@ // Retrieve the config node

try {
const offset1 = this.positionConfig.getFloatProp(node,msg,config.operand1OffsetType, config.operand1Offset);
const operand1 = this.positionConfig.getDateFromProp(node, msg, config.operand1Type, config.operand1, config.operand1Format, offset1, config.operand1OffsetMultiplier);
const offset1 = node.positionConfig.getFloatProp(node,msg,config.operand1OffsetType, config.operand1Offset);
const operand1 = node.positionConfig.getDateFromProp(node, msg, config.operand1Type, config.operand1, config.operand1Format, offset1, config.operand1OffsetMultiplier);
node.debug('operand1 ' + util.inspect(operand1)); // eslint-disable-line

@@ -327,4 +327,4 @@ if (operand1 === null) {

}
const offset2 = this.positionConfig.getFloatProp(node,msg,config.operand2OffsetType, config.operand2Offset);
const operand2 = this.positionConfig.getDateFromProp(node, msg, config.operand2Type, config.operand2, config.operand2Format, offset2, config.operand2OffsetMultiplier);
const offset2 = node.positionConfig.getFloatProp(node,msg,config.operand2OffsetType, config.operand2Offset);
const operand2 = node.positionConfig.getDateFromProp(node, msg, config.operand2Type, config.operand2, config.operand2Format, offset2, config.operand2OffsetMultiplier);
node.debug('operand2 ' + util.inspect(operand2)); // eslint-disable-line

@@ -349,4 +349,4 @@ if (operand2 === null) {

} else {
const resOffset = this.positionConfig.getFloatProp(node,msg,config.result1OffsetType, config.result1Offset);
resObj = this.positionConfig.getOutDataProp(node, msg, config.result1ValueType, config.result1Value, config.result1Format, resOffset, config.result1Multiplier);
const resOffset = node.positionConfig.getFloatProp(node,msg,config.result1OffsetType, config.result1Offset);
resObj = node.positionConfig.getOutDataProp(node, msg, config.result1ValueType, config.result1Value, config.result1Format, resOffset, config.result1Multiplier);
}

@@ -367,3 +367,3 @@ // to

} else if (resObj.error) {
this.error('error on getting result: ' + resObj.error);
node.error('error on getting result: ' + resObj.error);
} else if (config.result1Type === 'msg' || config.result1Type === 'msgProperty') {

@@ -385,3 +385,3 @@ RED.util.setMessageProperty(msg, config.result1, resObj);

try {
let ruleoperand = this.positionConfig.getFloatProp(this, msg, rule.operandType, rule.operandValue);
let ruleoperand = node.positionConfig.getFloatProp(node, msg, rule.operandType, rule.operandValue);
if (!isNaN(rule.multiplier) && rule.multiplier !== 0) {

@@ -425,3 +425,3 @@ ruleoperand = ruleoperand * rule.multiplier;

} catch (err) {
hlp.handleError(this, RED._('time-calc.errors.error-text'), err, RED._('time-calc.errors.error-title'));
hlp.handleError(node, RED._('time-span.errors.error-text'), err, RED._('time-span.errors.error-title'));
resObj.push(null);

@@ -439,5 +439,5 @@ continue;

node.debug('result object ' + util.inspect(resObj)); // eslint-disable-line
this.send(resObj);
node.send(resObj);
} catch (err) {
hlp.handleError(this, RED._('time-calc.errors.error-text'), err, RED._('time-calc.errors.error-title'));
hlp.handleError(node, RED._('time-span.errors.error-text'), err, RED._('time-span.errors.error-title'));
}

@@ -447,5 +447,5 @@ });

RED.nodes.registerType('time-span', timeCalcNode);
RED.nodes.registerType('time-span', timeSpanNode);
RED.httpAdmin.get('/sun-position/js/*', RED.auth.needsPermission('sun-position.read'), (req,res) => {
RED.httpAdmin.get('/sun-position/js/*', RED.auth.needsPermission('sun-position.read'), (_req,_res) => {
const options = {

@@ -455,4 +455,4 @@ root: __dirname + '/static/',

};
res.sendFile(req.params[0], options);
_res.sendFile(_req.params[0], options);
});
};

@@ -235,5 +235,5 @@ /********************************************

const result = calcWithinTimes(this, null, config);
// if an error occured, will retry in 6 minutes. This will prevent errors on initialisation.
// if an error occurred, will retry in 6 minutes. This will prevent errors on initialization.
if (setstate(this, result, (config.statusOut || 3), null, true)) {
node.debug('node is in initialisation, retrigger time calculation in 6 min');
node.debug('node is in initialization, retrigger time calculation in 6 min');
setTimeout(() => {

@@ -240,0 +240,0 @@ try {

{
"name": "node-red-contrib-sun-position",
"version": "0.2.0-alpha.2",
"version": "0.2.0-alpha.3",
"description": "NodeRED nodes to get sun and moon position",

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

@@ -645,21 +645,9 @@ # node-red-contrib-sun-position for NodeRED

- [ ] change icon size to 40x60 <https://github.com/node-red/node-red.github.io/pull/39>
- [ ] add posibility to select input/output timezone
- [ ] select auto ad get info from getTimezoneOffset
- [ ] add possibility to select input/output timezone
- [ ] select auto add get info from getTimezoneOffset
- [ ] solve problem of dst
- [x] time Span
- [x] zeitraum zwischen 2 zeitpunkten ausrechnen
- [x] die möglichkeit statt Zeitpunkt - Zeitraum auszugeben auch sowas wie Zeitpunkt - Zeitraum > Limit true/false rauszugeben
- [ ] offset für Input als Typed Input mit Wahl des offset: NA, num, msg, flow, global
- [ ] als Input 1. Des Monats, letzter Tag des Monats, Monatsmitte, erster+ letzter Mo, Di, Mi, Do, Fr, Sa, So im Monat
- [ ] within-time
- [ ] add Payload hinzufügen wie bei time inject - um beispielsweise dem Message Objekt mehr Infos hinzuzufügen
- [ ] als Start und Ende Midnight hinzufügen
- [ ] add result like other nodes
- [ ] remove status configuration, always show start and end
- [ ] offset als Typed Input mit Wahl des offset: NA, num, msg, flow, global
- [ ] Time Inject
- [ ] Midnight als auswahl für Zeit hinzufügen
- [ ] offset als Typed Input mit Wahl des offset: NA, num, msg, flow, global
- [ ] time-comp
- [ ] vergleicht mit 1. Des Monats, letzter Tag des Monats, Monatsmitte, erster+ letzter Mo, Di, Mi, Do, Fr, Sa, So im Monat
- [ ] offset als Typed Input mit Wahl des offset: NA, num, msg, flow, global

@@ -666,0 +654,0 @@ ## Bugs and Feedback

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

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