-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcar-bmw.html
398 lines (349 loc) · 15.7 KB
/
car-bmw.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
<!--
CAR BMW - config node which represents the ConnectedDrive account. Holds username/password.
-->
<script type="text/javascript">
RED.nodes.registerType("car-bmw", {
category: "config",
defaults: {
name: {value: "", required: false},
region: {value: "0", required: true},
unit: {value: "metric", required: true},
storage: {value: "", required: false},
debug: {value: false, required: true}
},
credentials: {
username: {type: "text"},
password: {type: "password"},
captcha: {type: "password", required: false},
},
label: function() {
return this.name ? this.name : "BMW ConnectedDrive";
}
});
</script>
<script type="text/x-red" data-template-name="car-bmw">
<div class="form-row">
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-config-input-name" />
</div>
<div class="form-row">
<label for="node-config-input-username"><i class="fa fa-user"></i> Username</label>
<input type="text" id="node-config-input-username" />
</div>
<div class="form-row">
<label for="node-config-input-password"><i class="fa fa-key"></i> Password</label>
<input type="password" id="node-config-input-password" />
</div>
<div class="form-row">
<label for="node-config-input-captcha"><i class="fa fa-barcode"></i> Captcha</label>
<input type="password" id="node-config-input-captcha" />
</div>
<div class="form-row">
<label for="node-config-input-region"><i class="fa fa-globe"></i> Region</label>
<select id="node-config-input-region" style="width:70%">
<option value=0>Rest of World</option>
<option value=1>USA</option>
<option value=2>China</option>
</select>
</div>
<div class="form-row">
<label for="node-config-input-unit"><i class="fa fa-balance-scale"></i> Units</label>
<select id="node-config-input-unit" style="width:70%">
<option value=metric>km & l</option>
<option value=imperial>mi & gal</option>
</select>
</div>
<div class="form-row">
<label for="node-config-input-storage" title="Name of the persistent context storage to keep the login state. Set only when multiple storages are configured."><i class="fa fa-database"></i> Storage</label>
<input type="text" id="node-config-input-storage" placeholder="Leave empty for default" />
</div>
<div class="form-row">
<label> </label>
<input type="checkbox" id="node-config-input-debug" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-config-input-debug" style="width: 70%;"> Debug mode</label>
</div>
<div class="form-tips">
<p>You need to configure the username and password of your BMW ConnectedDrive account.</p>
<p>Hint: Username is usually the email address you registered.</p>
<p>About <b>Captcha</b></p>
<p>Depending on your region, you will need a one-time token for the initial login that can be generated by solving a captcha.
Click one of the following links to obtain the token:
<a href="https://bimmer-connected.readthedocs.io/en/stable/captcha/rest_of_world.html" target="_blank">Rest of World</a>,
<a href="https://bimmer-connected.readthedocs.io/en/stable/captcha/north_america.html" target="_blank">USA</a>.
</p>
<p>
Paste it into the <label for="node-config-input-captcha" style="display: inline"><i>Captcha</i></label> input above and save & deploy the flow that is using this account.
The token is valid only for a short period of time.
</p>
<p>
Also ensure that you enabled a persistent <a href="https://nodered.org/docs/user-guide/context#context-stores" target="_blank">context storage</a> in the settings to preserve the login state, or you will have to solve a new captcha after a restart.
<br>
When multiple storages are configured, name the one to use in <label for="node-config-input-storage" style="display: inline"><i>Storage</i></label>.
</p>
</div>
</script>
<!--
CAR BMW - "list" node to list all registered vehicles of an account.
-->
<script type="text/javascript">
RED.nodes.registerType("car-bmw-list", {
category: "BMW",
color: "#2E9BDA",
icon: "car.png",
defaults: {
account: {type: "car-bmw", required: true},
name: {value: "", required: false},
as: {value: "single", required: true}
},
inputs: 1,
outputs: 1,
paletteLabel: "BMW List",
label: function() {
return this.name ? this.name : "BMW ConnectedDrive List";
},
labelStyle: function() {
return this.name ? "node_label_italic" : "";
}
});
</script>
<script type="text/x-red" data-template-name="car-bmw-list">
<div class="form-row">
<label for="node-input-account"><i class="fa fa-sign-in"></i> Account</label>
<input type="text" id="node-input-account">
</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" />
</div>
<div class="form-row">
<label for="node-input-as"><i class="fa fa-sign-out"></i> Output</label>
<select id="node-input-as" style="width:70%">
<option value="single">as a single message containing an array</option>
<option value="multi">as multiple messages, one for each car</option>
</select>
</div>
</script>
<script type="text/x-red" data-help-name="car-bmw-list">
<p>Read the list of cars, that are assigned to a BMW ConnectedDrive account.</p>
<h3>Inputs</h3>
<dl class="message-properties">
none
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">array | object</span></dt>
<dd> the result can be either a single message with a payload containing an array of car objects, or multiple
messages that each contain an object of a car. In any case the object holds various properties describing the car.</dd>
</dl>
<h3>Details</h3>
<p>The LIST node is used to list all cars which are assigned to a ConnectedDrive account.</p>
<h3>References</h3>
<ul>
<li><a href="https://github.com/krauskopf/node-red-contrib-car-bmw">GitHub</a> - the nodes github repository</li>
</ul>
</script>
<!--
CAR BMW - "get" node to read different values from the car.
-->
<script type="text/javascript">
RED.nodes.registerType("car-bmw-get", {
category: "BMW",
color: "#2E9BDA",
icon: "car.png",
defaults: {
account: {type: "car-bmw", required: true},
name: {value: "", required:false},
datatype: {value: "state", required: true}
},
credentials: {
vin: {type: "text", required: true}
},
inputs: 1,
outputs: 1,
paletteLabel: "BMW Get",
label: function() {
if (this.name) {
return this.name;
}
var text = {
"service": "Service \u2020",
"specs": "Specifications \u2020",
"dynamic": "Dynamic \u2020",
"navigation": "Navigation \u2020",
"chargingprofile": "Charging Profile",
"servicepartner": "Service Partner \u2020",
"efficiency": "Efficiency \u2020",
"statistics/allTrips": "All Trips \u2020",
"statistics/lastTrip": "Last Trip \u2020",
"status": "Status \u2020",
"destinations": "Destinations \u2020",
"charging-statistics": "Charging Statistics",
"charging-sessions": "Charging Sessions",
"state": "State"
};
return "" + text[this.datatype];
}
});
</script>
<script type="text/x-red" data-template-name="car-bmw-get">
<div class="form-row">
<label for="node-input-account"><i class="fa fa-sign-in"></i> Account</label>
<input type="text" id="node-input-account">
</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" />
</div>
<div class="form-row">
<label for="node-input-vin"><i class="fa fa-car"></i> VIN</label>
<input type="text" id="node-input-vin" placeholder="e.g. WBSXXXXXXXV123456"/>
</div>
<div class="form-row">
<label for="node-input-datatype"><i class="fa fa-file-text-o"></i> Data type</label>
<select id="node-input-datatype" style="width:70%">
<!--<option value="service">Services</option>-->
<!--<option value="specs">Specifications</option>-->
<!--<option value="dynamic">Dynamic</option>-->
<!--<option value="navigation">Navigation</option>-->
<!--<option value="servicepartner">Service Partner</option>-->
<!--<option value="efficiency">Efficiency</option>-->
<option value="state">State</option>
<option value="charging-statistics">Charging Statistics</option>
<option value="charging-sessions">Charging Sessions</option>
<option value="chargingprofile">Charging Profile</option>
</select>
</div>
</script>
<script type="text/x-red" data-help-name="car-bmw-get">
<p>Read different informations about your car.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt class="optional">vin <span class="property-type">string</span></dt>
<dd> if not set in the node configuration panel, this property specifies the VIN (vehicle identification number) of the car to read the infos from.</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">object</span></dt>
<dd> the return value. An object which has multiple properties with the data as returned from the ConnectedDrive server.</dd>
</dl>
<h3>Details</h3>
<p>The GET node is used to read the current state of a car. Select the desired data type to read in the editor panel.
You also have to specify the VIN (vehicle identification number) of your car. You can get the VIN of your car by looking in your
documents of by using the List node.<br>
If no VIN is given in the node configuration panel, then the vin in <code>msg.vin</code> is used.</p>
<h3>References</h3>
<ul>
<li><a href="https://github.com/krauskopf/node-red-contrib-car-bmw">GitHub</a> - the nodes github repository</li>
</ul>
</script>
<!--
CAR BMW - "action" node to trigger remote service of the car.
-->
<script type="text/javascript">
RED.nodes.registerType("car-bmw-action", {
category: "BMW",
color: "#2E9BDA",
icon: "car.png",
defaults: {
account: {type: "car-bmw", required: true},
name: {value: "", required:false},
action: {value: "RLF", required: true}
},
credentials: {
vin: {type: "text", required: true}
},
inputs: 1,
outputs: 1,
paletteLabel: "BMW Action",
label: function() {
if (this.name) {
return this.name;
}
var text = {
"RLF": "Flash Headlights",
"RHB": "Blow Horn",
"RDL": "Lock Door",
"RDU": "Unlock Door",
"RCN": "Start Climate",
"RCNSTOP": "Stop Climate",
"RVF": "Vehicle Finder",
"CHARGE_NOW": "Charge Now \u2020",
"CHANGE_CHARGING_MODE": "Change Charging Mode",
"CHANGE_CHARGING_SETTINGS": "Change Charging Settings",
"CHARGE_START": "Start Charging",
"CHARGE_STOP": "Stop Charging"
};
return "Action: " + text[this.action];
}
});
</script>
<script type="text/x-red" data-template-name="car-bmw-action">
<div class="form-row">
<label for="node-input-account"><i class="fa fa-sign-in"></i> Account</label>
<input type="text" id="node-input-account">
</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" />
</div>
<div class="form-row">
<label for="node-input-vin"><i class="fa fa-car"></i> VIN</label>
<input type="text" id="node-input-vin" placeholder="e.g. WBSXXXXXXXV123456"/>
</div>
<div class="form-row">
<label for="node-input-action"><i class="fa fa-car"></i> Action</label>
<select id="node-input-action" style="width:70%">
<option value="RLF">Flash Headlights</option>
<option value="RHB">Blow Horn</option>
<option value="RDL">Lock Door</option>
<option value="RDU">Unlock Door</option>
<option value="RCN">Start Climate</option>
<option value="RCNSTOP">Stop Climate</option>
<option value="RVF">Vehicle Finder</option>
<!--<option value="CHARGE_NOW">Charge Now</option>-->
<option value="CHANGE_CHARGING_MODE">Change Charging Mode</option>
<option value="CHANGE_CHARGING_SETTINGS">Change Charging Settings</option>
<option value="CHARGE_START">Start Charging</option>
<option value="CHARGE_STOP">Stop Charging</option>
</select>
</div>
</script>
<script type="text/x-red" data-help-name="car-bmw-action">
<p>Trigger an action on your car.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt class="optional">vin <span class="property-type">string</span></dt>
<dd> if not set in the node configuration panel, this property specifies the VIN (vehicle identification number) of the car to read the infos from.</dd>
</dl>
<dl class="message-properties">
<dt class="optional">payload <span class="property-type">string</span></dt>
<dd> If provided, this property specifies the JSON payload body which will be sent to the car.</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">object</span></dt>
<dd> the return value. An object which has multiple properties with the data as returned from the ConnectedDrive server.</dd>
</dl>
<h3>Details</h3>
<p>The ACTION node is used to trigger a remote service of a car. Select the desired action in the editor panel.
You also have to specify the VIN (vehicle identification number) of your car. You can get the VIN of your car by looking in your
documents of by using the List node.<br>
If no VIN is given in the node configuration panel, then the vin in <code>msg.vin</code> is used.<br></p>
<p>For some remote services (e.g. <code>Change Charging Mode</code>) a payload body has to be provided in <code>msg.payload</code>, which is sent to the car.</p>
<p>For the <code>Change Charging Mode</code> action the payload body must contain the charge and climate timer details to which the charging mode should be changed.
In this case the payload body must follow the object structure of the <code>chargeAndClimateTimerDetail</code> object returned by the <code>BMW Get</code> node for the data type <code>Charging Profile</code>.</p>
<p>For the <code>Change Charging Settings</code> action the payload body must contain the following properties:
<code>
{
"chargingTarget": xx,
"acLimitValue": xx
}
</code><br>
The <code>chargingTarget</code> must be a value between 20 and 100 in steps of 5.<br>
The <code>acLimitValue</code> must be a value as returned by the <code>chargingSettingsDetail.acLimit.values</code> of the <code>Charging Profile</code> data type of the <code>BMW Get</code> node.<br>
</p>
<h3>References</h3>
<ul>
<li><a href="https://github.com/krauskopf/node-red-contrib-car-bmw">GitHub</a> - the nodes github repository</li>
</ul>
</script>