Skip to content

Commit

Permalink
Merge pull request #370 from rdmtc/dev
Browse files Browse the repository at this point in the history
2.0.6: bug fixes
  • Loading branch information
Hypnos3 authored Nov 27, 2021
2 parents 23285eb + d940f7e commit a50a6f5
Show file tree
Hide file tree
Showing 16 changed files with 161 additions and 73 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ Install of a specific Version in Redmatic (on a Homematic):

This can be also used to go back to an older Version.

### 2.0.6: bug fixes

- time-inject fix for next property #364

- within-time-switch fix error with output value #363

- blind-control + clock-time
- reduced default startup delay to may 1s
- do output to first output on startup #369

- blind-control
- implemented `setSunDataFloorLength` #367
- for an oversteer rule can now be configured if it should be active if the sun is in the window (default as previous) #362

### 2.0.5: bug fixes

- clock-time
Expand Down
32 changes: 25 additions & 7 deletions nodes/blind-control.html
Original file line number Diff line number Diff line change
Expand Up @@ -1654,6 +1654,7 @@
thresholdType : 'num', // threshold type
threshold : '', // threshold
mode : 0,
onlySunInWindow : true,
blindPos : {
type : 'levelFixed',
value : 'open (max)'
Expand All @@ -1664,12 +1665,16 @@
}
};
}
if (!Object.prototype.hasOwnProperty.call(data, 'onlySunInWindow')) {
data.onlySunInWindow = true;
}

containerRow.css({overflow: 'hidden', whiteSpace: 'nowrap'});
const $row1 = $('<div/>').appendTo(containerRow);
const $row2 = $('<div/>', {style: 'padding-top: 5px;'}).appendTo(containerRow);
const $row3 = $('<div/>', {style: 'padding-top: 5px;'}).appendTo(containerRow);
const $row4 = $('<div/>', {style: 'padding-top: 5px;'}).appendTo(containerRow);
const $row5 = $('<div/>', {style: 'padding-top: 5px;'}).appendTo(containerRow);
// row1 - index + oversteerValue + Compare
$('<input/>',{
type: 'hidden',
Expand Down Expand Up @@ -1724,7 +1729,7 @@
class: 'node-input-oversteer-threshold',
type: 'text'
})
.css('width', 'calc(100% - 160px)')
.css('width', 'calc(100% - 162px)')
.appendTo($row2)
.typedInput({
default: 'num',
Expand Down Expand Up @@ -1761,7 +1766,7 @@
class: 'node-input-oversteer-blindPos',
type: 'text'
})
.css('width', 'calc(100% - 145px)')
.css('width', 'calc(100% - 147px)')
.appendTo($row3)
.typedInput({
default: types.LevelFix,
Expand All @@ -1774,7 +1779,7 @@
class: 'node-input-oversteer-slatPos',
type: 'text'
})
.css('width', 'calc(100% - 145px)')
.css('width', 'calc(100% - 147px)')
.appendTo($row4)
.typedInput({
default: 'num',
Expand All @@ -1798,6 +1803,18 @@
});
setTInputValue($oversteerSlatPos, data.slatPos.value, data.slatPos.type);

// row5 - SunInWindow
addLabel($row5, 'node-input-oversteer-sunInWindow', 'fa fa-window-maximize', node._('blind-control.label.oversteerSunInWindow'));
const $oversteerOnlySunInWindow = $('<input/>', {
class: 'node-input-oversteer-sunInWindow',
type: 'checkbox'
})
.css('width', 'auto')
.css('margin-left', '10px')
.css('margin-top', '0')
.appendTo($row5);
$oversteerOnlySunInWindow.prop('checked', data.onlySunInWindow);

