Skip to content

Commit

Permalink
Update Dependencies and add GasUsage feature (#167)
Browse files Browse the repository at this point in the history
* Update Dependencies and add GasUsage feature

* Drop support for Node v8

* Add examples 

* Create major release
  • Loading branch information
RaimondB authored Aug 15, 2020
1 parent 7fafc11 commit 951c718
Show file tree
Hide file tree
Showing 9 changed files with 697 additions and 211 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
language: node_js

node_js:
- "8"
- "10"
- "12"
- "14"
- "lts/*"

cache: npm
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
[![Build Status](https://travis-ci.com/RaimondB/node-red-contrib-nefit-easy.svg?branch=master)](https://travis-ci.com/RaimondB/node-red-contrib-nefit-easy)
[![Known Vulnerabilities](https://snyk.io/test/github/RaimondB/node-red-contrib-nefit-easy/badge.svg?targetFile=package.json)](https://snyk.io/test/github/RaimondB/node-red-contrib-nefit-easy?targetFile=package.json)

The typical setup is show below:
A simple setup to get the current temperature is shown below:
![alt text](images/nefit-easy-flow.PNG "Example flow")

Also see this link for an [importable version of the example](examples/nefit-easy-flow.json).
Also see [a number of importable examples in my repository](https://github.com/RaimondB/node-red-contrib-nefit-easy/tree/master/examples)).

---
*Pro-Tip* : Be sure to use an external trigger (such as the inject node) to get the latest status. This way you can determine the update speed yourself. However, keep in mind that updating quicker than every 60 seconds will probably result into errors because of limitations of the Nefit API.
Expand All @@ -18,6 +18,8 @@ Also see this link for an [importable version of the example](examples/nefit-eas
This Node-RED Node is based on the <a href="https://github.com/robertklep/nefit-easy-commands">Nefit Easy™ commands library build by Robert Klep</a>.
At this link also all usable commands are documented and not repeated here for maintainability.

*Minimum supported Node version is now at 10.x.*

## Features

* Get Status (all information that is visible in the App, including current Temp.)
Expand All @@ -30,6 +32,7 @@ At this link also all usable commands are documented and not repeated here for m
* Set Fireplace Mode (enable or disable)
* Get User Mode (manual or clock operation mode
* Set User Mode
* Get Gas Usage Data per day

## Installation

Expand Down
102 changes: 102 additions & 0 deletions examples/nefit-easy-dailygasusage-to-influx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
[
{
"id": "a248bce7.8f79d",
"type": "nefit-easy",
"z": "33143d4b.705502",
"easyconfig": "6a526c87.a87da4",
"name": "",
"topic": "nefit-easy",
"command": "getval-gasusage",
"value": "",
"x": 440,
"y": 200,
"wires": [
[
"12c9e807.0285c8",
"326e6cad.8b1bc4"
]
]
},
{
"id": "12c9e807.0285c8",
"type": "debug",
"z": "33143d4b.705502",
"name": "Easy Results",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 650,
"y": 140,
"wires": []
},
{
"id": "326e6cad.8b1bc4",
"type": "function",
"z": "33143d4b.705502",
"name": "Map Nefit to influx",
"func": "var result = msg.payload.map(v => {\n return { \n timestamp : v.date,\n measurement : \"nefit_easy\",\n fields: {\n hot_water : v[\"hot water\"],\n central_heating : v[\"central heating\"],\n average_outdoor_temperature : v[\"average outdoor temperature\"]\n }\n };\n});\n\nmsg.payload = result;\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 670,
"y": 200,
"wires": [
[
"8b8ade76.8c1ac"
]
]
},
{
"id": "16eeece5.cf6733",
"type": "inject",
"z": "33143d4b.705502",
"name": "Trigger Daily",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "00 04 * * *",
"once": false,
"onceDelay": "",
"topic": "",
"payload": "",
"payloadType": "num",
"x": 180,
"y": 200,
"wires": [
[
"a248bce7.8f79d"
]
]
},
{
"id": "8b8ade76.8c1ac",
"type": "influxdb batch",
"z": "33143d4b.705502",
"influxdb": "",
"precision": "",
"retentionPolicy": "",
"name": "",
"x": 940,
"y": 200,
"wires": []
},
{
"id": "6a526c87.a87da4",
"type": "nefit-easy-config",
"z": "",
"timeout": "30"
}
]
205 changes: 205 additions & 0 deletions examples/nefit-easy-migrategasusage-to-influx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
[
{
"id": "cc842a3e.278718",
"type": "nefit-easy",
"z": "76f4e759.530ae8",
"easyconfig": "f28ada3e.a49d18",
"name": "",
"topic": "nefit-easy",
"command": "getval-gasusage",
"value": "",
"x": 560,
"y": 320,
"wires": [
[
"1c3890ae.f046ff"
]
]
},
{
"id": "713e2984.e48828",
"type": "inject",
"z": "76f4e759.530ae8",
"name": "Trigger All Pages",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 120,
"y": 60,
"wires": [
[
"b66a472b.d9b848"
]
]
},
{
"id": "d60b59b1.759198",
"type": "influxdb batch",
"z": "76f4e759.530ae8",
"influxdb": "",
"precision": "",
"retentionPolicy": "",
"name": "",
"x": 860,
"y": 460,
"wires": []
},
{
"id": "1c3890ae.f046ff",
"type": "function",
"z": "76f4e759.530ae8",
"name": "Map Nefit to influx",
"func": "var result = msg.payload.map(v => {\n return { \n timestamp : v.date,\n measurement : \"nefit_easy\",\n fields: {\n hot_water : v[\"hot water\"],\n central_heating : v[\"central heating\"],\n average_outdoor_temperature : v[\"average outdoor temperature\"]\n }\n };\n});\n\nmsg.payload = result;\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 610,
"y": 460,
"wires": [
[
"d60b59b1.759198",
"3f9ad713.4f3f08"
]
]
},
{
"id": "3f9ad713.4f3f08",
"type": "function",
"z": "76f4e759.530ae8",
"name": "Loop all pages",
"func": "\nvar newPage = flow.get(\"page\");\nnewPage++;\nflow.set(\"page\", newPage);\n\nvar maxPage = flow.get(\"maxpage\");\n\nif(newPage <= maxPage)\n{\nmsg.payload = newPage;\nreturn msg;\n}\nelse\n{\n return null;\n}",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 340,
"y": 460,
"wires": [
[
"cc239a8b.da7928"
]
]
},
{
"id": "b66a472b.d9b848",
"type": "change",
"z": "76f4e759.530ae8",
"name": "Reset Page",
"rules": [
{
"t": "set",
"p": "page",
"pt": "flow",
"to": "0",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 140,
"y": 140,
"wires": [
[
"b8d14a60.24f6d8"
]
]
},
{
"id": "cc239a8b.da7928",
"type": "delay",
"z": "76f4e759.530ae8",
"name": "",
"pauseType": "delay",
"timeout": "2",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 380,
"y": 320,
"wires": [
[
"cc842a3e.278718"
]
]
},
{
"id": "b8d14a60.24f6d8",
"type": "nefit-easy",
"z": "76f4e759.530ae8",
"easyconfig": "f28ada3e.a49d18",
"name": "",
"topic": "nefit-easy",
"command": "gasusagepage",
"value": "",
"x": 300,
"y": 140,
"wires": [
[
"3b13e1ab.b6e4ae"
]
]
},
{
"id": "3b13e1ab.b6e4ae",
"type": "function",
"z": "76f4e759.530ae8",
"name": "Get Max Page Nr",
"func": "flow.set(\"maxpage\", msg.payload || 0);\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 190,
"y": 240,
"wires": [
[
"80d6e6e5.ec7d58",
"3f9ad713.4f3f08"
]
]
},
{
"id": "80d6e6e5.ec7d58",
"type": "debug",
"z": "76f4e759.530ae8",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 510,
"y": 200,
"wires": []
},
{
"id": "f28ada3e.a49d18",
"type": "nefit-easy-config",
"z": "",
"timeout": "30"
}
]
9 changes: 8 additions & 1 deletion nefit-easy-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ module.exports = function(RED) {
//
var EasyClient = require('nefit-easy-commands');


function NefitEasyConfigNode(n) {
//
// The configuration node stores the Nefit configuration and initiates the connection to Bosch backend servers.
Expand Down Expand Up @@ -108,6 +107,14 @@ module.exports = function(RED) {
});
break;

case 'getval-gasusage':
promise = client.gasUsage(value);
break;

case 'gasusagepage' :
promise = client.gasUsagePage();
break;

default:
return;
}
Expand Down
Loading

0 comments on commit 951c718

Please sign in to comment.