Skip to content

Commit

Permalink
Merge pull request #361 from rdmtc/dev
Browse files Browse the repository at this point in the history
2.0.5: small fix
  • Loading branch information
Hypnos3 authored Nov 13, 2021
2 parents 1b38b0b + 0775114 commit 23285eb
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 37 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.5: bug fixes

- clock-time
- fix of check if payload and topic has changed to prevent send output on not changed payload/topic to output 1 #360
- fix of not changeable context store #358

- blind-control
- fix of not changeable context store #358
- fix of not working '0' value for `setBlindSettingsTop`, `setBlindSettingsBottom`, `setBlindSettingsIncrement` and `setBlindSettingsLevel` config overwrite possibility #359

### 2.0.4: flow library fix

- no changes, republished 2.0.3 because of node-red flow library missing data

### 2.0.3: small fix + enhancement

- general
Expand Down
4 changes: 2 additions & 2 deletions nodes/blind-control.html
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@
const $nodeConfig = $('#node-input-positionConfig');
const node = this;

const $nodeInputContextStore = $('#node-config-input-contextStore');
const $nodeInputContextStore = $('#node-input-contextStore');
RED.settings.context.stores.forEach(store => {
$nodeInputContextStore.append('<option value="' + store + '"' + (this.contextStore === store ? ' selected' : '') + '>' + store + '</option>');
});
Expand Down Expand Up @@ -3837,7 +3837,7 @@
</div>
<div class="form-row">
<label for="node-input-contextStore"><i class="icon-tag"></i> Context Store</label>
<select id="node-config-input-contextStore">
<select id="node-input-contextStore">
<option value="">none</option>
</select>
</div>
Expand Down
21 changes: 14 additions & 7 deletions nodes/blind-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -1079,20 +1079,27 @@ module.exports = function (RED) {
}

