-
Notifications
You must be signed in to change notification settings - Fork 1
/
wnsm-b2b-node.html
148 lines (133 loc) · 5.41 KB
/
wnsm-b2b-node.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<script type="text/javascript">
RED.nodes.registerType('wnsm-b2b', {
category: 'input',
color: '#bb5d8c',
defaults: {
creds: {
type: 'wnsm-b2b-credentials',
required: true
},
request: {
value: 'single_zaehlpunkt_values'
},
period: {
value: 'current_month'
},
granularity: {
value: 'METER_READ'
},
kundenNr: {
value: '',
validate: RED.validators.regex(/\d+|/)
},
zaehlpunktNr: {
value: '',
validate: RED.validators.regex(/AT\d{31}|/)
},
name: {
value: ''
}
},
oneditprepare: function() {
$('#node-input-request').typedInput({
types: [{
value: 'request',
options: [
{ value: 'single_zaehlpunkt_values', label: 'Get values for specific Zählpunkt' },
{ value: 'all_metadata', label: 'Get metadata for all Zählpunkte' }
]
}]
})
$('#node-input-request').change(function() {
switch ($('#node-input-request').val()) {
case 'single_zaehlpunkt_values':
$('#row-period').show()
$('#row-granularity').show()
$('#row-kundenNr').show()
$('#row-zaehlpunktNr').show()
break
case 'all_metadata':
$('#row-period').hide()
$('#row-granularity').hide()
$('#row-kundenNr').hide()
$('#row-zaehlpunktNr').hide()
break
}
})
$('#node-input-period').typedInput({
types: [{
value: 'period',
options: [
{ value: 'current_month', label: 'Current month' },
{ value: 'previous_month', label: 'Previous month' },
{ value: 'yesterday', label: 'Yesterday' },
{ value: 'last_three_days', label: 'Last three days' },
{ value: 'custom', label: 'Custom period' },
]
}]
})
$('#node-input-granularity').typedInput({
types: [{
value: 'granularity',
options: [
{ value: 'METER_READ', label: 'Meter values' },
{ value: 'DAY', label: 'Daily values' },
{ value: 'QUARTER_HOUR', label: 'Quarter-hourly values' }
]
}]
})
},
inputs: 1,
outputs: 1,
icon: 'font-awesome/fa-bolt',
label: function() {
return this.name || 'WNSM B2B'
}
})
</script>
<script type="text/html" data-template-name="wnsm-b2b">
<div class="form-row">
<label for="node-input-creds"><i class="fa fa-id-card-o"></i> Credentials</label>
<input type="text" id="node-input-creds">
</div>
<div class="form-row">
<label for="node-input-request"><i class="fa fa-globe"></i> Request</label>
<input type="text" id="node-input-request">
</div>
<div class="form-row" id="row-period">
<label for="node-input-period"><i class="fa fa-calendar"></i> Period</label>
<input type="text" id="node-input-period">
</div>
<div class="form-row" id="row-granularity">
<label for="node-input-granularity"><i class="fa fa-bar-chart-o"></i> Granularity</label>
<input type="text" id="node-input-granularity">
</div>
<div class="form-row" id="row-kundenNr">
<label for="node-input-kundenNr"><i class="fa fa-id-card-o"></i> Kundennr.</label>
<input type="text" id="node-input-kundenNr">
</div>
<div class="form-row" id="row-zaehlpunktNr">
<label for="node-input-zaehlpunktNr"><i class="fa fa-map-marker"></i> Zählpunktnr.</label>
<input type="text" id="node-input-zaehlpunktNr">
</div>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
</script>
<script type="text/markdown" data-help-name="wnsm-b2b">
Access to Wiener Netze Smart Meter B2B API. Currently only querying Zählpunkte (metering points) metadata and Messwerte/Zählerstände (meter readings) is supported.
### Inputs
: dateFrom (string) : If period is set to custom, this is used to specify start of Messwerte date range in format "YYYY-MM-DD".
: dateTo (string) : If period is set to custom, this is used to specify end of Messwerte date range in format "YYYY-MM-DD".
: kundenNr (string) : Kundennummer, which is associated with requested Zählpunkt
: zaehlpunktNr (string) : Zählpunktnummer
### Outputs
: payload (object) : See details section and API docs link in references section.
### Details
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.
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).
### References
[Wiener Netze Smart Meter B2B API docs](https://api-portal.wienerstadtwerke.at/portal/apis/7f8a1cce-2a7e-4b18-840b-b0387ed9a3fc/apidocumentation) - description of API response objects (German)
[GitHub](https://github.com/vrilcode/node-red-wnsm-b2b-api) - the nodes GitHub repository
</script>