Skip to content

Commit

Permalink
1.0.14: BugFix
Browse files Browse the repository at this point in the history
- blind-control + clock-time
  - fixed bug for day of the week (String/integer format)
  • Loading branch information
Hypnos3 committed Mar 10, 2020
1 parent 508e91f commit af81097
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# node-red-contrib-sun-position

#### 1.0.14: BugFix

- blind-control + clock-time
- fixed bug for day of the week (String/integer format)

#### 1.0.13: BugFix

- time-inject
Expand Down
2 changes: 2 additions & 0 deletions nodes/blind-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -1444,12 +1444,14 @@ module.exports = function (RED) {
rule.timeDays = null;
} else {
rule.timeDays = rule.timeDays.split(',');
rule.timeDays = rule.timeDays.map( e => parseInt(e) );
}

if (!rule.timeMonths || rule.timeMonths === '*') {
rule.timeMonths = null;
} else {
rule.timeMonths = rule.timeMonths.split(',');
rule.timeMonths = rule.timeMonths.map( e => parseInt(e) );
}

if (!rule.timeLimited) {
Expand Down
4 changes: 3 additions & 1 deletion nodes/clock-timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ module.exports = function (RED) {
const monthNr = dNow.getMonth();
const dayId = hlp.getDayId(dNow);
prepareRules(node, msg, tempData);
// node.debug(`checkRules now=${dNow.toISOString()}, nowNr=${nowNr}, rules.count=${node.rules.count}, rules.lastUntil=${node.rules.lastUntil}`); // {colors:true, compact:10}
// node.debug(`checkRules now=${dNow.toISOString()}, nowNr=${nowNr}, dayNr=${dayNr}, dateNr=${dateNr}, monthNr=${monthNr}, dayId=${dayId}, rules.count=${node.rules.count}, rules.lastUntil=${node.rules.lastUntil}`);

/**
* Timestamp compare function
Expand Down Expand Up @@ -911,12 +911,14 @@ module.exports = function (RED) {
rule.timeDays = null;
} else {
rule.timeDays = rule.timeDays.split(',');
rule.timeDays = rule.timeDays.map( e => parseInt(e) );
}

if (!rule.timeMonths || rule.timeMonths === '*') {
rule.timeMonths = null;
} else {
rule.timeMonths = rule.timeMonths.split(',');
rule.timeMonths = rule.timeMonths.map( e => parseInt(e) );
}

if (!rule.timeLimited) {
Expand Down
25 changes: 17 additions & 8 deletions nodes/within-time-switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,15 @@ module.exports = function (RED) {
warn: ''
};

if (config.timeDays && config.timeDays !== '*' && !config.timeDays.includes(dNow.getDay())) {
if (config.timeDays && !config.timeDays.includes(dNow.getDay())) {
node.debug('invalid Day config. today=' + dNow.getDay() + ' timeDays=' + util.inspect(config.timeDays, Object.getOwnPropertyNames(config.timeDays)));
result.warn = RED._('within-time-switch.errors.invalid-day');
return result;
}
if (config.timeMonths && config.timeMonths !== '*') {
const mn = config.timeMonths.split(',');
if (!mn.includes(dNow.getMonth())) {
node.debug('invalid Day config. today=' + dNow.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.includes(dNow.getDay())) {
node.debug('invalid Month config. today=' + dNow.getMonth() + ' timeMonths=' + util.inspect(config.timeMonths, Object.getOwnPropertyNames(config.timeMonths)));
result.warn = RED._('within-time-switch.errors.invalid-month');
return result;
}
if (config.timedatestart || config.timedateend) {
let dStart,dEnd;
Expand Down Expand Up @@ -329,10 +326,22 @@ module.exports = function (RED) {

if (config.timeDays === '') {
throw new Error('No valid days given! Please check settings!');
} else if (!config.timeDays || config.timeDays === '*') {
config.timeDays = null;
} else {
config.timeDays = config.timeDays.split(',');
config.timeDays = config.timeDays.map( e => parseInt(e) );
}

if (config.timeMonths === '') {
throw new Error('No valid month given! Please check settings!');
} else if (!config.timeMonths || config.timeMonths === '*') {
config.timeMonths = null;
} else {
config.timeMonths = config.timeMonths.split(',');
config.timeMonths = config.timeMonths.map( e => parseInt(e) );
}

if (this.timeOnlyEvenDays && this.timeOnlyOddDays) {
this.timeOnlyEvenDays = false;
this.timeOnlyOddDays = false;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-sun-position",
"version": "1.0.13",
"version": "1.0.14",
"description": "NodeRED nodes to get sun and moon position",
"keywords": [
"node-red",
Expand Down

0 comments on commit af81097

Please sign in to comment.