Skip to content

Commit

Permalink
Releasing
Browse files Browse the repository at this point in the history
  • Loading branch information
SergiuToporjinschi committed Mar 13, 2019
1 parent 42e2193 commit 05e92e2
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 23 deletions.
68 changes: 65 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ A dashboard ui interface node for controlling a heater;
* 5 - current temperature from calendar
* 6 - next temperature from calendar and the starting hour
* 7 - warning that current temperature is missing so the controller is not active
* 8 - if is locked, will keep the target temperature until user intervention; If is unlocked, will keep the target temperature until next calendar change;

Once a custom value has been set will keep that value untill the user is resetting it by double clicking the tarvet value or by sliding it left or right, when the current calendar target value is taken from calendar.

Expand Down Expand Up @@ -55,7 +56,7 @@ The heater status is recalculated when this message received, or when the
user is changing the target temperature.

Message example:
```
```json
{
"topic" : "currentTemp",
"payload" : "22.5"
Expand All @@ -64,13 +65,70 @@ Message example:

To set the temperature target value other than through the UI (eg. Voice command), the optional topic "userTargetValue" can be used.

```
```json
{
"topic" : "userTargetValue",
"payload" : "20.0"
}
```

To set the calendar by imput message.
**<span style="color:red">ATTENTION</span>**<span style="color:red">: payload needs to be JSON Type</span>

```json
{
"topic" : "setCalendar",
"payload" : {
"Monday": {
"00:00": 99,
"06:20": 22,
"08:00": 19,
"16:40": 22,
"23:59": 19
},
"Tuesday": {
"00:00": 19,
"06:20": 22,
"08:00": 19,
"16:40": 22,
"23:59": 19
},
"Wednesday": {
"00:00": 19,
"06:20": 22,
"08:00": 19,
"16:40": 22,
"23:59": 19
},
"Thursday": {
"00:00": 19,
"06:20": 22,
"08:00": 19,
"16:40": 22,
"23:59": 19
},
"Friday": {
"00:00": 19,
"06:20": 23,
"08:00": 19,
"16:40": 22,
"23:59": 19
},
"Saturday": {
"00:00": 19,
"08:00": 20,
"20:00": 22,
"23:59": 19
},
"Sunday": {
"00:00": 19,
"08:00": 20,
"20:00": 22,
"23:59": 19
}
}
}
```
## Output

A message is emited when the status is recalculated (when the user is
Expand Down Expand Up @@ -113,6 +171,10 @@ For example:
True if current target temperature is set by the user
## Changelog

### v1.2.1 (March 13, 2019)
* Allowing negative values in hysteresis (ticket [Allow a minus figure in the upper hysteresis entry #18](https://github.com/SergiuToporjinschi/node-red-contrib-heater-controller/issues/18))
* Update documentation (ticket [Padlock function ? #17](https://github.com/SergiuToporjinschi/node-red-contrib-heater-controller/issues/17))
* Changeable Calendar by message (ticket [Changeable Calendar by message #16](https://github.com/SergiuToporjinschi/node-red-contrib-heater-controller/issues/16))
### v1.2.0 (December 28, 2018)
* Add German translation (thanks to [HanSolo72](https://github.com/HanSolo72))
* Chang user value using "userTargetValue" topic (thanks to [Alcantor](https://github.com/Alcantor))
Expand All @@ -138,5 +200,5 @@ For example:

## Testing schema
```
[{"id":"dd2014ed.0858b8","type":"inject","z":"d6abf2dd.559db","name":"","topic":"currentTemp","payload":"23.5","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":180,"wires":[["576ecd80.efbc04"]]},{"id":"576ecd80.efbc04","type":"ui_heater_controller","z":"d6abf2dd.559db","name":"heater","group":"b65552e.2f213b","unit":"C","order":0,"width":8,"height":3,"topic":"heaterMessage","sliderMinValue":10,"sliderMaxValue":35,"sliderStep":0.5,"thresholdRising":0.5,"thresholdFalling":0.5,"calendar":"{\n \"Monday\": {\n \"00:00\": 19,\n \"06:20\": 22,\n \"08:00\": 19,\n \"16:40\": 22,\n \"23:59\": 19\n },\n \"Tuesday\": {\n \"00:00\": 19,\n \"06:20\": 22,\n \"08:00\": 19,\n \"16:40\": 22,\n \"23:59\": 19\n },\n \"Wednesday\": {\n \"00:00\": 19,\n \"06:20\": 22,\n \"08:00\": 19,\n \"16:40\": 22,\n \"23:59\": 19\n },\n \"Thursday\": {\n \"00:00\": 19,\n \"06:20\": 22,\n \"08:00\": 19,\n \"16:40\": 22,\n \"23:59\": 19\n },\n \"Friday\": {\n \"00:00\": 19,\n \"06:20\": 23,\n \"08:00\": 19,\n \"16:40\": 22,\n \"23:59\": 19\n },\n \"Saturday\": {\n \"00:00\": 19,\n \"08:00\": 20,\n \"20:00\": 22,\n \"23:59\": 19\n },\n \"Sunday\": {\n \"00:00\": 19,\n \"08:00\": 20,\n \"20:00\": 22,\n \"23:59\": 19\n }\n}","x":290,"y":180,"wires":[["a7503252.5ecee"]]},{"id":"a7503252.5ecee","type":"debug","z":"d6abf2dd.559db","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":430,"y":180,"wires":[]},{"id":"b65552e.2f213b","type":"ui_group","z":"","name":"Group 1","tab":"1913485f.ed4198","order":1,"disp":true,"width":"8","collapse":false},{"id":"1913485f.ed4198","type":"ui_tab","name":"Tab 1","icon":"dashboard","order":1}]
[{"id":"1bd80269.b8fb3e","type":"inject","z":"8a6eba9e.37afb8","name":"setCalendar","topic":"setCalendar","payload":"{\"Monday\":{\"00:00\":29,\"06:20\":22,\"08:00\":19,\"16:40\":22,\"23:59\":19},\"Tuesday\":{\"00:00\":19,\"06:20\":22,\"08:00\":19,\"16:40\":22,\"23:59\":19},\"Wednesday\":{\"00:00\":19,\"06:20\":22,\"08:00\":19,\"16:40\":10,\"23:59\":10},\"Thursday\":{\"00:00\":10,\"06:20\":10,\"08:00\":10,\"16:40\":10,\"23:59\":10},\"Friday\":{\"00:00\":19,\"06:20\":23,\"08:00\":19,\"16:40\":22,\"23:59\":19},\"Saturday\":{\"00:00\":19,\"08:00\":20,\"20:00\":22,\"23:59\":19},\"Sunday\":{\"00:00\":19,\"08:00\":20,\"20:00\":22,\"23:59\":19}}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":260,"wires":[["a47a34f8.a58ec8"]]},{"id":"a47a34f8.a58ec8","type":"ui_heater_controller","z":"8a6eba9e.37afb8","name":"heater","group":"e7110dea.42a4f","unit":"C","order":0,"width":8,"height":3,"topic":"","sliderMinValue":11,"sliderMaxValue":30,"sliderStep":0.5,"thresholdRising":0.5,"thresholdFalling":0.5,"calendar":"{\n \"Monday\": {\n \"00:00\": 99,\n \"06:20\": 22,\n \"08:00\": 19,\n \"16:40\": 22,\n \"23:59\": 19\n },\n \"Tuesday\": {\n \"00:00\": 19,\n \"06:20\": 22,\n \"08:00\": 19,\n \"16:40\": 22,\n \"23:59\": 19\n },\n \"Wednesday\": {\n \"00:00\": 19,\n \"06:20\": 22,\n \"08:00\": 19,\n \"16:40\": 22,\n \"23:59\": 19\n },\n \"Thursday\": {\n \"00:00\": 19,\n \"06:20\": 22,\n \"08:00\": 19,\n \"16:40\": 22,\n \"23:59\": 19\n },\n \"Friday\": {\n \"00:00\": 19,\n \"06:20\": 23,\n \"08:00\": 19,\n \"16:40\": 22,\n \"23:59\": 19\n },\n \"Saturday\": {\n \"00:00\": 19,\n \"08:00\": 20,\n \"20:00\": 22,\n \"23:59\": 19\n },\n \"Sunday\": {\n \"00:00\": 19,\n \"08:00\": 20,\n \"20:00\": 22,\n \"23:59\": 19\n }\n}","x":390,"y":260,"wires":[["9c97d5a.ffc3d28"]]},{"id":"d4e58ace.1c50b8","type":"inject","z":"8a6eba9e.37afb8","name":"","topic":"currentTemp","payload":"23","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":220,"wires":[["a47a34f8.a58ec8"]]},{"id":"9c97d5a.ffc3d28","type":"debug","z":"8a6eba9e.37afb8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":530,"y":260,"wires":[]},{"id":"29a31b65.adcd74","type":"inject","z":"8a6eba9e.37afb8","name":"","topic":"userTargetValue","payload":"27","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":300,"wires":[["a47a34f8.a58ec8"]]},{"id":"e7110dea.42a4f","type":"ui_group","z":"","name":"Default","tab":"3d03ca82.b2eac6","disp":true,"width":"8","collapse":false},{"id":"3d03ca82.b2eac6","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
```
31 changes: 21 additions & 10 deletions backEndNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function backEndNode(node, config) {
throw 'heater_controller.error.no-group';
}
this.node = node;
this.allowedTopics = ['currentTemp', 'userTargetValue'];
this.allowedTopics = ['currentTemp', 'userTargetValue', 'setCalendar'];
this.config = config;
}
function override(target, source) {
Expand Down Expand Up @@ -105,23 +105,34 @@ backEndNode.prototype.beforeEmit = function (msg, value) {
return { msg: existingValues }; //return what I already have
}
//in case we need more topics we have to see if we should convert value
value = parseFloat(value);
var returnValues = override(existingValues, { [msg.topic]: value });
context.set("values", returnValues);
var returnValues = existingValues;
switch (msg.topic) {
case 'setCalendar':
this.config.calendar = value;
returnValues = override(existingValues, { "calendar": value });
if(this.config.currentTemp) {
returnValues = recalculateAndTrigger(returnValues, this.config, this.node);
}
context.set("values", returnValues);
break;
case 'userTargetValue':
value = parseFloat(value);
returnValues = override(existingValues, { [msg.topic]: value });
context.set("values", returnValues);
returnValues.isUserCustom = true;
/* No break, continue with updating values... */
/* No break, continue with updating values... */
case 'currentTemp':
value = parseFloat(value);
returnValues = override(existingValues, { [msg.topic]: value });
context.set("values", returnValues);
returnValues = recalculateAndTrigger(returnValues, this.config, this.node);
context.set("values", returnValues);

this.node.send({
topic: this.config.topic,
payload: returnValues
});
break;
}
this.node.send({
topic: this.config.topic,
payload: returnValues
});
return { msg: returnValues };
};

Expand Down
5 changes: 3 additions & 2 deletions frontEnd.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ module.exports.init = function (config) {
$scope.init = function (config) {
$scope.config = config;
};

//front->back
$scope.toSchedule = function () {
$scope.msg.isUserCustom = false;
$scope.msg.targetValue = $scope.msg.temp;
$scope.send($scope.msg);
};

//front->back
$scope.sendVal = function () {
if (!$scope.msg.userTargetValue) {
$scope.msg.userTargetValue == $scope.config.sliderMinValue;
Expand All @@ -106,6 +106,7 @@ module.exports.init = function (config) {
$scope.msg.isUserCustom = true;
$scope.send($scope.msg);
};
//front->back
$scope.lockCustom = function () {
if ($scope.msg) {
$scope.msg.isUserCustomLocked = !$scope.msg.isUserCustomLocked;
Expand Down
12 changes: 6 additions & 6 deletions heater-controller.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
</div>
<div class="ident">
<div class="form-row">
<label for="node-input-sliderMinValue"><i class="fa fa-step-forward" aria-hidden="true"></i> <span data-i18n="heater_controller.label.min"></span></label>
<label for="node-input-sliderMinValue"><i class="fa fa-step-backward" aria-hidden="true"></i> <span data-i18n="heater_controller.label.min"></span></label>
<input type="number" step="1" id="node-input-sliderMinValue" data-i18n="[placeholder]heater_controller.placeholder.value" style="width: 280px" >
</div>
<div class="form-row">
<label for="node-input-sliderMaxValue"><i class="fa fa-step-backward" aria-hidden="true"></i> <span data-i18n="heater_controller.label.min"></span></label>
<label for="node-input-sliderMaxValue"><i class="fa fa-step-forward" aria-hidden="true"></i> <span data-i18n="heater_controller.label.max"></span></label>
<input type="number" step="1" id="node-input-sliderMaxValue" data-i18n="[placeholder]heater_controller.placeholder.value" style="width: 280px" >
</div>
<div class="form-row">
Expand All @@ -57,11 +57,11 @@
<div class="ident">
<div class="form-row" style="display: block;">
<label style="width: 140px !important" for="node-input-thresholdRising"><i class="fa fa-level-up"></i> <span data-i18n="heater_controller.label.upThreshold"></label>
<input type="number" min="0" max="100" step="0.5" list="defaultNumbers" id="node-input-thresholdRising" data-i18n="[placeholder]heater_controller.placeholder.value" style="width: 280px" dir="">
<input type="number" min="-100" max="100" step="0.5" list="defaultNumbers" id="node-input-thresholdRising" data-i18n="[placeholder]heater_controller.placeholder.value" style="width: 280px" dir="">
</div>
<div class="form-row" style="display: block;">
<label style="width: 140px !important" for="node-input-thresholdFalling"><i class="fa fa-level-down"></i> <span data-i18n="heater_controller.label.lowerThreshold"></label>
<input type="number" min="0" max="100" step="0.5" list="defaultNumbers" id="node-input-thresholdFalling" data-i18n="[placeholder]heater_controller.placeholder.value" style="width: 280px" dir="">
<input type="number" min="-100" max="100" step="0.5" list="defaultNumbers" id="node-input-thresholdFalling" data-i18n="[placeholder]heater_controller.placeholder.value" style="width: 280px" dir="">
</div>
<datalist id="defaultNumbers">
<option value="0">
Expand Down Expand Up @@ -146,13 +146,13 @@
thresholdRising: {
value: 0.5,
validate: function (v) {
return RED.validators.number(v)(v) && v >= 0 && v <= 100;
return RED.validators.number(v)(v) && v >= -100 && v <= 100;
}
},
thresholdFalling: {
value: 0.5,
validate: function (v) {
return RED.validators.number(v)(v) && v >= 0 && v <= 100;
return RED.validators.number(v)(v) && v >= -100 && v <= 100;
}
},
calendar: {
Expand Down
2 changes: 1 addition & 1 deletion heater-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = function (RED) {
group: config.group,
order: config.order || 0
}, backModule.getWidget()));
} catch (error) {
} catch (error) {
node.error(RED._(error));
throw error;
}
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-heater-controller",
"version": "1.2.0",
"version": "1.2.1",
"contributors": [],
"dependencies": {},
"deprecated": false,
Expand Down

0 comments on commit 05e92e2

Please sign in to comment.