This repository has been archived by the owner on Sep 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
vw-carnet.js
1431 lines (1334 loc) · 69.6 KB
/
vw-carnet.js
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
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// version 0.3.1a
// to start debugging in vscode:
// node --inspect-brk vw-carnet.js --force --logs
/*jshint esversion: 6 */
/*jshint sub:true*/
// 'use strict';
const utils = require('@iobroker/adapter-core');
let adapter;
//var ioBroker_Settings
var ioBroker_Language = 'en';
//DummyFunktion, die übergeben wird, wenn kein Callback benötigt wird
function dummyFunc(myTmp) {}
function startUpdateProcess(count) {
mySuccessfulUpdate = true;
myUpdateCount = count;
}
function updateSuccessfulFlag(myTmp) {
mySuccessfulUpdate = mySuccessfulUpdate && myTmp;
myUpdateCount --;
if (myUpdateCount <= 0) {
myUpdateCount = 0;
//adapter.log.info('VW Car-Net connected?: ' + VWCarNet_Connected);
if (mySuccessfulUpdate){
var myDate = Date.now();
adapter.setState('lastUpdate', {val: myDate, ack: true});
}
}
}
function startAdapter(options) {
options = options || {};
Object.assign(options,{
name: "vw-carnet",
//ab hier neu V 0.3.x
stateChange: function (id, state) {
var myTmp1
var myCommand = id.split('.');
myCommand = myCommand[myCommand.length -1];
//adapter.log.info(myCommand);
if (myCommand === 'btn_update') {
VWCarNetReadData(); // command 'update' received
}
if (myCommand === 'btn_chargerStart') {
requestCarSwitchCharger('start', dummyFunc); //command start charging received
}
if (myCommand === 'btn_chargerStop') {
requestCarSwitchCharger('stop', dummyFunc); //command stop charging received
}
if (myCommand === 'btn_climaterStart') {
adapter.log.info('start climater not yet implemented')
//requestCarSwitchClimater('start', dummyFunc); //command start climater received
}
if (myCommand === 'btn_climaterStop') {
adapter.log.info('stop climater not yet implemented')
//requestCarSwitchClimater('stop', dummyFunc); //command stop climater received
}
if (myCommand === 'btn_windowheatStart') {
adapter.log.info('start windowheat not yet implemented')
//requestCarSwitchWindowHeater('start', dummyFunc); //command start windowheat received
}
if (myCommand === 'btn_windowheatStop') {
adapter.log.info('stop windowheat not yet implemented')
//requestCarSwitchWindowHeater('stop', dummyFunc); //command stop windowheat received
}
},
//bis hier neu V 0.3.x
message: function (obj) {
if (typeof obj === 'object' && obj.message) {
var lCommand = obj.command.toLowerCase();
adapter.log.info('Received message: ' + lCommand);
if (lCommand === 'update') {
VWCarNetReadData(); // sendto command 'update' received
}
if (lCommand === 'carsenddata') {
VWCarNetForceCarToSendData(); // sendto command 'update' received
}
}
},
unload: function (callback) {
try {
stopUpdateTimer();
VWCarNet_Connected = false;
adapter.setState('connection', {val: VWCarNet_Connected, ack: true}); //connection to Threema gateway not established
adapter.log.info('Adapter stopped - cleaned everything up...');
callback();
} catch (e) {
callback();
}
},
ready: function () {
var myTmp;
//adapter.log.info(ioBroker_Language)
CreateStates_common(dummyFunc);
myGoogleMapsAPIKey = adapter.config.GoogleAPIKey;
VWCarNet_GetStatus = adapter.config.adapterGetStatus;
VWCarNet_GetClimater = adapter.config.adapterGetClimater;
VWCarNet_GetEManager = adapter.config.adapterGetEManager;
VWCarNet_GetLocation = adapter.config.adapterGetLocation;
CreateStates_Services(dummyFunc);
CreateStates_Status(dummyFunc);
CreateStates_climater(dummyFunc);
CreateStates_eManager(dummyFunc);
CreateStates_location(dummyFunc);
main();
startUpdateTimer();
}
});
adapter = new utils.Adapter(options);
adapter.getForeignObject('system.config', function(err, ioBroker_Settings) {
if (err) {
adapter.log.error('Error while fetching system.config: ' + err);
return;
}
switch (ioBroker_Settings.common.language){
case 'de':
ioBroker_Language = 'de';
break;
default:
ioBroker_Language = 'en';
}
});
return adapter;
}
var VWCarNet_CredentialsAreValid = false;
var VWCarNet_Country = 'DE';
var VWCarNet_Brand = 'VW';
var VWCarNet_VINIsValid = false;
var VWCarNet_Connected = false;
var VWCarNet_GetStatus = false;
var VWCarNet_GetClimater = false;
var VWCarNet_GetEManager = false;
var VWCarNet_GetLocation = false;
var myCarNet_myChargingState;
var myCarNet_MaxChargeCurrent;
var myCarNet_PowerSupplyState;
var myCarNet_vehicleStatus;
var myCarNet_requestID;
var myCarNetDoors={'doors':'dummy'};
var myCarNetWindows={'windows':'dummy'};
var mySuccessfulUpdate = true;
var myUpdateCount = 0;
var myUpdateTimer = null;
var myToken = '';
var myVIN = '';
var myTmp;
var request = require('request');
// Fake the VW CarNet mobile app headers
var myHeaders = {'accept': 'application/json'};
myHeaders['x-app-name'] = 'eRemote';
myHeaders['clientid'] = 'CarNetApp';
myHeaders['x-app-version'] = '4.6.1';
myHeaders['user-agent'] = 'okhttp/3.7.0';
var myAuthHeaders = JSON.parse(JSON.stringify(myHeaders));
var myGoogleMapsAPIKey = '';
var myGoogleDefaulHeader = {
'Accept': 'application/json, ' + 'text/plain, */*',
'Content-Type': 'application/json;charset=UTF-8',
'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0.1; D5803 Build/23.5.A.1.291; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/63.0.3239.111 Mobile Safari/537.36'};
//##############################################################################################################
// declaring names of states for CarNet Services data
const channel_sv = {'label':'CarNet-Servcies', 'en':'status of available carnet services', 'de':'Status der verfügbaren CarNet Services'};
const state_sv_statusreport_v1_status = {'label':'CarNet-Servcies.StatusReport.serviceStatus', 'en':'general status data', 'de':'allgemeine Status Daten'};
const state_sv_statusreport_v1_eol = {'label':'CarNet-Servcies.StatusReport.serviceEOL', 'en':'end of life general status data', 'de':'Vertragsende'};
const state_sv_rclima_v1_status = {'label':'CarNet-Servcies.Climater.serviceStatus', 'en':'climaterdata', 'de':'Lüftung/Klimaanlage'};
const state_sv_rclima_v1_eol = {'label':'CarNet-Servcies.Climater.serviceEOL', 'en':'end of life', 'de':'Vertragsende'};
const state_sv_carfinder_v1_status = {'label':'CarNet-Servcies.CarFinder.serviceStatus', 'en':'locationdata', 'de':'Standortdaten'};
const state_sv_carfinder_v1_eol = {'label':'CarNet-Servcies.CarFinder.serviceEOL', 'en':'end of life', 'de':'Vertragsende'};
const state_sv_rbatterycharge_v1_status = {'label':'CarNet-Servcies.eManager.serviceStatus', 'en':'electric data (electric/hybrid cars only)', 'de':'Daten für Elektro- Hybridfahrzeuge'};
const state_sv_rbatterycharge_v1_eol = {'label':'CarNet-Servcies.eManager.serviceEOL', 'en':'end of life', 'de':'Vertragsende'};
//##############################################################################################################
// declaring names of states for Vehicle data
const channel_v = {'label':'Vehicle', 'en':'selected vehicle', 'de':'Fahrzeug'};
const state_v_name = {'label':'Vehicle.name', 'en':'name in VW Car-Net', 'de':'Name des Fahrzeuges in VW Car-Net'};
const state_v_VIN = {'label':'Vehicle.VIN', 'en':'vehicle identification number', 'de':'Fahrgestellnummer'};
const state_v_Update = {'label':'Vehicle.btn_update', 'en': 'load data from CarNet', 'de': 'Daten von CarNet laden'};
//##############################################################################################################
// declaring names of states for status data
const channel_s = {'label':'Vehicle.Status', 'en': 'Status of vehicle', 'de': 'Fahrzeugstatus'};
const state_s_lastConnectionTimeStamp = {'label':'Vehicle.Status.lastConnectionTimeStamp', 'en': 'Last connection timestamp', 'de': 'Zeitpunkt der letzten Verbindung'};
const state_s_distanceCovered = {'label':'Vehicle.Status.distanceCovered', 'en': 'Distance covered', 'de': 'Kilometerstand'};
const state_s_hybridRange = {'label':'Vehicle.Status.hybridRange', 'en': 'total range', 'de': 'Gesamtreichweite'};
const state_s_serviceInspectionDistance= {'label':'Vehicle.Status.serviceInspectionDistance', 'en': 'Distance until next service inspection', 'de': 'Entfernung bis zur nächsten Inspektion'};
const state_s_serviceInspectionTime= {'label':'Vehicle.Status.serviceInspectionTime', 'en': 'Time until next service inspecton', 'de': 'Zeit bis zur nächsten Inspektion', 'unit_de':'Tag(e)', 'unit_en':'day(s)'};
const state_s_oilInspectionDistance= {'label':'Vehicle.Status.oilInspectionDistance', 'en': 'Distance until next oil inspection', 'de': 'Entfernung bis zum nächsten Ölwechsel'};
const state_s_oilInspectionTime= {'label':'Vehicle.Status.oilInspectionTime', 'en': 'Time until next oil inspecton', 'de': 'Zeit bis zum nächsten Ölwechsel', 'unit_de':'Tag(e)', 'unit_en':'day(s)'};
const state_s_adBlueInspectionDistance= {'label':'Vehicle.Status.adBlueInspectionDistance', 'en': 'Distance until next ad blue inspection', 'de': 'Entfernung bis zur nächsten AdBlue-Füllung'};
const state_s_parkingLights = {'label':'Vehicle.Status.ParkingLights', 'en': 'Parking lights', 'de': 'Parklichter / Standlicht'};
const state_s_parkingBrake = {'label':'Vehicle.Status.ParkingBrake', 'en': 'Parking brake', 'de': 'Parkbremse'};
const state_s_carCentralLock = {'label':'Vehicle.Status.CentralLock', 'en': 'Central lock', 'de': 'Zentralverriegelung'};
const state_s_fuelType = {'label':'Vehicle.Status.fuelType', 'en': 'Motor type', 'de': 'Kraftstoff-Typ'}; // XXX
const state_s_fuelLevel = {'label':'Vehicle.Status.fuelLevel', 'en': 'fuel level', 'de': 'Kraftstoff-Füllstand'};
const state_s_fuelRange = {'label':'Vehicle.Status.fuelRange', 'en': 'fuel range', 'de': 'Kraftstoff-Reichweite'};
const state_s_batteryLevel = {'label':'Vehicle.Status.batteryLevel', 'en': 'battery level', 'de': 'Batterie-Füllstand'};
const state_s_batteryRange = {'label':'Vehicle.Status.batteryRange', 'en': 'battery range', 'de': 'Batterie-Reicheweite'};
const channel_dw_DoorsAndWindows = {'label':'Vehicle.Status.DoorsAndWindows', 'en': 'doors and windows', 'de': 'Türen und Fenster'};
const state_dw_Doors = {'label':'Vehicle.Status.DoorsAndWindows.doorsJSON', 'en': 'JSON objekt with windowstates', 'de': 'JSON Objekt Status Türen'};
const state_dw_Windows = {'label':'Vehicle.Status.DoorsAndWindows.windowsJSON', 'en': 'JSON object with doorstates', 'de': 'JSON Objekt Status Fenster'};
//##############################################################################################################
// declaring names of states for climater data
const channel_c = {'label':'Vehicle.climater', 'en': 'heating / air condition / climater', 'de': 'Heizung / Klimaanlage / Lüftung'};
const state_c_climatisationWithoutHVPower = {'label':'Vehicle.climater.climatisationWithoutHVPower', 'en': 'Allow air condition in e-mode', 'de': 'Klimaanlage über Batterie zulassen'};
const state_c_targetTemperature = {'label':'Vehicle.climater.targetTemperature', 'en': 'Target temperature', 'de': 'Zieltemperatur'};
const state_c_heaterSource = {'label':'Vehicle.climater.heaterSource', 'en': 'Heater source', 'de': 'Heizungs-Quelle'};
const state_c_climatisationReason = {'label':'Vehicle.climater.climatisationReason', 'en': 'Climatisation reason', 'de': 'Heizungsbetrieb'};
const state_c_windowHeatingStateFront = {'label':'Vehicle.climater.windowHeatingStateFront', 'en': 'State of window heating front', 'de': 'Zustand der Windschutzscheibenheizung'};
const state_c_windowHeatingStateRear = {'label':'Vehicle.climater.windowHeatingStateRear', 'en': 'State of window heating rear', 'de': 'Zustand der Heckscheibenheizung'};
const state_c_outdoorTemperature = {'label':'Vehicle.climater.outdoorTemperature', 'en': 'Outdoor temperature', 'de': 'Außentemperatur'};
const state_c_vehicleParkingClock = {'label':'Vehicle.climater.vehicleParkingClock', 'en': 'Parking timestamp', 'de': 'Parkzeit'};
const state_c_climatisationState = {'label':'Vehicle.climater.climatisationState', 'en': 'State of climatisation', 'de': 'Zustand der Standheizung'};
const state_c_remainingClimatisationTime = {'label':'Vehicle.climater.remainingClimatisationTime', 'en': 'Remaining climatisation time', 'de': 'Verbleibende Dauer bis Zieltemperatur'};
const state_c_climaterStart = {'label':'Vehicle.climater.btn_climaterStart', 'en': 'start heating process', 'de': 'Klimatisieren starten'};
const state_c_climaterStop = {'label':'Vehicle.climater.btn_climaterStop', 'en': 'stop heating process', 'de': 'Klimatisieren stoppen'};
const state_c_windowheatStart = {'label':'Vehicle.climater.btn_windowheatStart', 'en': 'start windowmelt', 'de': 'Scheibenheizung starten'};
const state_c_windowheatStop = {'label':'Vehicle.climater.btn_windowheatStop', 'en': 'stop windowmelt', 'de': 'Scheibenheizung stoppen'};
//##############################################################################################################
// declaring names of states for eManager data
const channel_e = {'label':'Vehicle.eManager', 'en': 'e-manager', 'de': 'e-Manager'};
const state_e_stateOfCharge = {'label':'Vehicle.eManager.stateOfCharge', 'en': 'Charging state main battery', 'de': 'Ladezustand der Hauptbatterie'};
const state_e_remainingChargingTimeTargetSOC = {'label':'Vehicle.eManager.remainingChargingTimeTargetSOC', 'en': 'Remaining charging time until SOC', 'de': 'Verbleibende Ladedauer untere Batterie-Ladegrenze'};
const state_e_chargingMode = {'label':'Vehicle.eManager.chargingMode', 'en': 'Charging mode', 'de': 'Lademodus'};
const state_e_chargingState = {'label':'Vehicle.eManager.chargingState', 'en': 'Charging state', 'de': 'Zustand des Ladevorgangs'};
const state_e_chargingReason = {'label':'Vehicle.eManager.chargingReason', 'en': 'Charging reason', 'de': 'Ladebetrieb'};
const state_e_remainingChargingTime = {'label':'Vehicle.eManager.remainingChargingTime', 'en': 'Remaining charging time until 100%', 'de': 'Verbleibende Ladedauer bis 100%'};
const state_e_maxChargeCurrent = {'label':'Vehicle.eManager.maxChargeCurrent', 'en': 'Maximun charging current', 'de': 'Maximaler Ladestrom'};
const state_e_plugState = {'label':'Vehicle.eManager.plugState', 'en': 'Charging cable plugged', 'de': 'Status Ladestecker'};
const state_e_lockState = {'label':'Vehicle.eManager.lockState', 'en': 'Charging cable locked', 'de': 'Verriegelung Ladestecker'};
const state_e_extPowerSupplyState = {'label':'Vehicle.eManager.externalPowerSupplyState', 'en': 'External power supply state', 'de': 'Status externe Stromversorgung'};
const state_e_chargerStart = {'label':'Vehicle.eManager.btn_chargerStart', 'en': 'start charging process', 'de': 'Ladevorgang starten'};
const state_e_chargerStop = {'label':'Vehicle.eManager.btn_chargerStop', 'en': 'stop charging process', 'de': 'Ladevorgang stoppen'};
//##############################################################################################################
// declaring names of states for location data
const channel_l = {'label':'Vehicle.location', 'en': 'Location', 'de': 'Ortungsdaten Fahrzeug'};
const state_l_lat = {'label':'Vehicle.location.latitude', 'en': 'Latitude', 'de': 'Breitengrad'};
const state_l_lng = {'label':'Vehicle.location.longitude', 'en': 'Longitude', 'de': 'Längengrad'};
const state_l_parkingTime = {'label':'Vehicle.location.parkingTimeUTC', 'en': 'Parking timestamp', 'de': 'Parkzeit'};
const state_l_address = {'label':'Vehicle.location.parkingAddress', 'en': 'Parking address', 'de': 'Parkadresse'};
function stopUpdateTimer() {
if (myUpdateTimer) {
clearInterval(myUpdateTimer);
myUpdateTimer = null;
}
}
function startUpdateTimer() {
stopUpdateTimer();
var updateInterval = parseInt(adapter.config.autoUpdate);
if (updateInterval > 0) {
myUpdateTimer = setInterval(autoUpdate, 1000 * 60 * Math.max(updateInterval, 5));
}
}
function autoUpdate() {
// Always try to update data. If not logged on, funxction will try to
// Otherwise: In case of a suspended VW server Connected will become false
// an there would be no further updates anymore.
//if (VWCarNet_Connected) // If connected to VW car-net server
VWCarNetReadData();
}
function CreateStates_common(callback){
// creating channel/states for Vehicle Data
adapter.setObject(channel_v.label, {
type: 'object',
common: {name: channel_v[ioBroker_Language]},
native: {}
});
adapter.setObject(state_v_name.label, {
type: 'state',
common: {name: state_v_name[ioBroker_Language], type: 'string', read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_v_VIN.label, {
type: 'state',
common: {name: state_v_VIN[ioBroker_Language], type: 'string', read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_v_Update.label, {
type: 'state',
common: {name: state_v_Update[ioBroker_Language], type: "boolean", read: false, write: true, role: 'button'},
native: {}
});
return callback(true);
}
function CreateStates_Services(callback){
// creating channel/states for available CarNet services
adapter.setObject(channel_sv.label, {
type: 'object',
common: {name: channel_sv[ioBroker_Language]},
native: {}
});
adapter.setObject(state_sv_statusreport_v1_status.label, {
type: 'state',
common: {name: state_sv_statusreport_v1_status[ioBroker_Language], type: 'string', read: true, write: false, role: 'value'},
native: {}
});
adapter.setState(state_sv_statusreport_v1_status.label, {val: 'Disabled', ack: true});
adapter.setObject(state_sv_statusreport_v1_eol.label, {
type: 'state',
common: {name: state_sv_statusreport_v1_eol[ioBroker_Language], type: 'string', read: true, write: false, role: 'datetime'},
native: {}
});
adapter.setObject(state_sv_rclima_v1_status.label, {
type: 'state',
common: {name: state_sv_rclima_v1_status[ioBroker_Language], type: 'string', read: true, write: false, role: 'value'},
native: {}
});
adapter.setState(state_sv_rclima_v1_status.label, {val: 'Disabled', ack: true});
adapter.setObject(state_sv_rclima_v1_eol.label, {
type: 'state',
common: {name: state_sv_rclima_v1_eol[ioBroker_Language], type: 'string', read: true, write: false, role: 'datetime'},
native: {}
});
adapter.setObject(state_sv_carfinder_v1_status.label, {
type: 'state',
common: {name: state_sv_carfinder_v1_status[ioBroker_Language], type: 'string', read: true, write: false, role: 'value'},
native: {}
});
adapter.setState(state_sv_carfinder_v1_status.label, {val: 'Disabled', ack: true});
adapter.setObject(state_sv_carfinder_v1_eol.label, {
type: 'state',
common: {name: state_sv_carfinder_v1_eol[ioBroker_Language], type: 'string', read: true, write: false, role: 'datetime'},
native: {}
});
adapter.setObject(state_sv_rbatterycharge_v1_status.label, {
type: 'state',
common: {name: state_sv_rbatterycharge_v1_status[ioBroker_Language], type: 'string', read: true, write: false, role: 'value'},
native: {}
});
adapter.setState(state_sv_rbatterycharge_v1_status.label, {val: 'Disabled', ack: true});
adapter.setObject(state_sv_rbatterycharge_v1_eol.label, {
type: 'state',
common: {name: state_sv_rbatterycharge_v1_eol[ioBroker_Language], type: 'string', read: true, write: false, role: 'datetime'},
native: {}
});
return callback(true);
}
function CreateStates_Status(callback){
// creating channel/states for selectedVehicle Data
adapter.setObject(channel_s.label, {
type: 'channel',
common: {name: channel_s[ioBroker_Language]},
native: {}
});
adapter.setObject(state_s_lastConnectionTimeStamp.label, {
type: 'state',
common: {name: state_s_lastConnectionTimeStamp[ioBroker_Language], type: 'string', read: true, write: false, role: 'datetime'},
native: {}
});
adapter.setObject(state_s_distanceCovered.label, {
type: 'state',
common: {name: state_s_distanceCovered[ioBroker_Language], type: 'number', unit: 'km', read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_s_hybridRange.label, {
type: 'state',
common: {name: state_s_hybridRange[ioBroker_Language], type: 'number', unit: 'km', read: true, write: false, def: 0, role: 'value'},
native: {}
});
adapter.setObject(state_s_serviceInspectionDistance.label, {
type: 'state',
common: {name: state_s_serviceInspectionDistance[ioBroker_Language], type: 'number', unit: 'km', read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_s_serviceInspectionTime.label, {
type: 'state',
common: {name: state_s_serviceInspectionTime[ioBroker_Language], type: 'number', unit: state_s_serviceInspectionTime['unit_' + ioBroker_Language], read: true, write: false, def: 0, role: 'value'},
native: {}
});
adapter.setObject(state_s_adBlueInspectionDistance.label, {
type: 'state',
common: {name: state_s_adBlueInspectionDistance[ioBroker_Language], type: 'number', unit: 'km', read: true, write: false, def: 0, role: 'value'},
native: {}
});
adapter.setObject(state_s_oilInspectionDistance.label, {
type: 'state',
common: {name: state_s_oilInspectionDistance[ioBroker_Language], type: 'number', unit: 'km', read: true, write: false, def: 0, role: 'value'},
native: {}
});
adapter.setObject(state_s_oilInspectionTime.label, {
type: 'state',
common: {name: state_s_oilInspectionTime[ioBroker_Language], type: 'number', unit: state_s_oilInspectionTime['unit_' + ioBroker_Language], read: true, write: false, def: 0, role: 'value'},
native: {}
});
adapter.setObject(state_s_parkingLights.label, {
type: 'state',
common: {name: state_s_parkingLights[ioBroker_Language], type: "string", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_s_parkingBrake.label, {
type: 'state',
common: {name: state_s_parkingBrake[ioBroker_Language], type: "string", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_s_carCentralLock.label, {
type: 'state',
common: {name: state_s_carCentralLock[ioBroker_Language], type: "string", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_s_fuelType.label, {
type: 'state',
common: {name: state_s_fuelType[ioBroker_Language], type: 'string', read: true, write: false, def: '', role: 'value'},
native: {}
});
adapter.setObject(state_s_fuelLevel.label, {
type: 'state',
common: {name: state_s_fuelLevel[ioBroker_Language], type: "number", unit: "%", read: true, write: false, def: 0, role: 'value'},
native: {}
});
adapter.setObject(state_s_fuelRange.label, {
type: 'state',
common: {name: state_s_fuelRange[ioBroker_Language], type: "number", unit: "km", read: true, write: false, def: 0, role: 'value'},
native: {}
});
adapter.setObject(state_s_batteryLevel.label, {
type: 'state',
common: {name: state_s_batteryLevel[ioBroker_Language], type: "number", unit: "%", read: true, write: false, def: 0, role: 'value'},
native: {}
});
adapter.setObject(state_s_batteryRange.label, {
type: 'state',
common: {name: state_s_batteryRange[ioBroker_Language], type: "number", unit: "km", read: true, write: false, def: 0, role: 'value'},
native: {}
});
adapter.setObject(channel_dw_DoorsAndWindows.label, {
type: 'channel',
common: {name: channel_dw_DoorsAndWindows[ioBroker_Language]},
native: {}
});
adapter.setObject(state_dw_Doors.label, {
type: 'state',
common: {name: state_dw_Doors[ioBroker_Language], type: "string", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_dw_Windows.label, {
type: 'state',
common: {name: state_dw_Windows[ioBroker_Language], type: "string", read: true, write: false, role: 'value'},
native: {}
});
return callback(true);
}
function CreateStates_climater(callback){
if (VWCarNet_GetClimater === false){
return callback(true);
}
// creating channel/states for climater Data
adapter.setObject(channel_c.label, {
type: 'channel',
common: {name: channel_c[ioBroker_Language]},
native: {}
});
adapter.setObject(state_c_climatisationWithoutHVPower.label, {
type: 'state',
common: {name: state_c_climatisationWithoutHVPower[ioBroker_Language], type: "boolean", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_c_targetTemperature.label, {
type: 'state',
common: {name: state_c_targetTemperature[ioBroker_Language], type: "number", unit: "°C", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_c_heaterSource.label, {
type: 'state',
common: {name: state_c_heaterSource[ioBroker_Language], type: "string", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_c_climatisationReason.label, {
type: 'state',
common: {name: state_c_climatisationReason[ioBroker_Language], type: "string", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_c_windowHeatingStateFront.label, {
type: 'state',
common: {name: state_c_windowHeatingStateFront[ioBroker_Language], type: "string", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_c_windowHeatingStateRear.label, {
type: 'state',
common: {name: state_c_windowHeatingStateRear[ioBroker_Language], type: "string", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_c_outdoorTemperature.label, {
type: 'state',
common: {name: state_c_outdoorTemperature[ioBroker_Language], type: "number", unit: "°C", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_c_vehicleParkingClock.label, {
type: 'state',
common: {name: state_c_vehicleParkingClock[ioBroker_Language], type: 'string', read: true, write: false, role: 'datetime'},
native: {}
});
adapter.setObject(state_c_climatisationState.label, {
type: 'state',
common: {name: state_c_climatisationState[ioBroker_Language], type: "string", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_c_remainingClimatisationTime.label, {
type: 'state',
common: {name: state_c_remainingClimatisationTime[ioBroker_Language], type: "number", unit: "Min", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_c_climaterStart.label, {
type: 'state',
common: {name: state_c_climaterStart[ioBroker_Language], type: "boolean", read: false, write: true, role: 'button'},
native: {}
});
adapter.setObject(state_c_climaterStop.label, {
type: 'state',
common: {name: state_c_climaterStop[ioBroker_Language], type: "boolean", read: false, write: true, role: 'button'},
native: {}
});
adapter.setObject(state_c_windowheatStart.label, {
type: 'state',
common: {name: state_c_windowheatStart[ioBroker_Language], type: "boolean", read: false, write: true, role: 'button'},
native: {}
});
adapter.setObject(state_c_windowheatStop.label, {
type: 'state',
common: {name: state_c_windowheatStop[ioBroker_Language], type: "boolean", read: false, write: true, role: 'button'},
native: {}
});
return callback(true);
}
function CreateStates_eManager(callback){
if (VWCarNet_GetEManager === false){
return callback(true);
}
// creating channel/states for eManager Data
adapter.setObject(channel_e.label, {
type: 'channel',
common: {name: channel_e[ioBroker_Language]},
native: {}
});
adapter.setObject(state_e_stateOfCharge.label, {
type: 'state',
common: {name: state_e_stateOfCharge[ioBroker_Language], type: "number", unit: "%", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_e_remainingChargingTimeTargetSOC.label, {
type: 'state',
common: {name: state_e_remainingChargingTimeTargetSOC[ioBroker_Language], type: "number", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_e_chargingMode.label, {
type: 'state',
common: {name: state_e_chargingMode[ioBroker_Language], type: "string", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_e_chargingState.label, {
type: 'state',
common: {name: state_e_chargingState[ioBroker_Language], type: "string", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_e_chargingReason.label, {
type: 'state',
common: {name: state_e_chargingReason[ioBroker_Language], type: "string", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_e_remainingChargingTime.label, {
type: 'state',
common: {name: state_e_remainingChargingTime[ioBroker_Language], type: "string", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_e_maxChargeCurrent.label, {
type: 'state',
common: {name: state_e_maxChargeCurrent[ioBroker_Language], type: "number", unit: "A", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_e_plugState.label, {
type: 'state',
common: {name: state_e_plugState[ioBroker_Language], type: "string", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_e_lockState.label, {
type: 'state',
common: {name: state_e_lockState[ioBroker_Language], type: "string", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_e_extPowerSupplyState.label, {
type: 'state',
common: {name: state_e_extPowerSupplyState[ioBroker_Language], type: "string", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_e_chargerStart.label, {
type: 'state',
common: {name: state_e_chargerStart[ioBroker_Language], type: "boolean", read: false, write: true, role: 'button'},
native: {}
});
adapter.setObject(state_e_chargerStop.label, {
type: 'state',
common: {name: state_e_chargerStop[ioBroker_Language], type: "boolean", read: false, write: true, role: 'button'},
native: {}
});
return callback(true);
}
function CreateStates_location(callback){
if (VWCarNet_GetLocation === false){
return callback(true);
}
// creating channel/states for location Data
adapter.setObject(channel_l.label, {
type: 'channel',
common: {name: channel_l[ioBroker_Language]},
native: {}
});
adapter.setObject(state_l_lat.label, {
type: 'state',
common: {name: state_l_lat[ioBroker_Language], type: "number", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_l_lng.label, {
type: 'state',
common: {name: state_l_lng[ioBroker_Language], type: "number", read: true, write: false, role: 'value'},
native: {}
});
adapter.setObject(state_l_parkingTime.label, {
type: 'state',
common: {name: state_l_parkingTime[ioBroker_Language], type: "string", read: true, write: false, role: 'datetime'},
native: {}
});
if (myGoogleMapsAPIKey !== '') {
adapter.setObject(state_l_address.label, {
type: 'state',
common: {name: state_l_address[ioBroker_Language], type: "string", read: true, write: false, role: 'value'},
native: {}
});
}
return callback(true);
}
function readCarNetData() {
startUpdateProcess(4); // Es stehen vier Calls an
RetrieveVehicleData_Status(updateSuccessfulFlag);
RetrieveVehicleData_Location(updateSuccessfulFlag);
RetrieveVehicleData_eManager(updateSuccessfulFlag);
RetrieveVehicleData_Climater(updateSuccessfulFlag);
}
function isRequestOk(name, error, response, result) {
if (error) {
adapter.log.error('error at ' + name + ': ' + error);
return false;
}
var errorInfo = "";
switch(response.statusCode){
case 200:
case 202:
case 204:
return true;
case 401:
errorInfo = "Username or PW are incorrect =>" + JSON.stringify(response);
break;
case 504:
if (result !== null && typeof result == 'object') {
if (result.hasOwnProperty('error')) {
errorInfo = result.error;
if (result.hasOwnProperty('error_description')) {
errorInfo += ' - ' + result.error_description;
}
break;
}
}
default:
errorInfo = "=> " + JSON.stringify(response);
}
adapter.log.error(name + ": " + response.statusCode + " " + errorInfo);
return false;
}
// ############################################# start here! ###################################################
function main() {
adapter.subscribeStates('*.btn_');
CarNetLogon(function(myTmp){
VWCarNet_CredentialsAreValid=myTmp;
myCarNetDoors['FL']={'closed':false,'locked':true,'safe':false};
myCarNetDoors['RL']={'closed':false,'locked':true,'safe':false};
myCarNetDoors['FR']={'closed':false,'locked':true,'safe':false};
myCarNetDoors['RR']={'closed':false,'locked':true,'safe':false};
myCarNetDoors['hood']={'closed':false};
myCarNetDoors['rear']={'closed':false,'locked':false,};
delete myCarNetDoors['doors']; //remove dummy entry
myCarNetWindows['FL']={'closed':false, 'level':0};
myCarNetWindows['RL']={'closed':false, 'level':0};
myCarNetWindows['FR']={'closed':false, 'level':0};
myCarNetWindows['RR']={'closed':false, 'level':0};
myCarNetWindows['roof']={'closed':false, 'level':0};
delete myCarNetWindows['windows']; //remove dummy entry
//adapter.log.info('Credentials valid?: ' + VWCarNet_CredentialsAreValid);
if (VWCarNet_CredentialsAreValid){
//adapter.log.info('Credentials valid - starting adapter')
RetrieveVehicles(function(myTmp){
RetrieveVehicleData_VINValid(function(myTmp){
VWCarNet_VINIsValid=myTmp;
adapter.log.debug('VIN valid: ' + VWCarNet_VINIsValid);
VWCarNet_Connected = VWCarNet_CredentialsAreValid && VWCarNet_VINIsValid;
adapter.setState('connection', {val: VWCarNet_Connected, ack: true});
if(VWCarNet_VINIsValid){
adapter.setState(state_v_VIN.label, {val: myVIN, ack: true});
} else {
adapter.setState(state_v_VIN.label, {val: '', ack: true});
}
RetrieveVehicleData_operationList(function(myTmp){
if (VWCarNet_Connected){
readCarNetData();
}
});
//adapter.log.info('VW Car-Net connected?: ' + VWCarNet_Connected);
});
});
}
});
}
String.prototype.Capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
};
function VWCarNetReadData(){
CarNetLogon(function(myTmp){
VWCarNet_CredentialsAreValid=myTmp;
VWCarNet_Connected = VWCarNet_CredentialsAreValid && VWCarNet_VINIsValid;
adapter.log.debug('Credentials valid: ' + VWCarNet_CredentialsAreValid);
if (VWCarNet_Connected){
readCarNetData();
}
});
}
function VWCarNetForceCarToSendData(){
CarNetLogon(function(myTmp){
VWCarNet_CredentialsAreValid=myTmp;
VWCarNet_Connected = VWCarNet_CredentialsAreValid && VWCarNet_VINIsValid;
if (VWCarNet_Connected){
// startUpdateProcess(1); // Es steht ein Calls an
requestCarSendData2CarNet(dummyFunc /* updateSuccessfulFlag */);
}
});
}
function CarNetLogon(callback) { //retrieve Token for the respective user
var responseData;
var myUrl = 'https://msg.volkswagen.de/fs-car/core/auth/v1/'+ VWCarNet_Brand + '/'+ VWCarNet_Country + '/token';
var myFormdata = {'grant_type': 'password',
'username': adapter.config.email,
'password': adapter.config.password};
request.post({url: myUrl, form: myFormdata, headers: myHeaders, json: true}, function(error, response, result){
if (isRequestOk('CarNetLogin', error, response, result)) {
myAuthHeaders.Authorization = 'AudiAuth 1 ' + result.access_token;
myToken = result.access_token;
return callback(true);
} else {
callback(false); //connection to VW Car-Net not established
}
});
}
function RetrieveVehicles(callback){ //retrieve VIN of the first vehicle (Fahrgestellnummer)
var myVehicleID = 0;
var myUrl = 'https://msg.volkswagen.de/fs-car/usermanagement/users/v1/'+ VWCarNet_Brand + '/'+ VWCarNet_Country + '/vehicles';
if (VWCarNet_CredentialsAreValid===false){
return callback('not authenticated');
}
if (adapter.config.VIN === ''){
request.get({url: myUrl, headers: myAuthHeaders, json: true}, function (error, response, result){
adapter.log.debug('Retrieve vehicles: ' + JSON.stringify(result));
myVIN = result.userVehicles.vehicle[myVehicleID];
return callback('Count: ' + result.userVehicles.vehicle.length);
});
} else {
myVIN = adapter.config.VIN;
return callback('default');
}
}
function RetrieveVehicleData_VINValid(callback){
var myVINIsValid=false;
var myUrl = 'https://msg.volkswagen.de/fs-car/vehicleMgmt/vehicledata/v2/'+ VWCarNet_Brand + '/'+ VWCarNet_Country + '/vehicles/'+ myVIN;
request.get({url: myUrl, headers: myAuthHeaders, json: true}, function (error, response, result){
adapter.log.debug('Retrieve brand and country: ' + JSON.stringify(result));
try {
if(result.vehicleData.vin===myVIN){
myVINIsValid=true;
VWCarNet_Brand=result.vehicleData.brand;
VWCarNet_Country=result.vehicleData.country;
}
}
catch (ex) {
myVINIsValid=false;
}
return callback(myVINIsValid);
});
}
function RetrieveVehicleData_operationList(callback){
if (VWCarNet_Connected===false) { return callback(false); }
var myUrl;
var myService = 0;
//######### Request Operations
myUrl = 'https://msg.volkswagen.de/fs-car/rolesrights/operationlist/v2/'+ VWCarNet_Brand + '/'+ VWCarNet_Country + '/vehicles/' + myVIN + '/operations'; //Möglichkeiten von Carnet für entsprechendes FZ abrufen
request.get({url: myUrl, headers: myAuthHeaders, json: true}, function (error, response, result) {
if (isRequestOk('RequestOperations', error, response, result)) {
adapter.log.debug('Retrieve operations: ' + JSON.stringify(result));
var myOperations = result.operationList.serviceInfo;
for (myService in myOperations){
switch(myOperations[myService].serviceId){
case 'statusreport_v1':
//adapter.log.info(myOperations[myService].serviceId);
adapter.setState(state_sv_statusreport_v1_status.label, {val: myOperations[myService].serviceStatus.status, ack: true});
adapter.setState(state_sv_statusreport_v1_eol.label, {val: myOperations[myService].cumulatedLicenseV2.expirationDate, ack: true});
VWCarNet_GetStatus = (myOperations[myService].serviceStatus.status === 'Enabled');
break;
case 'rclima_v1':
//adapter.log.info(myOperations[myService].serviceId);
adapter.setState(state_sv_rclima_v1_status.label, {val: myOperations[myService].serviceStatus.status, ack: true});
adapter.setState(state_sv_rclima_v1_eol.label, {val: myOperations[myService].cumulatedLicenseV2.expirationDate, ack: true});
VWCarNet_GetClimater = adapter.config.adapterGetClimater && (myOperations[myService].serviceStatus.status === 'Enabled');
break;
case 'rbatterycharge_v1':
//adapter.log.info(myOperations[myService].serviceId)
adapter.setState(state_sv_rbatterycharge_v1_status.label, {val: myOperations[myService].serviceStatus.status, ack: true});
adapter.setState(state_sv_rbatterycharge_v1_eol.label, {val: myOperations[myService].cumulatedLicenseV2.expirationDate, ack: true});
VWCarNet_GetEManager = adapter.config.adapterGetEManager && (myOperations[myService].serviceStatus.status === 'Enabled');
break;
case 'carfinder_v1':
//adapter.log.info(myOperations[myService].serviceId)
adapter.setState(state_sv_carfinder_v1_status.label, {val: myOperations[myService].serviceStatus.status, ack: true});
adapter.setState(state_sv_carfinder_v1_eol.label, {val: myOperations[myService].cumulatedLicenseV2.expirationDate, ack: true});
VWCarNet_GetLocation = adapter.config.adapterGetLocation && (myOperations[myService].serviceStatus.status === 'Enabled');
break;
default:
}
}
return callback(true);
} else {
return callback(false);
}
});
}
function RetrieveVehicleData_Status(callback){
if (VWCarNet_GetStatus === false) { return callback(true); }
if (VWCarNet_Connected===false) { return callback(false); }
var myData = 0;
var myField = 0;
var myReceivedDataKey;
var myParkingLight;
var myUrl = 'https://msg.volkswagen.de/fs-car/bs/vsr/v1/'+ VWCarNet_Brand + '/'+ VWCarNet_Country + '/vehicles/' + myVIN + '/status';
try{
request.get({url: myUrl, headers: myAuthHeaders, json: true}, function (error, response, result) {
if (isRequestOk('getStatus', error, response, result)) {
if (result.error !== undefined) {
adapter.log.error('Error while retrieving status: ' + JSON.stringify(result.error));
return callback(false);
}
result.StoredVehicleDataResponse.vin = 'ANONYMIZED_VIN_FOR_LOGGING';
adapter.log.debug('Retrieve status: ' + JSON.stringify(result));
var vehicleData = result.StoredVehicleDataResponse.vehicleData;
adapter.setState(state_s_lastConnectionTimeStamp.label, {val: vehicleData.data[myData].field[myField].tsCarSentUtc, ack: true});
var vdj = JSON.stringify(vehicleData.data);
for (myData in vehicleData.data) {
for (myField in vehicleData.data[myData].field) {
myReceivedDataKey = vehicleData.data[myData].field[myField];
switch(vehicleData.data[myData].id + "." + vehicleData.data[myData].field[myField].id){
case '0x0101010002.0x0101010002': //distanceCovered
adapter.setState(state_s_distanceCovered.label, {val: myReceivedDataKey.value, ack: true});
break;
case '0x0204FFFFFF.0x02040C0001': //adBlueInspectionData_km
adapter.setState(state_s_adBlueInspectionDistance.label, {val: myReceivedDataKey.value, ack: true});
break;
case '0x0203FFFFFF.0x0203010001': //oilInspectionData_km
adapter.setState(state_s_oilInspectionDistance.label, {val: myReceivedDataKey.value *-1, ack: true});
break;
case '0x0203FFFFFF.0x0203010002': //oilInspectionData_days
adapter.setState(state_s_oilInspectionTime.label, {val: myReceivedDataKey.value *-1, ack: true});
break;
case '0x0203FFFFFF.0x0203010003': //serviceInspectionData_km
adapter.setState(state_s_serviceInspectionDistance.label, {val: myReceivedDataKey.value * -1, ack: true});
break;
case '0x0203FFFFFF.0x0203010004': //serviceInspectionData_days
adapter.setState(state_s_serviceInspectionTime.label, {val: myReceivedDataKey.value *-1, ack: true});
break;
case '0x030101FFFF.0x0301010001': //status_parking_light_off
myParkingLight = myReceivedDataKey.value;
break;
case '0x030103FFFF.0x0301030001': //parking brake
adapter.setState(state_s_parkingBrake.label, {val: 'textId' in myReceivedDataKey ? myReceivedDataKey.textId : myReceivedDataKey.value, ack: true});
break;
case '0x030103FFFF.0x0301030007': //fuel type
adapter.setState(state_s_fuelType.label, {val: 'textId' in myReceivedDataKey ? myReceivedDataKey.textId.replace('engine_type_','').replace('unsupported','-').Capitalize() : myReceivedDataKey.value, ack: true});
break;
case '0x030103FFFF.0x030103000A': //fuel level
adapter.setState(state_s_fuelLevel.label, {val: myReceivedDataKey.value, ack: true});
break;
case '0x030103FFFF.0x0301030006': //fuel range
adapter.setState(state_s_fuelRange.label, {val: 'value' in myReceivedDataKey ? myReceivedDataKey.value * 1 : 0, ack: true});
break;
case '0x030103FFFF.0x0301030009': //secondary_typ - erst ab Modelljahr 2018
var secondaryType = 'textId' in myReceivedDataKey ? myReceivedDataKey.textId.replace('engine_type_','').replace('unsupported','-').Capitalize() : myReceivedDataKey.value;
break;
case '0x030103FFFF.0x0301030002': //soc_ok
adapter.setState(state_s_batteryLevel.label, {val: myReceivedDataKey.value, ack: true});
break;
case '0x030103FFFF.0x0301030008': //secondary_range - erst ab Modelljahr 2018
adapter.setState(state_s_batteryRange.label, {val: 'value' in myReceivedDataKey ? myReceivedDataKey.value * 1 : 0, ack: true});
break;
case '0x030103FFFF.0x0301030005': //hybrid_range - erst ab Modelljahr 2018
adapter.setState(state_s_hybridRange.label, {val: myReceivedDataKey.value, ack: true});
break;
//door1 - front/left
case '0x030104FFFF.0x0301040001':
myCarNetDoors.FL.locked = myReceivedDataKey.value === '2';
break;
case '0x030104FFFF.0x0301040002':
myCarNetDoors.FL.closed = myReceivedDataKey.value === '3';
break;
case '0x030104FFFF.0x0301040003':
myCarNetDoors.FL.safe = myReceivedDataKey.value === '2';
break;
//door2 - rear/left
case '0x030104FFFF.0x0301040004':
myCarNetDoors.RL.locked = myReceivedDataKey.value === '2';
break;
case '0x030104FFFF.0x0301040005':
myCarNetDoors.RL.closed = myReceivedDataKey.value === '3';
break;
case '0x030104FFFF.0x0301040006':
myCarNetDoors.RL.safe = myReceivedDataKey.value === '2';
break;
//door3 - front/right
case '0x030104FFFF.0x0301040007':
myCarNetDoors.FR.locked = myReceivedDataKey.value === '2';
break;
case '0x030104FFFF.0x0301040008':
myCarNetDoors.FR.closed = myReceivedDataKey.value === '3';
break;
case '0x030104FFFF.0x0301040009':
myCarNetDoors.FR.safe = myReceivedDataKey.value === '2';
break;
//door4 - rear/right
case '0x030104FFFF.0x030104000A':
myCarNetDoors.RR.locked = myReceivedDataKey.value === '2';
break;
case '0x030104FFFF.0x030104000B':
myCarNetDoors.RR.closed = myReceivedDataKey.value === '3';
break;
case '0x030104FFFF.0x030104000C':
myCarNetDoors.RR.safe = myReceivedDataKey.value === '2';
break;
//door5 - rear
case '0x030104FFFF.0x030104000D':
myCarNetDoors.rear.locked = myReceivedDataKey.value === '2';
break;
case '0x030104FFFF.0x030104000E':
myCarNetDoors.rear.closed = myReceivedDataKey.value === '3';
break;
case '0x030104FFFF.0x030104000F':
//myCarNetDoors.rear.safe = myReceivedDataKey.value === '2';
break;
//door6 - hood
case '0x030104FFFF.0x0301040010':
//myCarNetDoors.hood.locked = myReceivedDataKey.value === '2';
break;