node-red-contrib-sun-position
Advanced tools
Comparing version 1.0.3 to 1.0.4
# node-red-contrib-sun-position | ||
#### 1.0.4: bug fix | ||
- within-time-switch | ||
- fixed error day selection #100 | ||
- fixed wrong working month selection | ||
- sun-position | ||
- added lastUpdateStr to payload to get the original calculation base time | ||
- moon-position | ||
- added lastUpdateStr to payload to get the original calculation base time | ||
#### 1.0.3: bug fix | ||
@@ -4,0 +14,0 @@ |
@@ -18,28 +18,2 @@ /******************************************** | ||
/******************************************************************************************/ | ||
/** | ||
* the definition of the time to compare | ||
* @param {*} compareType type to compare | ||
* @param {*} msg the message object | ||
* @param {*} node the current node object | ||
*/ | ||
function getNow_(node, msg) { | ||
let value = ''; | ||
if (typeof msg.time === 'number') { | ||
value = msg.time; | ||
node.debug(`compare time to msg.time = "${value}"`); | ||
} else if (typeof msg.ts === 'number') { | ||
value = msg.ts; | ||
node.debug(`compare time to msg.ts = "${value}"`); | ||
} else { | ||
return new Date(); | ||
} | ||
const dto = new Date(value); | ||
if (hlp.isValidDate(dto)) { | ||
// node.debug(dto.toISOString()); | ||
return dto; | ||
} | ||
node.error(`Error can not get a valid timestamp from "${value}"! Will use current timestamp!`); | ||
return new Date(); | ||
} | ||
module.exports = function (RED) { | ||
@@ -718,3 +692,3 @@ 'use strict'; | ||
node.reason.code = NaN; | ||
const now = getNow_(node, msg); | ||
const now = hlp.getNowTimeStamp(node, msg); | ||
if (node.autoTrigger) { | ||
@@ -721,0 +695,0 @@ node.autoTrigger.time = node.autoTrigger.deaultTime; |
@@ -32,15 +32,4 @@ /******************************************** | ||
const errorStatus = ''; | ||
let now = new Date(); | ||
if (typeof msg.time !== 'undefined') { | ||
now = new Date(msg.time); | ||
} | ||
if (typeof msg.ts !== 'undefined') { | ||
now = new Date(msg.ts); | ||
} | ||
if (!hlp.isValidDate(now)) { | ||
now = new Date(); | ||
node.error(RED._('node-red-contrib-sun-position/position-config:errors.invalidParameter', { param: 'msg.ts', type: 'Date', newValue:now})); | ||
} | ||
const now = hlp.getNowTimeStamp(this, msg); | ||
if (!this.positionConfig) { | ||
@@ -47,0 +36,0 @@ // node.error(RED._('node-red-contrib-sun-position/position-config:errors.pos-config')); |
@@ -41,13 +41,4 @@ /******************************************** | ||
let errorStatus = ''; | ||
let now = new Date(); | ||
if (typeof msg.time !== 'undefined') { | ||
now = new Date(msg.time); | ||
} | ||
if (typeof msg.ts !== 'undefined') { | ||
now = new Date(msg.ts); | ||
} | ||
if (!hlp.isValidDate(now)) { | ||
now = new Date(); | ||
node.error(RED._('node-red-contrib-sun-position/position-config:errors.invalidParameter', { param: 'msg.ts', type: 'Date', newValue: now })); | ||
} | ||
const now = hlp.getNowTimeStamp(this, msg); | ||
if (!this.positionConfig) { | ||
@@ -54,0 +45,0 @@ // node.error(RED._('node-red-contrib-sun-position/position-config:errors.pos-config')); |
@@ -124,3 +124,4 @@ /******************************************** | ||
altEndTime: (node.propertyEndType !== 'none') && (msg || (node.propertyEndType !== 'msg')), | ||
valid:false | ||
valid: false, | ||
warn: '' | ||
}; | ||
@@ -133,6 +134,9 @@ | ||
} | ||
if (config.timeMonths && config.timeMonths !== '*' && !config.timeMonths.includes(now.getMonth())) { | ||
node.debug('invalid Day config. today=' + now.getMonth() + ' timeMonths=' + util.inspect(config.timeMonths, Object.getOwnPropertyNames(config.timeMonths))); | ||
result.warn = RED._('within-time-switch.errors.invalid-month'); | ||
return result; | ||
if (config.timeMonths && config.timeMonths !== '*') { | ||
const mn = config.timeMonths.split(','); | ||
if (!mn.includes(now.getMonth())) { | ||
node.debug('invalid Day config. today=' + now.getMonth() + ' timeMonths=' + util.inspect(config.timeMonths, Object.getOwnPropertyNames(config.timeMonths))); | ||
result.warn = RED._('within-time-switch.errors.invalid-month'); | ||
return result; | ||
} | ||
} | ||
@@ -331,3 +335,3 @@ const dateNr = now.getDate(); | ||
if (result.start.value && result.end.value) { | ||
if (result.valid && result.start.value && result.end.value) { | ||
const startNr = hlp.getTimeNumberUTC(result.start.value); | ||
@@ -352,4 +356,2 @@ const endNr = hlp.getTimeNumberUTC(result.end.value); | ||
} | ||
} else if (!result.valid) { | ||
throw new Error('Error can not calc time!'); | ||
} else { | ||
@@ -356,0 +358,0 @@ setstate(node, result); |
{ | ||
"name": "node-red-contrib-sun-position", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "NodeRED nodes to get sun and moon position", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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 too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1451566
10621