if (msg.topic && (typeof msg.topic === 'string') && msg.topic.startsWith('set')) {
const getFloatValue = def => {
const val = parseFloat(msg.payload);
if (isNaN(val)) {
return def;
}
return val;
};
switch (msg.topic) {
/* Blind Settings */
case 'setBlindSettingsTop':
node.nodeData.levelTop = parseFloat(msg.payload) || node.nodeData.levelTop;
node.nodeData.levelTop = getFloatValue(node.nodeData.levelTop);
break;
case 'setBlindSettingsBottom':
node.nodeData.levelBottom = parseFloat(msg.payload) || node.nodeData.levelBottom;
node.nodeData.levelBottom = getFloatValue(node.nodeData.levelBottom);
break;
case 'setBlindSettingsIncrement':
node.nodeData.increment = parseFloat(msg.payload) || node.nodeData.increment;
node.nodeData.increment = getFloatValue(node.nodeData.increment);
break;
/* Default Settings */
case 'setBlindSettingsLevel':
node.nodeData.levelDefault = parseFloat(msg.payload) || node.nodeData.levelDefault;
node.nodeData.levelDefault = getFloatValue(node.nodeData.levelDefault);
break;
case 'setSettingsTopic':
node.nodeData.topic = msg.payload || node.nodeData.topic;
Expand All @@ -1103,14 +1110,14 @@ module.exports = function (RED) {
break;
/* minimum changes Settings */
case 'setSunDataMinDelta':
node.sunData.minDelta = parseFloat(msg.payload) || node.sunData.minDelta;
node.sunData.minDelta = parseFloat(msg.payload) || node.sunData.minDelta; // payload of 0 makes no sense, use then default
break;
case 'setSmoothTime':
node.smoothTime = parseFloat(msg.payload) || node.smoothTime;
node.smoothTime = parseFloat(msg.payload) || node.smoothTime; // payload of 0 makes no sense, use then default
break;
/* advanced Settings */
case 'setAutoTriggerTime':
node.autoTrigger.defaultTime = parseInt(msg.payload) || node.autoTrigger.defaultTime;
node.autoTrigger.defaultTime = parseInt(msg.payload) || node.autoTrigger.defaultTime; // payload of 0 makes no sense, use then default
break;
case 'setContextStore':
node.contextStore = msg.payload || node.contextStore;
Expand Down
4 changes: 2 additions & 2 deletions nodes/clock-timer.html
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
const $nodeConfig = $('#node-input-positionConfig');
const node = this;

const $nodeInputContextStore = $('#node-config-input-contextStore');
const $nodeInputContextStore = $('#node-input-contextStore');
RED.settings.context.stores.forEach(store => {
$nodeInputContextStore.append('<option value="' + store + '"' + (this.contextStore === store ? ' selected' : '') + '>' + store + '</option>');
});
Expand Down Expand Up @@ -2786,7 +2786,7 @@
</div>
<div class="form-row">
<label for="node-input-contextStore"><i class="icon-tag"></i> Context Store</label>
<select id="node-config-input-contextStore">
<select id="node-input-contextStore">
<option value="">none</option>
</select>
</div>
Expand Down
49 changes: 26 additions & 23 deletions nodes/clock-timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = function (RED) {
* @param {ITimeObject} oNow the *current* date Object
* @returns {boolean} true if override is active, otherwise false
*/
function checkPosOverwrite(node, msg, oNow) {
function checkPosOverwrite(node, msg, oldValue, oNow) {
// node.debug(`checkPosOverwrite act=${node.nodeData.overwrite.active} `);
let isSignificant = false;
const exactImportance = hlp.getMsgBoolValue(msg, ['exactImportance', 'exactSignificance', 'exactPriority', 'exactPrivilege']);
Expand Down Expand Up @@ -80,11 +80,11 @@ module.exports = function (RED) {
const isv = hlp.getMsgBoolValue(msg, 'ignoreSameValue');
node.debug(`needOverwrite importance=${nImportance} expire=${nExpire} resetOnSameAsLastValue=${rosalv} ignoreSameValue=${isv}`);

if (rosalv && isEqual(node.previousData.payloadValue, overrideData)) {
if (rosalv && isEqual(oldValue, overrideData)) {
node.debug(`resetOnSameAsLastValue active, reset overwrite and exit overrideData=${overrideData}`);
ctrlLib.posOverwriteReset(node);
return ctrlLib.setOverwriteReason(node);
} else if (isv && isEqual(node.previousData.payloadValue, overrideData)) {
} else if (isv && isEqual(oldValue, overrideData)) {
node.debug(`overwrite exit true (ignoreSameValue), overrideData=${overrideData}`);
return ctrlLib.setOverwriteReason(node);
}
Expand Down Expand Up @@ -374,11 +374,6 @@ module.exports = function (RED) {
current: undefined,
topic: node.nodeData.topic
};
node.previousData = {
reasonCode: -1,
usedRule: NaN,
last : {}
};

/**
* set the state of the node
Expand Down Expand Up @@ -441,7 +436,7 @@ module.exports = function (RED) {
break;
/* advanced Settings */
case 'setAutoTriggerTime':
node.autoTrigger.defaultTime = parseInt(msg.payload) || node.autoTrigger.defaultTime;
node.autoTrigger.defaultTime = parseInt(msg.payload) || node.autoTrigger.defaultTime; // payload of 0 makes no sense, use then default
break;
case 'setCntextStore':
node.contextStore = msg.payload || node.contextStore;
Expand All @@ -466,10 +461,11 @@ module.exports = function (RED) {
// initialize
node.nowarn = {};
const tempData = node.context().get('cacheData',node.contextStore) || {};
node.previousData.reasonCode = node.reason.code;
node.previousData.reasonState = node.reason.state;
node.previousData.reasonDescription = node.reason.description;
node.previousData.payloadValue = clonedeep(node.payload.current);
const previousData = node.context().get('lastData', node.contextStore) || {
reasonCode: -1,
usedRule: NaN,
lastAuto : {}
};

node.reason.code = NaN;
const oNow = hlp.getNowObject(node, msg);
Expand All @@ -493,23 +489,23 @@ module.exports = function (RED) {
reason : node.reason,
timeClock : node.nodeData,
autoTrigger : node.autoTrigger,
lastEvaluated: node.previousData.last,
lastEvaluated: previousData.lastAuto,
name: node.name || node.id,
id: node.addId || node.id
};

let ruleId = -2;

// check for manual overwrite
let overwrite = checkPosOverwrite(node, msg, oNow);
let overwrite = checkPosOverwrite(node, msg, previousData.payload, oNow);
if (!overwrite || node.rules.canResetOverwrite || (node.rules.maxImportance > 0 && node.rules.maxImportance > node.nodeData.overwrite.importance)) {
// calc times:
timeCtrl.rule = checkRules(node, msg, oNow, tempData);
node.previousData.last.ruleId = timeCtrl.rule.id;
node.previousData.last.ruleTopic = timeCtrl.rule.topic;
previousData.lastAuto.ruleId = timeCtrl.rule.id;
previousData.lastAuto.ruleTopic = timeCtrl.rule.topic;

node.debug(`overwrite=${overwrite}, node.rules.maxImportance=${node.rules.maxImportance}, nodeData.overwrite.importance=${node.nodeData.overwrite.importance}`);
if (overwrite && timeCtrl.rule.resetOverwrite && timeCtrl.rule.id !== node.previousData.usedRule) {
if (overwrite && timeCtrl.rule.resetOverwrite && timeCtrl.rule.id !== previousData.usedRule) {
ctrlLib.posOverwriteReset(node);
overwrite = false;
}
Expand All @@ -523,8 +519,8 @@ module.exports = function (RED) {
node.reason.code = timeCtrl.rule.code;
node.reason.state = timeCtrl.rule.state;
node.reason.description = timeCtrl.rule.description;
node.previousData.last.payload = node.payload.current;
node.previousData.last.topic = node.payload.topic;
previousData.lastAuto.payload = clonedeep(node.payload.current);
previousData.lastAuto.topic = node.payload.topic;
}
}

Expand Down Expand Up @@ -552,8 +548,8 @@ module.exports = function (RED) {
if ((typeof node.payload.current !== 'undefined') &&
(node.payload.current !== 'none') &&
(node.payload.current !== null) &&
((node.payload.topic !== node.previousData.topic) ||
((typeof node.previousData.payloadValue !== 'undefined') && (!isEqual(node.previousData.payloadValue, node.payload.current)))) ) {
!(isEqual(node.payload.topic, previousData.topic) &&
isEqual(previousData.payload, node.payload.current))) {
const msgOut = {};
for (let i = 0; i < node.results.length; i++) {
const prop = node.results[i];
Expand Down Expand Up @@ -581,8 +577,15 @@ module.exports = function (RED) {
} else {
send([null, { topic, payload: timeCtrl }]);
}
node.previousData.usedRule = ruleId;

previousData.usedRule = ruleId;
previousData.payload = clonedeep(node.payload.current);
previousData.topic = node.payload.topic;
previousData.reasonCode = node.reason.code;
previousData.reasonState = node.reason.state;
previousData.reasonDescription = node.reason.description;
node.context().set('cacheData', tempData, node.contextStore);
node.context().set('lastData', previousData, node.contextStore);
if (node.autoTrigger) {
node.debug('next autoTrigger will set to ' + node.autoTrigger.time + ' - ' + node.autoTrigger.type);
if (node.autoTriggerObj) {
Expand Down
2 changes: 1 addition & 1 deletion nodes/position-config.html
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@
</div>

<div class="form-row">
<label for="node-input-contextStore"><i class="icon-tag"></i> Context Store</label>
<label for="node-config-input-contextStore"><i class="icon-tag"></i> Context Store</label>
<select id="node-config-input-contextStore">
<option value="">none</option>
</select>
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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": "2.0.3",
"version": "2.0.5",
"description": "NodeRED nodes to get sun and moon position",
"keywords": [
"node-red",
Expand Down

0 comments on commit 23285eb

Please sign in to comment.