Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.0.0-alpha-5 to 1.0.0-alpha-6

26

nodes/clock-timer.js

@@ -16,4 +16,3 @@ /********************************************

const cRuleLogOperatorOr = 1;
const cautoTriggerTimeFull = 60 * 60000; // <- 1h
// const cautoTriggerTimeSmall = 10 * 60000; // 10 min
const cautoTriggerTime = 20 * 60000;

@@ -222,10 +221,10 @@ /******************************************************************************************/

let overrideTopic = undefined;
if (!onlyTrigger && msg.payload) {
if (msg.payload.value && (msg.payload.expires || msg.payload.prio || msg.payload.priority)) {
overrideData = msg.payload.value;
overrideTopic = msg.topic;
} else if (msg.topic && (msg.topic.includes('manual') ||
if (!onlyTrigger && typeof msg.payload !== 'undefined') {
if (msg.topic && (msg.topic.includes('manual') ||
msg.topic.includes('overwrite'))) {
overrideData = msg.payload;
overrideTopic = msg.topic;
} else if (typeof msg.payload === 'object' && (msg.payload.value && (msg.payload.expires || msg.payload.prio || msg.payload.priority))) {
overrideData = msg.payload.value;
overrideTopic = msg.topic;
}

@@ -666,4 +665,6 @@ }

node.reason.stateComplete = node.reason.state ;
if (timeCtrl.payload && typeof timeCtrl.payload !== 'object') {
node.reason.stateComplete = hlp.clipStrLength(timeCtrl.payload.toString(),10) + ' - ' + node.reason.stateComplete;
if (timeCtrl.payloadOut === null || typeof timeCtrl.payloadOut !== 'object') {
node.reason.stateComplete = hlp.clipStrLength(''+timeCtrl.payloadOut,20) + ' - ' + node.reason.stateComplete;
} else if (typeof timeCtrl.payloadOut === 'object') {
node.reason.stateComplete = hlp.clipStrLength(JSON.stringify(timeCtrl.payloadOut),20) + ' - ' + node.reason.stateComplete;
}

@@ -702,3 +703,3 @@ node.status({

timeClock: node.timeClockData,
payload: node.payload.current
payloadOut: node.payload.current
};

@@ -713,3 +714,3 @@ const tempData = node.context().get('cacheData',node.storeName) || {};

if (node.autoTrigger) {
node.autoTriggerTime = cautoTriggerTimeFull;
node.autoTriggerTime = cautoTriggerTime;
node.autoTriggerType = 0;

@@ -745,4 +746,5 @@ }

if (node.payload.current &&
if (typeof node.payload.current !== 'undefined' &&
node.payload.current !== 'none' &&
node.payload.current !== null &&
((node.reason.code !== previousData.reasonCode) ||

@@ -749,0 +751,0 @@ (ruleId !== previousData.usedRule))) {

@@ -13,2 +13,3 @@ /********************************************

// (function() {
/*******************************************************************************************************/

@@ -92,5 +93,5 @@ const moonPhases = [{

/**
* creates a new instance of the settings node and initializes them
* @param {*} config - configuration of the node
*/
* creates a new instance of the settings node and initializes them
* @param {*} config - configuration of the node
*/
constructor(config) {

@@ -147,5 +148,5 @@ RED.nodes.createNode(this, config);

/**
* register a node as child
* @param {*} node node to register as child node
*/
* register a node as child
* @param {*} node node to register as child node
*/
register(node) {

@@ -156,7 +157,7 @@ this.users[node.id] = node;

/**
* remove a previous registered node as child
* @param {*} node node to remove
* @param {function} done function which should be executed after deregister
* @returns {*} result of the function
*/
* remove a previous registered node as child
* @param {*} node node to remove
* @param {function} done function which should be executed after deregister
* @returns {*} result of the function
*/
deregister(node, done) {

@@ -168,26 +169,26 @@ delete node.users[node.id];

/**
* @typedef {Object} timeresult
* @property {Date} value - a Date object of the neesed date/time
* @property {number} ts - The time as unix timestamp
* @property {number} pos - The position of the sun on the time
* @property {number} angle - Angle of the sun on the time
* @property {number} julian - The time as julian calendar
* @property {boolean} valid - indicates if the time is valid or not
*/
* @typedef {Object} timeresult
* @property {Date} value - a Date object of the neesed date/time
* @property {number} ts - The time as unix timestamp
* @property {number} pos - The position of the sun on the time
* @property {number} angle - Angle of the sun on the time
* @property {number} julian - The time as julian calendar
* @property {boolean} valid - indicates if the time is valid or not
*/
/**
* @typedef {Object} erroresult
* @property {string} error - string of an error message if an error occurs
*/
* @typedef {Object} erroresult
* @property {string} error - string of an error message if an error occurs
*/
/**
* gets sun time by Name
* @param {Date} now current time
* @param {string} value name of the sun time
* @param {number} [offset] the offset (positive or negative) which should be added to the date. If no multiplier is given, the offset must be in milliseconds.
* @param {number} [multiplier] additional multiplier for the offset. Should be a positive Number. Special value -1 if offset is in month and -2 if offset is in years
* @param {number} [next] if greater than 0 the number of days in the future
* @param {string} [days] days for which should be calculated the sun time
* @return {timeresult|erroresult} result object of sunTime
*/
* gets sun time by Name
* @param {Date} now current time
* @param {string} value name of the sun time
* @param {number} [offset] the offset (positive or negative) which should be added to the date. If no multiplier is given, the offset must be in milliseconds.
* @param {number} [multiplier] additional multiplier for the offset. Should be a positive Number. Special value -1 if offset is in month and -2 if offset is in years
* @param {number} [next] if greater than 0 the number of days in the future
* @param {string} [days] days for which should be calculated the sun time
* @return {timeresult|erroresult} result object of sunTime
*/
getSunTimeByName(now, value, offset, multiplier, next, days) {

@@ -243,6 +244,6 @@ let result;

/**
* gets previous and next sun time
* @param {Date} now current time
* @return {array} result object of sunTime
*/
* gets previous and next sun time
* @param {Date} now current time
* @return {array} result object of sunTime
*/
getSunTimePrevNext(now) {

@@ -351,16 +352,16 @@ let dayid = hlp.getDayId(now); // this._getUTCDayId(now);

/**
* @typedef {Object} moontime
* @property {Date|NaN} value - a Date object of the neesed date/time
*/
* @typedef {Object} moontime
* @property {Date|NaN} value - a Date object of the neesed date/time
*/
/**
* gets moon time
* @param {Date} now current time
* @param {string} value name of the moon time
* @param {number} [offset] the offset (positive or negative) which should be added to the date. If no multiplier is given, the offset must be in milliseconds.
* @param {number} [multiplier] additional multiplier for the offset. Should be a positive Number. Special value -1 if offset is in month and -2 if offset is in years
* @param {number} [next] if greater than 0 the number of days in the future
* @param {string} [days] days for which should be calculated the moon time
* @return {moontime|erroresult} result object of moon time
*/
* gets moon time
* @param {Date} now current time
* @param {string} value name of the moon time
* @param {number} [offset] the offset (positive or negative) which should be added to the date. If no multiplier is given, the offset must be in milliseconds.
* @param {number} [multiplier] additional multiplier for the offset. Should be a positive Number. Special value -1 if offset is in month and -2 if offset is in years
* @param {number} [next] if greater than 0 the number of days in the future
* @param {string} [days] days for which should be calculated the moon time
* @return {moontime|erroresult} result object of moon time
*/
getMoonTimeByName(now, value, offset, multiplier, next, days) {

@@ -420,6 +421,6 @@ const result = {};

/**
* Formate a Date Object to a Date and Time String
* @param {Date} dt Date to format to Date and Time string
* @returns {string} formated Date object
*/
* Formate a Date Object to a Date and Time String
* @param {Date} dt Date to format to Date and Time string
* @returns {string} formated Date object
*/
toDateTimeString(dt) {

@@ -430,6 +431,6 @@ return (this.toDateString(dt) + ' ' + this.toTimeString(dt)).trim();

/**
* Formate a Date Object to a Time String
* @param {Date} dt Date to format to trime string
* @returns {string} formated Date object
*/
* Formate a Date Object to a Time String
* @param {Date} dt Date to format to trime string
* @returns {string} formated Date object
*/
toTimeString(dt) {

@@ -443,6 +444,6 @@ if (!this.tzOffset && this.stateTimeFormat === '3') {

/**
* Formate a Date Object to a Date String
* @param {Date} dt Date to format to Date string
* @returns {string} formated Date object
*/
* Formate a Date Object to a Date String
* @param {Date} dt Date to format to Date string
* @returns {string} formated Date object
*/
toDateString(dt) {

@@ -456,11 +457,11 @@ if (!this.tzOffset && this.stateDateFormat === '12') {

/**
* get a float value from a type input in Node-Red
* @param {*} _srcNode - source node information
* @param {*} msg - message object
* @param {string} type - type name of the type input
* @param {*} value - value of the type input
* @param {*} [def] - default value if can not get float value
* @param {*} [opCallback] - callback function for getting getPropValue
* @returns {number} float property
*/
* get a float value from a type input in Node-Red
* @param {*} _srcNode - source node information
* @param {*} msg - message object
* @param {string} type - type name of the type input
* @param {*} value - value of the type input
* @param {*} [def] - default value if can not get float value
* @param {*} [opCallback] - callback function for getting getPropValue
* @returns {number} float property
*/
getFloatProp(_srcNode, msg, type, value, def, opCallback, noError) {

@@ -494,21 +495,21 @@ // _srcNode.debug('getFloatProp type='+type+' value='+value);

/**
* @typedef {Object} outPropType
* @property {string} type - type name of the type input
* @property {string} value - value of the type input
* @property {string|number} format - format of the input
* @property {string} [offset] - value of the offset type input
* @property {string} [offsetType] - type name of the offset type input
* @property {number} [multiplier] - multiplier to the time
* @property {boolean} [next] - if __true__ the next date will be delivered starting from now, otherwise the matching date of the date from now
* @property {string} [days] - valid days
* @property {Date} [now] - base date, current time as default
*/
* @typedef {Object} outPropType
* @property {string} type - type name of the type input
* @property {string} value - value of the type input
* @property {string|number} format - format of the input
* @property {string} [offset] - value of the offset type input
* @property {string} [offsetType] - type name of the offset type input
* @property {number} [multiplier] - multiplier to the time
* @property {boolean} [next] - if __true__ the next date will be delivered starting from now, otherwise the matching date of the date from now
* @property {string} [days] - valid days
* @property {Date} [now] - base date, current time as default
*/
/**
* get the time Data prepared for output
* @param {*} _srcNode - source node for logging
* @param {*} [msg] - the message object
* @param {outPropType} data - a Data object
* @returns {*} output Data
*/
* get the time Data prepared for output
* @param {*} _srcNode - source node for logging
* @param {*} [msg] - the message object
* @param {outPropType} data - a Data object
* @returns {*} output Data
*/
getOutDataProp(_srcNode, msg, data) {

@@ -576,28 +577,28 @@ // _srcNode.debug(`getOutDataProp IN data=${util.inspect(data, { colors: true, compact: 10, breakLength: Infinity }) } tzOffset=${this.tzOffset}`);

/**
* @typedef {Object} timePropType
* @property {string} type - type name of the type input
* @property {string} value - value of the type input
* @property {string|number} [format] - format of the input
* @property {string} [offset] - value of the offset type input
* @property {string} [offsetType] - type name of the offset type input
* @property {number} [multiplier] - multiplier to the time
* @property {boolean} [next] - if __true__ the next date will be delivered starting from now, otherwise the matching date of the date from now
* @property {string} [days] - valid days
* @property {Date} [now] - base date, current time as default
*/
* @typedef {Object} timePropType
* @property {string} type - type name of the type input
* @property {string} value - value of the type input
* @property {string|number} [format] - format of the input
* @property {string} [offset] - value of the offset type input
* @property {string} [offsetType] - type name of the offset type input
* @property {number} [multiplier] - multiplier to the time
* @property {boolean} [next] - if __true__ the next date will be delivered starting from now, otherwise the matching date of the date from now
* @property {string} [days] - valid days
* @property {Date} [now] - base date, current time as default
*/
/**
* @typedef {Object} timePropResultType
* @property {Date} value - the Date value
* @property {string} error - error message if an error has occured
* @property {boolean} fix - indicator if the given time value is a fix date
*/
* @typedef {Object} timePropResultType
* @property {Date} value - the Date value
* @property {string} error - error message if an error has occured
* @property {boolean} fix - indicator if the given time value is a fix date
*/
/**
* get the time Data from a typed input
* @param {*} _srcNode - source node for logging
* @param {*} [msg] - the message object
* @param {timePropType} data - a Data object
* @returns {timePropResultType} value of the type input
*/
* get the time Data from a typed input
* @param {*} _srcNode - source node for logging
* @param {*} [msg] - the message object
* @param {timePropType} data - a Data object
* @returns {timePropResultType} value of the type input
*/
getTimeProp(_srcNode, msg, data) {

@@ -722,15 +723,15 @@ // _srcNode.debug(`getTimeProp data=${util.inspect(data, { colors: true, compact: 10, breakLength: Infinity })} tzOffset=${this.tzOffset}`);

/**
* @typedef {Object} propValueType
* @property {string} type - type name of the type input
* @property {string} value - value of the type input
* @property {function} [callback] - function which should be called after value was recived
*/
* @typedef {Object} propValueType
* @property {string} type - type name of the type input
* @property {string} value - value of the type input
* @property {function} [callback] - function which should be called after value was recived
*/
/**
* get a property value from a type input in Node-Red
* @param {*} _srcNode - source node information
* @param {*} msg - message object
* @param {propValueType} data - data object with more information
* @returns {*} value of the type input, return of the callback function if defined or __null__ if value could not resolved
*/
* get a property value from a type input in Node-Red
* @param {*} _srcNode - source node information
* @param {*} msg - message object
* @param {propValueType} data - data object with more information
* @returns {*} value of the type input, return of the callback function if defined or __null__ if value could not resolved
*/
getPropValue(_srcNode, msg, data) {

@@ -1234,2 +1235,3 @@ _srcNode.debug(`getPropValue ${data.type}.${data.value} (${data.addID}) - data= ${util.inspect(data, { colors: true, compact: 10, breakLength: Infinity })}`);

});
};
};
// })();

@@ -948,3 +948,3 @@ /************************************************************************/

function getBackendData(result, data) { // eslint-disable-line no-unused-vars
console.log('[IN getBackendData] ',data); // eslint-disable-line
// console.log('[IN getBackendData] ',data); // eslint-disable-line
let res = '';

@@ -1011,2 +1011,15 @@ if (!data || data.type === 'none' || data.type === '' || data.type === 'jsonata' || data.type === 'json' || data.type === 'bin') {

return ((add) ? add : '');
}
/**
* get the value for the day checkbox array
* @param {jQuery} value - the checkbox array
* @returns {string} the value of the checkboxes
*/
function getDaysStr(value) { // eslint-disable-line no-unused-vars
const days = value.map((_, el) => { return $(el).val(); }).get();
if (days.length === 0) { return ''; }
if (days.length === 7) { return '*'; }
return days.join(',');
}
{
"name": "node-red-contrib-sun-position",
"version": "1.0.0-alpha-5",
"version": "1.0.0-alpha-6",
"description": "NodeRED nodes to get sun and moon position",

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

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