Skip to content

Commit a457ac2

Browse files
authored
Merge pull request #107 from rdmtc/dev
fixes #106
2 parents 9ea4650 + 5f4552f commit a457ac2

14 files changed

+182
-62
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
#### 1.0.7: bug fix
44

5+
- time-inject
6+
- fixes that time inject will do a recalculation every 1 ms (Problem can only occurs if the time constraints are used.) #106
7+
8+
- blind-control + clock-time
9+
- documentation
10+
- i18n
11+
12+
#### 1.0.7: bug fix
13+
514
- general
615
- added additional caching of sun times calculation to reduce calculation load
716

blind_control.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Used to control a blind with many possibilities. This can be time-dependent and
2828
- [rules](#rules)
2929
- [rules execution in detail](#rules-execution-in-detail)
3030
- [rules example](#rules-example)
31+
- [time rules additional constraints](#time-rules-additional-constraints)
3132
- [Samples](#samples)
3233
- [Example 1](#example-1)
3334
- [Example 2](#example-2)
@@ -313,7 +314,7 @@ The shape indicates whether the blind is fully closed or not.
313314
## rules
314315

315316
The rules are not easy to understand.
316-
![rule-edit](https://user-images.githubusercontent.com/12692680/68091997-d985ad00-fe86-11e9-827c-967ecf4d6893.png)
317+
![rule-edit-0](https://user-images.githubusercontent.com/12692680/75113132-1f8b9a00-564b-11ea-9a04-9bc340763a08.png)
317318

318319
There are basically 4 generic types of rules:
319320

@@ -326,7 +327,7 @@ There are basically 4 generic types of rules:
326327
- a rule with a condition will only be active if the condition matches, otherwise the rule will be ignored
327328
- rules with only a condition are evaluated in the order of time __until__ and time __from__ rules
328329
- a rule with a given time - time rule
329-
![rule-type-3](https://user-images.githubusercontent.com/12692680/68092071-a1329e80-fe87-11e9-82ae-dbefb494cea1.png)
330+
![rule-type-3](https://user-images.githubusercontent.com/12692680/75113146-68435300-564b-11ea-8531-6623311851b8.png)
330331
- time rules differ again in 2 ways
331332
- __until__ time rules
332333
- rules will be active from Midnight __until__ the given time
@@ -336,7 +337,7 @@ There are basically 4 generic types of rules:
336337
- the last matching __from__ rule with a time earlier than the current time will be considered
337338
- __from__ rules only considered if no __until__ rule was selected
338339
- a rule with a condition and a given time
339-
![rule-type-4](https://user-images.githubusercontent.com/12692680/68092080-c6271180-fe87-11e9-9ec8-8287ac1eb771.png)
340+
![rule-type-4](https://user-images.githubusercontent.com/12692680/75113183-bc4e3780-564b-11ea-83d8-495e188e4b81.png)
340341
- these type of rules are a combination. The rules will only be considered if the condition matches and then it act as a normal time rule. Otherwise it will be ignored.
341342

342343
the blind level of a rule could have 5 options:
@@ -415,6 +416,30 @@ starting from a defined time the following rule will be used:
415416

416417
There is a time between the *until* and the *from* rules, where no rules matches. In this time the default defined blind position will be used or if sun control is active the blind position calculated by the sun will be used.
417418

419+
### time rules additional constraints
420+
421+
On a time rule additional constraints can be choose:
422+
![blind-control-rules-constraints](https://user-images.githubusercontent.com/12692680/75113198-f61f3e00-564b-11ea-835e-7550a9e765af.png)
423+
424+
A rule is only executed if there are no restrictions.
425+
426+
That means:
427+
428+
- if the current day of the week is one of the selected days of the week
429+
- if the current month is one of the selected months
430+
- if *only even* is selected and the current day is an even day
431+
- if *only odd* is selected and the current day is an odd day
432+
- if the current day is in the time period as selected
433+
- For the time period settings the year is ignored.
434+
- Normal: the start day and month is less than the end day and month
435+
- the rule is only executed if the current month+day is greater than or equal the selected period start **and** less than the selected end month and day.
436+
- Example: This can be used To setup a period starting from 17th of March to 7th of May.
437+
- over the year: the start day and month is greater than the end day and month
438+
- the rule is only executed if the current month+day is greater than or equal the selected period start **or** less than the selected end month and day.
439+
- Example: This can be used To setup a period starting from 12th of November to 20th of February.
440+
441+
All constraints are additive. Pleas careful to that, that means it is possible to setup a rule which never would be used.
442+
418443
## Samples
419444

420445
### Example 1

nodes/blind-control.html

Lines changed: 52 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@
616616
try {
617617
if (typeof data.valid === undefined) {
618618
result += '<div>The rule is out of date, but should work normally regardless. If possible, please open the rule, save and re-deploy the node. This updates the data structures.</div>';
619-
} else if (typeof data.valid !== undefined && (!data.valid || !data.isValid)) {
619+
} else if (!data.valid || !data.isValid) {
620620
result += '<div>Rule is invalid and needs to be changed!!</div>';
621621
}
622622
if (data.validOperandAType && data.validOperandAType !== 'none') {
@@ -1336,7 +1336,7 @@
13361336
title: node._('blind-control.label.dialogtitle'),
13371337
autoOpen: false,
13381338
resizable: true,
1339-
height: Math.min(1024, $(window).height() * 0.9),
1339+
height: Math.min(750, $(window).height() * 0.9), // 1024
13401340
width: Math.min(850, $(window).width() * 0.9),
13411341
modal: true,
13421342
closeOnEscape: true,
@@ -1490,6 +1490,16 @@
14901490
$dialogTimeMaxOffset.typedInput('width', '40%');
14911491
// #endregion dialogTimeMax
14921492
// #region dialogTimeLimit
1493+
$dialog.find('#dialog-row-timeConstraints-show').click(() => {
1494+
$dialog.find('#dialog-row-timeConstraintsPlaceholder').hide();
1495+
$dialog.find('#dialog-row-timeConstraints').fadeIn('slow');
1496+
});
1497+
1498+
$dialog.find('#dialog-row-timeConstraints-hide').click(() => {
1499+
$dialog.find('#dialog-row-timeConstraintsPlaceholder').fadeIn('slow');
1500+
$dialog.find('#dialog-row-timeConstraints').hide();
1501+
});
1502+
14931503
const $dialogTimeLimitOnlyEvenDays = $dialog.find('#dlg-ip-blindctl-rule-timeOnlyEvenDays');
14941504
const $dialogTimeLimitOnlyOddDays = $dialog.find('#dlg-ip-blindctl-rule-timeOnlyOddDays');
14951505
const $dialogTimeLimitDateStart = $dialog.find('#dlg-ip-blindctl-rule-timedatelimit-start');
@@ -1539,6 +1549,7 @@
15391549
$('#dialog-row-offset-timeMin').hide();
15401550
$('#dialog-row-offset-timeMax').hide();
15411551
$('.dialog-row-timeLimits').hide();
1552+
$('.dialog-row-timeLimits-ph').hide();
15421553
// $dialogTimeMinInput.typedInput('value','');
15431554
if ($dialogTimeMaxInput.typedInput('type') !== types.Undefined.value) {
15441555
$dialogTimeMaxInput.typedInput('type', types.Undefined.value);
@@ -1552,11 +1563,13 @@
15521563
} else if (opType === types.TimeSun.value || opType === types.TimeMoon.value) {
15531564
$dialogTimeRegOperator.show();
15541565
$('#dialog-row-offset-timeReg').show();
1555-
$('.dialog-row-timeLimits').show();
1566+
$('.dialog-row-timeLimits').hide();
1567+
$('.dialog-row-timeLimits-ph').show();
15561568
} else {
15571569
$dialogTimeRegOperator.show();
15581570
$('#dialog-row-offset-timeReg').hide();
1559-
$('.dialog-row-timeLimits').show();
1571+
$('.dialog-row-timeLimits').hide();
1572+
$('.dialog-row-timeLimits-ph').show();
15601573
}
15611574
getBackendData(d => {
15621575
// console.log('getBackendData of $dialogTimeRegInput ',d);
@@ -1578,15 +1591,15 @@
15781591
$dialogTimeRegInput.attr('timedata', dialogAddData.timeReg.ts);
15791592
_dialogGenHelpText();
15801593
}, {
1581-
nodeId: node.id,
1582-
kind: 'getTimeData',
1583-
config: $nodeConfig.val(),
1584-
type: opType,
1585-
value: $dialogTimeRegInput.typedInput('value'),
1586-
offsetType: $dialogTimeRegOffset.typedInput('type'),
1587-
offset: $dialogTimeRegOffset.typedInput('value'),
1588-
multiplier: parseInt($dialogTimeRegMultiplier.val()),
1589-
noOffsetError: true
1594+
nodeId: node.id,
1595+
kind: 'getTimeData',
1596+
config: $nodeConfig.val(),
1597+
type: opType,
1598+
value: $dialogTimeRegInput.typedInput('value'),
1599+
offsetType: $dialogTimeRegOffset.typedInput('type'),
1600+
offset: $dialogTimeRegOffset.typedInput('value'),
1601+
multiplier: parseInt($dialogTimeRegMultiplier.val()),
1602+
noOffsetError: true
15901603
});
15911604
$dialogTimeMinInput.change();
15921605
$dialogTimeMaxInput.change();
@@ -2342,7 +2355,7 @@
23422355
</div>
23432356
<div class="form-row block-noindent spinner-Small" data-i18n="[title]blind-control.placeholder.startDelay2">
23442357
<label for="node-input-startDelay"><i class="fa fa-hourglass-start"></i> <span data-i18n="blind-control.label.startDelay"></span></label>
2345-
<span id="blind-control-startDelayTime-edit" >
2358+
<span id="blind-control-startDelayTime-edit">
23462359
<input type="text" class="spinner-time" id="blind-control-startDelayTime" data-i18n="[placeholder]blind-control.placeholder.startDelay" value=""/>
23472360
<select id="blind-control-startDelayTime-multiplier" class="node-input-multiplier">
23482361
<option value="1" data-i18n="node-red-contrib-sun-position/position-config:common.multiplier.0"></option>
@@ -2437,8 +2450,16 @@
24372450
<select id="dlg-ip-blindctl-rule-multiplier-timeMax" class="ipadd dlg-ip-blindctl-rule-multiplier-timeMax" >
24382451
</select>
24392452
</div>
2440-
<div class="dialog-row dialog-row-timeLimits" id="dialog-row-timeDays" data-i18n="[title]blind-control.placeholder.ruleTimeDays">
2441-
<div id="dlg-ip-blindctl-rule-timeDays" class="dlg-ip-blindctl-rule-days">
2453+
<div class="dialog-row dialog-row-timeLimits-ph is-to-show-initially" id="dialog-row-timeConstraintsPlaceholder">
2454+
<div class="dlg-ip-blindctl-rule-timecontraintctrl" id="dialog-row-timeConstraints-show">
2455+
<button class="dialog-element-clickable" data-i18n="blind-control.label.timeconstraintshow"></button>
2456+
</div>
2457+
</div>
2458+
<div class="dialog-row dialog-row-timeLimits is-initial-hidden" id="dialog-row-timeConstraints">
2459+
<div class="dlg-ip-blindctl-rule-timecontraintctrl" id="dialog-row-timeConstraints-hide">
2460+
<button class="dialog-element-clickable" data-i18n="blind-control.label.timeconstrainthide"></button>
2461+
</div>
2462+
<div id="dlg-ip-blindctl-rule-timeDays" class="dlg-ip-blindctl-rule-days" data-i18n="[title]blind-control.placeholder.ruleTimeDays">
24422463
<div style="display:inline-block; vertical-align:top; margin-right:5px;" data-i18n="blind-control.label.validForDays"></div>
24432464
<div style="display:inline-block;">
24442465
<div>
@@ -2462,8 +2483,8 @@
24622483
</div>
24632484
</div>
24642485
<div id="dlg-ip-blindctl-rule-timeMonths" class="dlg-ip-blindctl-rule-months" style="margin-top:5px;border-top: 1px solid #000;">
2486+
<div style="display:inline-block; vertical-align:top; margin-right:5px;" data-i18n="blind-control.label.validForMonths"></div>
24652487
<div style="display:inline-block;">
2466-
<div style="display:inline-block; vertical-align:top; margin-right:5px;" data-i18n="blind-control.label.validForMonths"></div>
24672488
<div>
24682489
<label data-i18n="[title]node-red-contrib-sun-position/position-config:common.months.0"><input type='checkbox' checked value='0'/> <span data-i18n="node-red-contrib-sun-position/position-config:common.months.12"></span></label>
24692490
<label data-i18n="[title]node-red-contrib-sun-position/position-config:common.months.1"><input type='checkbox' checked value='1'/> <span data-i18n="node-red-contrib-sun-position/position-config:common.months.13"></span></label>
@@ -2569,12 +2590,12 @@
25692590
.block-indent2 .row-full-width {
25702591
width : calc(100% - 130px);
25712592
}
2572-
.block-noindent .ui-spinner {
2573-
width : calc(100% - 245px);
2574-
}
25752593
.spinner-Small .ui-spinner {
25762594
width : 100px !important;
25772595
}
2596+
.block-noindent .ui-spinner {
2597+
width : calc(100% - 245px);
2598+
}
25782599
.block-indent1 .ui-spinner {
25792600
width : calc(100% - 255px);
25802601
}
@@ -2666,6 +2687,17 @@
26662687
width: 45%;
26672688
margin-bottom: 0px !important;
26682689
}
2690+
.dialog-element-clickable {
2691+
user-select: none;
2692+
cursor: pointer;
2693+
touch-action: manipulation;
2694+
display: inline-block;
2695+
/* background: transparent; */
2696+
/* border: 0; */
2697+
vertical-align:top;
2698+
margin-right:5px;
2699+
}
2700+
.dlg-ip-blindctl-rule-timecontraintctrl,
26692701
.dlg-ip-blindctl-rule-days,
26702702
.dlg-ip-blindctl-rule-limits,
26712703
.dlg-ip-blindctl-rule-months,

nodes/blind-control.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,11 @@ module.exports = function (RED) {
991991
this.outputs = Number(config.outputs || 1);
992992
this.smoothTime = (parseFloat(config.smoothTime) || -1);
993993
this.startDelayTime = parseFloat(config.startDelayTime);
994-
if (isNaN(this.startDelayTime) || this.startDelayTime < 10) { delete this.startDelayTime; }
994+
if (isNaN(this.startDelayTime) || this.startDelayTime < 10) {
995+
delete this.startDelayTime;
996+
} else {
997+
this.startDelayTime = Math.min(this.startDelayTime, 2147483646);
998+
}
995999

9961000
if (config.autoTrigger) {
9971001
this.autoTrigger = {

0 commit comments

Comments
 (0)