Skip to content

Commit f0ea595

Browse files
author
vrilcode
committed
v1.1.0: Adapted granularity + code cleanup
1 parent a2e0d0e commit f0ea595

File tree

3 files changed

+28
-31
lines changed

3 files changed

+28
-31
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@vrilcode/node-red-wnsm-b2b",
33
"description": "Wiener Netze Smart Meter B2B API node for Node-RED",
4-
"version": "1.0.3",
4+
"version": "1.1.0",
55
"keywords": [
66
"node-red",
77
"smart-meter",

wnsm-b2b-node.html

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
required: true
99
},
1010
request: {
11-
value: 'all_messwerte'
11+
value: 'all_zaehlpunkte_values'
1212
},
1313
period: {
1414
value: 'current_month'
1515
},
16-
wertetyp: {
16+
granularity: {
1717
value: 'METER_READ'
1818
},
1919
kundenNr: {
@@ -33,30 +33,30 @@
3333
types: [{
3434
value: 'request',
3535
options: [
36-
{ value: 'all_messwerte', label: 'Get Messwerte for all Zählpunkte' },
37-
{ value: 'zaehlpunkt_messwerte', label: 'Get Messwerte for specific Zählpunkt' },
38-
{ value: 'all_zaehlpunkte', label: 'Get all Zählpunkte metadata' }
36+
{ value: 'all_zaehlpunkte_values', label: 'Get values for all Zählpunkte' },
37+
{ value: 'single_zaehlpunkt_values', label: 'Get values for specific Zählpunkt' },
38+
{ value: 'all_metadata', label: 'Get metadata for all Zählpunkte' }
3939
]
4040
}]
4141
})
4242

4343
$('#node-input-request').change(function() {
4444
switch ($('#node-input-request').val()) {
45-
case 'all_messwerte':
45+
case 'all_zaehlpunkte_values':
4646
$('#row-period').show()
47-
$('#row-wertetyp').show()
47+
$('#row-granularity').show()
4848
$('#row-kundenNr').hide()
4949
$('#row-zaehlpunktNr').hide()
5050
break
51-
case 'zaehlpunkt_messwerte':
51+
case 'single_zaehlpunkt_values':
5252
$('#row-period').show()
53-
$('#row-wertetyp').show()
53+
$('#row-granularity').show()
5454
$('#row-kundenNr').show()
5555
$('#row-zaehlpunktNr').show()
5656
break
57-
case 'all_zaehlpunkte':
57+
case 'all_metadata':
5858
$('#row-period').hide()
59-
$('#row-wertetyp').hide()
59+
$('#row-granularity').hide()
6060
$('#row-kundenNr').hide()
6161
$('#row-zaehlpunktNr').hide()
6262
break
@@ -76,19 +76,16 @@
7676
}]
7777
})
7878

79-
80-
$('#node-input-wertetyp').typedInput({
79+
$('#node-input-granularity').typedInput({
8180
types: [{
82-
value: 'wertetyp',
81+
value: 'granularity',
8382
options: [
83+
{ value: 'METER_READ', label: 'Meter values' },
8484
{ value: 'DAY', label: 'Daily values' },
85-
{ value: 'QUARTER_HOUR', label: 'Quarter-hourly values' },
86-
{ value: 'METER_READ', label: 'Meter read' }
85+
{ value: 'QUARTER_HOUR', label: 'Quarter-hourly values' }
8786
]
8887
}]
8988
})
90-
91-
9289
},
9390
inputs: 1,
9491
outputs: 1,
@@ -112,9 +109,9 @@
112109
<label for="node-input-period"><i class="fa fa-calendar"></i> Period</label>
113110
<input type="text" id="node-input-period">
114111
</div>
115-
<div class="form-row" id="row-wertetyp">
116-
<label for="node-input-wertetyp"><i class="fa fa-calendar"></i> Wertetyp</label>
117-
<input type="text" id="node-input-wertetyp">
112+
<div class="form-row" id="row-granularity">
113+
<label for="node-input-granularity"><i class="fa fa-bar-chart-o"></i> Granularity</label>
114+
<input type="text" id="node-input-granularity">
118115
</div>
119116
<div class="form-row" id="row-kundenNr">
120117
<label for="node-input-kundenNr"><i class="fa fa-id-card-o"></i> Kundennr.</label>
@@ -125,8 +122,8 @@
125122
<input type="text" id="node-input-zaehlpunktNr">
126123
</div>
127124
<div class="form-row">
128-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
129-
<input type="text" id="node-input-name" placeholder="Name">
125+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
126+
<input type="text" id="node-input-name" placeholder="Name">
130127
</div>
131128
</script>
132129

@@ -148,7 +145,7 @@
148145

149146
Messwerte of a specific Zählpunkt can only be retrieved, if Kundennr. is provided. Each Zählpunkt is assigned to one Kundennr. It's not needed if you retrieve Messwerte of all Zählpunkte. This gathers data of all Zählpunkte, which are related to the user account, even if they are assigned to different Kundennr.
150147

151-
If you retrieve just Zählpunkte metdata, non smart meters are included as well.
148+
Request type and granularity can only be set via node config, not via msg properties (inputs). If you retrieve just Zählpunkte metadata, non-smart meters are included as well.
152149

153150
API error responses are not particularly meaningful. That means, if you are using a wrong Kundennr. or wrong combination of Kundennr. and Zählpunkt, it is not unlikely, that you will receive a HTTP response with status code 500 (instead of 404) and no further description. If you are trying to access Zählpunkte, which do not belong to your account, it is possible that you will receive HTTP status 404 instead of 403 and so on (at least this could be argued with security considerations).
154151

wnsm-b2b-node.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@ module.exports = function(RED) {
1818

1919
let endpoint
2020
switch (config.request) {
21-
case 'all_zaehlpunkte':
22-
endpoint = '/zaehlpunkte/'
23-
break
24-
case 'all_messwerte':
21+
case 'all_zaehlpunkte_values':
2522
endpoint = '/zaehlpunkte/messwerte/'
2623
break
27-
case 'zaehlpunkt_messwerte':
24+
case 'single_zaehlpunkt_values':
2825
if (!kundenNr || !zaehlpunktNr) {
2926
done('Missing Kundennummer and/or Zählpunktnummer, both has to be provided via config or msg properties')
3027
return
3128
} else {
3229
endpoint = `/zaehlpunkte/${kundenNr}/${zaehlpunktNr}/messwerte`
3330
}
3431
break
32+
case 'all_metadata':
33+
endpoint = '/zaehlpunkte/'
34+
break
3535
default:
3636
done('Missing request type')
3737
return
@@ -74,7 +74,7 @@ module.exports = function(RED) {
7474
endpoint === 'all_zaehlpunkte' ? undefined : {
7575
'datumVon': dateFrom,
7676
'datumBis': dateTo,
77-
'wertetyp': config.wertetyp ? config.wertetyp : 'METER_READ'
77+
'wertetyp': config.granularity
7878
}
7979
)
8080
} catch (e) {

0 commit comments

Comments
 (0)