// changes
$oversteerValue.change(() => {
$oversteerThreshold.change();
Expand Down Expand Up @@ -3540,6 +3557,7 @@
operatorText : $rule.find('.node-input-oversteer-compare option:selected').text(),
thresholdType : $rule.find('.node-input-oversteer-threshold').typedInput('type'),
threshold : $rule.find('.node-input-oversteer-threshold').typedInput('value'),
onlySunInWindow : $rule.find('.node-input-oversteer-sunInWindow').is(':checked'),
blindPos : {
type : $rule.find('.node-input-oversteer-blindPos').typedInput('type'),
value : $rule.find('.node-input-oversteer-blindPos').typedInput('value')
Expand Down Expand Up @@ -3678,8 +3696,8 @@
<button type="button" id="node-button-add" class="rdg-ui-btn red-ui-button red-ui-button-small" data-i18n="[title]blind-control.placeholder.btnAdd" style="margin-top: 4px;"><i class="fa fa-plus"></i> <span data-i18n="node-red-contrib-sun-position/position-config:ruleCtrl.label.btnAdd"></span></button> &nbsp;
<button type="button" id="node-button-clear" class="rdg-ui-btn red-ui-button red-ui-button-small" data-i18n="[title]blind-control.placeholder.btnClear" style="margin-top: 4px;"><i class="fa fa-eraser"></i> <span data-i18n="node-red-contrib-sun-position/position-config:ruleCtrl.label.btnClear"></span></button> &nbsp;
<button type="button" id="node-button-sort" class="rdg-ui-btn red-ui-button red-ui-button-small" data-i18n="[title]blind-control.placeholder.btnSort" style="margin-top: 4px;"><i class="fa fa-sort-amount-asc"></i> <span data-i18n="node-red-contrib-sun-position/position-config:ruleCtrl.label.btnSort"></span></button>
<button type="button" id="node-button-export" class="rdg-ui-btn red-ui-button red-ui-button-small" data-i18n="[title]blind-control.placeholder.btnExport" style="margin-top: 4px;"><i class="fa fa-download"></i> <span data-i18n="node-red-contrib-sun-position/position-config:ruleCtrl.label.btnExport"></span></button>
<button type="button" id="node-button-import" class="rdg-ui-btn red-ui-button red-ui-button-small" data-i18n="[title]blind-control.placeholder.btnImport" style="margin-top: 4px;"><i class="fa fa-upload"></i> <span data-i18n="node-red-contrib-sun-position/position-config:ruleCtrl.label.btnImport"></span></button>
<button type="button" id="node-button-export" class="rdg-ui-btn red-ui-button red-ui-button-small" data-i18n="[title]blind-control.placeholder.btnExport" style="margin-top: 4px;"><i class="fa fa-files-o"></i> <span data-i18n="node-red-contrib-sun-position/position-config:ruleCtrl.label.btnExport"></span></button>
<button type="button" id="node-button-import" class="rdg-ui-btn red-ui-button red-ui-button-small" data-i18n="[title]blind-control.placeholder.btnImport" style="margin-top: 4px;"><i class="fa fa-clipboard"></i> <span data-i18n="node-red-contrib-sun-position/position-config:ruleCtrl.label.btnImport"></span></button>
</div>
</div>
</div>
Expand Down Expand Up @@ -3788,8 +3806,8 @@
<ol id="node-input-oversteer-container"></ol>
<button type="button" id="node-oversteer-button-add" class="rdg-ui-btn red-ui-button red-ui-button-small" data-i18n="[title]blind-control.placeholder.btnAdd" style="margin-top: 4px;"><i class="fa fa-plus"></i> <span data-i18n="node-red-contrib-sun-position/position-config:ruleCtrl.label.btnAdd"></span></button> &nbsp;
<button type="button" id="node-oversteer-button-clear" class="rdg-ui-btn red-ui-button red-ui-button-small" data-i18n="[title]blind-control.placeholder.btnClear" style="margin-top: 4px;"><i class="fa fa-eraser"></i> <span data-i18n="node-red-contrib-sun-position/position-config:ruleCtrl.label.btnClear"></span></button> &nbsp;
<button type="button" id="node-oversteer-button-export" class="rdg-ui-btn red-ui-button red-ui-button-small" data-i18n="[title]blind-control.placeholder.btnExport" style="margin-top: 4px;"><i class="fa fa-download"></i> <span data-i18n="node-red-contrib-sun-position/position-config:ruleCtrl.label.btnExport"></span></button>
<button type="button" id="node-oversteer-button-import" class="rdg-ui-btn red-ui-button red-ui-button-small" data-i18n="[title]blind-control.placeholder.btnImport" style="margin-top: 4px;"><i class="fa fa-upload"></i> <span data-i18n="node-red-contrib-sun-position/position-config:ruleCtrl.label.btnImport"></span></button>
<button type="button" id="node-oversteer-button-export" class="rdg-ui-btn red-ui-button red-ui-button-small" data-i18n="[title]blind-control.placeholder.btnExport" style="margin-top: 4px;"><i class="fa fa-files-o"></i> <span data-i18n="node-red-contrib-sun-position/position-config:ruleCtrl.label.btnExport"></span></button>
<button type="button" id="node-oversteer-button-import" class="rdg-ui-btn red-ui-button red-ui-button-small" data-i18n="[title]blind-control.placeholder.btnImport" style="margin-top: 4px;"><i class="fa fa-clipboard"></i> <span data-i18n="node-red-contrib-sun-position/position-config:ruleCtrl.label.btnImport"></span></button>
</div>
<div class="form-row row-oversteerTopic block-noindent" data-i18n="[title]blind-control.placeholder.oversteerTopic">
<label for="node-input-oversteerTopic"><i class="fa fa-tasks"></i> <span data-i18n="blind-control.label.oversteerTopic"></span></label>
Expand Down
95 changes: 58 additions & 37 deletions nodes/blind-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,27 +105,28 @@ module.exports = function (RED) {
* @param {Object} tempData the temporary data holder object
* @param {ITimeObject} oNow the now Object
*/
function checkOversteer(node, msg, tempData, oNow) {
function checkOversteer(node, msg, tempData, sunPosition, oNow) {
// node.debug(`checkOversteer ${util.inspect(node.oversteers, { colors: true, compact: 10, breakLength: Infinity })}`);
try {
node.oversteer.isChecked = true;
return node.oversteers.find(el => ((el.mode === 0 || el.mode === node.sunData.mode) && node.positionConfig.comparePropValue(node, msg,
{
value: el.value,
type: el.valueType,
expr: el.valueExpr,
callback: (result, _obj) => {
return ctrlLib.evalTempData(node, _obj.type, _obj.value, result, tempData);
}
},
el.operator,
{
value: el.threshold,
type: el.thresholdType,
callback: (result, _obj) => {
return ctrlLib.evalTempData(node, _obj.type, _obj.value, result, tempData);
}
}, false, oNow.dNow)));
return node.oversteers.find(el => ((el.mode === 0 || el.mode === node.sunData.mode) && (!el.onlySunInWindow || sunPosition.InWindow) &&
node.positionConfig.comparePropValue(node, msg,
{
value: el.value,
type: el.valueType,
expr: el.valueExpr,
callback: (result, _obj) => {
return ctrlLib.evalTempData(node, _obj.type, _obj.value, result, tempData);
}
},
el.operator,
{
value: el.threshold,
type: el.thresholdType,
callback: (result, _obj) => {
return ctrlLib.evalTempData(node, _obj.type, _obj.value, result, tempData);
}
}, false, oNow.dNow)));
} catch (err) {
node.error(RED._('blind-control.errors.getOversteerData', err));
node.log(util.inspect(err, Object.getOwnPropertyNames(err)));
Expand Down Expand Up @@ -336,6 +337,24 @@ module.exports = function (RED) {
}
}

if (node.oversteer.active) {
const res = checkOversteer(node, msg, tempData, sunPosition, oNow);
if (res) {
node.level.current = getBlindPosFromTI(node, undefined, res.blindPos.type, res.blindPos.value, node.nodeData.levelTop);
node.level.currentInverse = getInversePos_(node, node.level.current);
node.level.slat = node.positionConfig.getPropValue(node, msg, res.slatPos, false, oNow.dNow);
node.level.topic = node.oversteer.topic;
node.previousData.last.sunLevel = node.level.current;
node.reason.code = 10;
node.reason.state = RED._('node-red-contrib-sun-position/position-config:ruleCtrl.states.oversteer', { pos: res.pos+1 });
node.reason.description = RED._('node-red-contrib-sun-position/position-config:ruleCtrl.reasons.oversteer', { pos: res.pos+1 });
sunPosition.oversteer = res;
sunPosition.oversteerAll = node.oversteers;
return sunPosition;
}
sunPosition.oversteerAll = node.oversteers;
}

// const summerMode = 2;
if (!sunPosition.InWindow) {
if (node.sunData.mode === cWinterMode) {
Expand Down Expand Up @@ -364,24 +383,6 @@ module.exports = function (RED) {
return sunPosition;
}

if (node.oversteer.active) {
const res = checkOversteer(node, msg, tempData, oNow);
if (res) {
node.level.current = getBlindPosFromTI(node, undefined, res.blindPos.type, res.blindPos.value, node.nodeData.levelTop);
node.level.currentInverse = getInversePos_(node, node.level.current);
node.level.slat = node.positionConfig.getPropValue(node, msg, res.slatPos, false, oNow.dNow);
node.level.topic = node.oversteer.topic;
node.previousData.last.sunLevel = node.level.current;
node.reason.code = 10;
node.reason.state = RED._('node-red-contrib-sun-position/position-config:ruleCtrl.states.oversteer', { pos: res.pos+1 });
node.reason.description = RED._('node-red-contrib-sun-position/position-config:ruleCtrl.reasons.oversteer', { pos: res.pos+1 });
sunPosition.oversteer = res;
sunPosition.oversteerAll = node.oversteers;
return sunPosition;
}
sunPosition.oversteerAll = node.oversteers;
}

if (node.sunData.mode === cWinterMode) {
node.level.current = node.nodeData.levelMax;
node.level.currentInverse = getInversePos_(node, node.level.current);
Expand Down Expand Up @@ -888,6 +889,7 @@ module.exports = function (RED) {
thresholdType : 'num',
threshold : config.sunMinAltitude,
mode : 2,
onlySunInWindow : true,
blindPos : {
type : config.blindPosDefaultType,
value : config.blindPosDefault
Expand All @@ -907,6 +909,7 @@ module.exports = function (RED) {
threshold : config.oversteerThreshold,
thresholdType : config.oversteerThresholdType,
mode : 0,
onlySunInWindow : true,
blindPos : {
type : config.oversteerBlindPosType,
value : config.oversteerBlindPos
Expand All @@ -924,6 +927,7 @@ module.exports = function (RED) {
threshold : config.oversteer2Threshold,
thresholdType : config.oversteer2ThresholdType,
mode : 0,
onlySunInWindow : true,
blindPos : {
type : config.oversteer2BlindPosType,
value : config.oversteer2BlindPos
Expand All @@ -941,6 +945,7 @@ module.exports = function (RED) {
threshold : config.oversteer3Threshold,
thresholdType : config.oversteer3ThresholdType,
mode : 0,
onlySunInWindow : true,
blindPos : {
type : config.oversteer3BlindPosType,
value : config.oversteer3BlindPos
Expand Down Expand Up @@ -979,6 +984,9 @@ module.exports = function (RED) {
node.oversteers = config.oversteers;
node.oversteers.forEach( (val, _index) => {
val.pos = _index;
if (!Object.prototype.hasOwnProperty.call(val, 'onlySunInWindow')) {
val.onlySunInWindow = true;
}
if (node.positionConfig && val.valueType === 'jsonata') {
try {
val.valueExpr = node.positionConfig.getJSONataExpression(node, val.value);
Expand Down Expand Up @@ -1108,6 +1116,14 @@ module.exports = function (RED) {
case 'setSunDataTopic':
node.sunData.topic = msg.payload || node.sunData.topic;
break;
case 'setSunDataFloorLength': {
const val = getFloatValue(node.sunData.floorLength);
if (val !== node.sunData.floorLength) {
node.sunData.floorLengthType = 'num';
node.sunData.floorLength = val;
}
break;
}
/* minimum changes Settings */
case 'setSunDataMinDelta':
node.sunData.minDelta = parseFloat(msg.payload) || node.sunData.minDelta; // payload of 0 makes no sense, use then default
Expand Down Expand Up @@ -1310,7 +1326,8 @@ module.exports = function (RED) {
if (topic) {
topic = hlp.topicReplace(topic, replaceAttrs);
}
if ((!isNaN(node.level.current)) &&
if ((!node.startDelayTimeOut) &&
(!isNaN(node.level.current)) &&
((node.level.current !== node.previousData.level) ||
(!isEqual(node.level.slat, node.previousData.slat)) ||
(node.level.topic !== node.previousData.topic))) {
Expand Down Expand Up @@ -1384,6 +1401,10 @@ module.exports = function (RED) {
clearTimeout(node.autoTriggerObj);
delete node.autoTriggerObj;
}
if (node.startDelayTimeOutObj) {
clearTimeout(node.startDelayTimeOutObj);
delete node.startDelayTimeOutObj;
}
// tidy up any state
});
// ####################################################################################################
Expand Down
Loading

0 comments on commit a50a6f5

Please sign in to comment.