Skip to content

Commit f52cec1

Browse files
author
vrilcode
committed
v2.0: Transition to official API
0 parents  commit f52cec1

File tree

12 files changed

+1643
-0
lines changed

12 files changed

+1643
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.DS_Store
2+
.env
3+
node_modules

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Wiener Netze Smart Meter API node for Node-RED
2+
3+
This package provides a node for [Node-RED](https://nodered.org/) to access the Wiener Netze Smart Meter API (see references). You can retrieve consumption values (Verbrauchsdaten), meter readings (Zählerstände) and metadata of metering points (Zählpunkte). Minimal example flows are included in directory `contrib`.
4+
5+
# Installation
6+
7+
```
8+
npm i @vrilcode/node-red-wnsm
9+
```
10+
11+
# Usage without Node-RED
12+
13+
You can use this package also with your regular JS/TS application without Node-RED. An example code is provided in `contrib/wnsm-client.mjs`, which can be executed via `npm run client`, if an according `.env` file exists.
14+
15+
# References
16+
17+
* [Wiener Netze Smart Meter-Portale](https://www.wienernetze.at/smart-meter-webportal) (German)
18+
* [Wiener Stadtwerke Developer-Portal](https://api-portal.wienerstadtwerke.at/portal/) (German)
19+
* [Docs for Wiener Netze Smart Meter API](https://api-portal.wienerstadtwerke.at/portal/apis/7f8a1cce-2a7e-4b18-840b-b0387ed9a3fc/apidocumentation) (German)

contrib/example-flows.json

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
[
2+
{
3+
"id": "1135eefa3b0c61df",
4+
"type": "inject",
5+
"z": "5d5ea87d01c5c7e6",
6+
"name": "",
7+
"props": [],
8+
"repeat": "",
9+
"crontab": "",
10+
"once": false,
11+
"onceDelay": 0.1,
12+
"topic": "",
13+
"x": 450,
14+
"y": 120,
15+
"wires": [
16+
[
17+
"a2769e9473170caa"
18+
]
19+
]
20+
},
21+
{
22+
"id": "37b6a644b42dddb3",
23+
"type": "debug",
24+
"z": "5d5ea87d01c5c7e6",
25+
"name": "debug 1",
26+
"active": true,
27+
"tosidebar": true,
28+
"console": false,
29+
"tostatus": false,
30+
"complete": "payload",
31+
"targetType": "msg",
32+
"statusVal": "",
33+
"statusType": "auto",
34+
"x": 980,
35+
"y": 120,
36+
"wires": []
37+
},
38+
{
39+
"id": "a2769e9473170caa",
40+
"type": "wnsm",
41+
"z": "5d5ea87d01c5c7e6",
42+
"config": "2fe01941af6497c4",
43+
"requestType": "metering_points_values",
44+
"valuesType": "DAY",
45+
"period": "previous_month",
46+
"meterTypes": "ALL",
47+
"meteringPoint": "",
48+
"name": "",
49+
"x": 580,
50+
"y": 120,
51+
"wires": [
52+
[
53+
"7617389087bf4531"
54+
]
55+
]
56+
},
57+
{
58+
"id": "7617389087bf4531",
59+
"type": "change",
60+
"z": "5d5ea87d01c5c7e6",
61+
"name": "Calc monthly consumption",
62+
"rules": [
63+
{
64+
"t": "set",
65+
"p": "payload",
66+
"pt": "msg",
67+
"to": "payload.{\t \"meteringPoint\": zaehlpunkt,\t \"period\": $moment(zaehlwerke[0].messwerte[0].zeitVon).format(\"YYYY-MM\"),\t \"consumptionWH\": $sum(zaehlwerke[0].messwerte.messwert)\t}",
68+
"tot": "jsonata"
69+
}
70+
],
71+
"action": "",
72+
"property": "",
73+
"from": "",
74+
"to": "",
75+
"reg": false,
76+
"x": 780,
77+
"y": 120,
78+
"wires": [
79+
[
80+
"37b6a644b42dddb3"
81+
]
82+
]
83+
},
84+
{
85+
"id": "de2a2c8eb0dc5416",
86+
"type": "inject",
87+
"z": "5d5ea87d01c5c7e6",
88+
"name": "",
89+
"props": [
90+
{
91+
"p": "dateFrom",
92+
"v": "2024-12-25",
93+
"vt": "str"
94+
},
95+
{
96+
"p": "dateTo",
97+
"v": "2025-01-01",
98+
"vt": "str"
99+
}
100+
],
101+
"repeat": "",
102+
"crontab": "",
103+
"once": false,
104+
"onceDelay": 0.1,
105+
"topic": "",
106+
"x": 450,
107+
"y": 160,
108+
"wires": [
109+
[
110+
"37cc3d8519ba3665"
111+
]
112+
]
113+
},
114+
{
115+
"id": "37cc3d8519ba3665",
116+
"type": "wnsm",
117+
"z": "5d5ea87d01c5c7e6",
118+
"config": "2fe01941af6497c4",
119+
"requestType": "metering_points_values",
120+
"valuesType": "METER_READ",
121+
"period": "custom",
122+
"meterTypes": "ALL",
123+
"meteringPoint": "",
124+
"name": "",
125+
"x": 580,
126+
"y": 160,
127+
"wires": [
128+
[
129+
"dae5168259a03462"
130+
]
131+
]
132+
},
133+
{
134+
"id": "dae5168259a03462",
135+
"type": "debug",
136+
"z": "5d5ea87d01c5c7e6",
137+
"name": "debug 2",
138+
"active": true,
139+
"tosidebar": true,
140+
"console": false,
141+
"tostatus": false,
142+
"complete": "payload",
143+
"targetType": "msg",
144+
"statusVal": "",
145+
"statusType": "auto",
146+
"x": 720,
147+
"y": 160,
148+
"wires": []
149+
},
150+
{
151+
"id": "a7fbd9115d8e760a",
152+
"type": "inject",
153+
"z": "5d5ea87d01c5c7e6",
154+
"name": "",
155+
"props": [],
156+
"repeat": "",
157+
"crontab": "",
158+
"once": false,
159+
"onceDelay": 0.1,
160+
"topic": "",
161+
"x": 450,
162+
"y": 200,
163+
"wires": [
164+
[
165+
"3d7eaa0601921c33"
166+
]
167+
]
168+
},
169+
{
170+
"id": "3d7eaa0601921c33",
171+
"type": "wnsm",
172+
"z": "5d5ea87d01c5c7e6",
173+
"config": "2fe01941af6497c4",
174+
"requestType": "metering_points_metadata",
175+
"valuesType": "METER_READ",
176+
"period": "custom",
177+
"meterTypes": "ALL",
178+
"meteringPoint": "",
179+
"name": "",
180+
"x": 580,
181+
"y": 200,
182+
"wires": [
183+
[
184+
"27ca2232bacde357"
185+
]
186+
]
187+
},
188+
{
189+
"id": "27ca2232bacde357",
190+
"type": "debug",
191+
"z": "5d5ea87d01c5c7e6",
192+
"name": "debug 3",
193+
"active": true,
194+
"tosidebar": true,
195+
"console": false,
196+
"tostatus": false,
197+
"complete": "payload",
198+
"targetType": "msg",
199+
"statusVal": "",
200+
"statusType": "auto",
201+
"x": 720,
202+
"y": 200,
203+
"wires": []
204+
},
205+
{
206+
"id": "2fe01941af6497c4",
207+
"type": "wnsm-config",
208+
"name": "Default"
209+
}
210+
]

contrib/wnsm-client.mjs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import Wnsm from '../wnsm-api.js'
2+
3+
const wnsm = new Wnsm({
4+
clientId: process.env.WNSM_CLIENT_ID,
5+
clientSecret: process.env.WNSM_CLIENT_SECRET,
6+
apiKey: process.env.WNSM_API_KEY
7+
})
8+
9+
try {
10+
let data
11+
12+
data = await wnsm.call('/zaehlpunkte/messwerte', {
13+
datumVon: '2025-02-01',
14+
datumBis: '2025-02-15',
15+
wertetyp: 'METER_READ',
16+
})
17+
18+
console.log(JSON.stringify(data, null, 2))
19+
} catch (err) {
20+
console.error('Got an error', err)
21+
}

0 commit comments

Comments
 (0)