homebridge-bluelink-3-0 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/.kodiak.toml +4 -0
  2. package/LICENSE +176 -0
  3. package/README.md +73 -0
  4. package/config.schema.json +105 -0
  5. package/dist/index.d.ts +7 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +7 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/platform.d.ts +23 -0
  10. package/dist/platform.d.ts.map +1 -0
  11. package/dist/platform.js +126 -0
  12. package/dist/platform.js.map +1 -0
  13. package/dist/platformAccessory.d.ts +14 -0
  14. package/dist/platformAccessory.d.ts.map +1 -0
  15. package/dist/platformAccessory.js +50 -0
  16. package/dist/platformAccessory.js.map +1 -0
  17. package/dist/services/base.d.ts +25 -0
  18. package/dist/services/base.d.ts.map +1 -0
  19. package/dist/services/base.js +46 -0
  20. package/dist/services/base.js.map +1 -0
  21. package/dist/services/ignition.d.ts +15 -0
  22. package/dist/services/ignition.d.ts.map +1 -0
  23. package/dist/services/ignition.js +78 -0
  24. package/dist/services/ignition.js.map +1 -0
  25. package/dist/services/index.d.ts +3 -0
  26. package/dist/services/index.d.ts.map +1 -0
  27. package/dist/services/index.js +11 -0
  28. package/dist/services/index.js.map +1 -0
  29. package/dist/services/lock.d.ts +17 -0
  30. package/dist/services/lock.d.ts.map +1 -0
  31. package/dist/services/lock.js +99 -0
  32. package/dist/services/lock.js.map +1 -0
  33. package/dist/services/motor.d.ts +17 -0
  34. package/dist/services/motor.d.ts.map +1 -0
  35. package/dist/services/motor.js +72 -0
  36. package/dist/services/motor.js.map +1 -0
  37. package/dist/services/usCommandClient.d.ts +19 -0
  38. package/dist/services/usCommandClient.d.ts.map +1 -0
  39. package/dist/services/usCommandClient.js +197 -0
  40. package/dist/services/usCommandClient.js.map +1 -0
  41. package/dist/settings.d.ts +9 -0
  42. package/dist/settings.d.ts.map +1 -0
  43. package/dist/settings.js +12 -0
  44. package/dist/settings.js.map +1 -0
  45. package/package.json +76 -0
package/.kodiak.toml ADDED
@@ -0,0 +1,4 @@
1
+ # .kodiak.toml
2
+ # Minimal config. version is the only required field.
3
+ version = 1
4
+ merge.automerge_label = "dependencies"
package/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # Homebridge Hyundai Bluelink
2
+
3
+ [![npm version](https://badge.fury.io/js/homebridge-bluelink-3-0.svg)](https://badge.fury.io/js/homebridge-bluelink-3-0)
4
+ ![Build Status)](https://img.shields.io/github/workflow/status/cnpittman/homebridge-bluelink-3.0/build/main)
5
+
6
+ This is a [Homebridge](https://homebridge.io) platform plugin that uses [bluelinky](https://github.com/Hacksore/bluelinky) to connect your Hyundai or Kia vehicle to HomeKit, which allows you control your vehicle using Siri, shortcuts, or the Home app.
7
+
8
+ This is a maintained fork of [athal7/homebridge-hyundai-bluelink](https://github.com/athal7/homebridge-hyundai-bluelink), published as `homebridge-bluelink-3-0`.
9
+
10
+ ## Installation
11
+
12
+ This plugin can be installed from the Homebridge web console:
13
+ 1. Log in to the console and go to the `Plugins` tab
14
+ 2. Search for `homebridge-bluelink-3-0` and install it
15
+ 3. Edit the settings in the UI, or directly in the `config.json` file following the schema below
16
+
17
+ ## Configuration
18
+
19
+ ### Sample
20
+
21
+ ```json
22
+ "platforms": [
23
+ {
24
+ "credentials": {
25
+ "username": "your username / email",
26
+ "password": "your password",
27
+ "region": "US / CA / EU",
28
+ "brand": "Hyundai / Kia",
29
+ "pin": "your pin"
30
+ },
31
+ "vehicles": [
32
+ {
33
+ "vin": "your VIN",
34
+ "maxRange": 500
35
+ }
36
+ ],
37
+ "remoteStart": {
38
+ "airCtrl": false,
39
+ "heating1": false,
40
+ "defrost": false,
41
+ "airTempvalue": 72,
42
+ "igniOnDuration": 10
43
+ },
44
+ "platform": "Hyundai"
45
+ }
46
+ ],
47
+ ```
48
+
49
+ ### Notes
50
+ * `vehicles.maxRange` is optional
51
+ * `remoteStart.airCtrl` controls whether the HVAC is turned on
52
+ * `remoteStart.airTempvalue` is the temperature in Fahrenheit
53
+ * `remoteStart.igniOnDuration` must be between 1 and 10, otherwise remote start will fail
54
+
55
+ ## Known Issues
56
+
57
+ ### SSL Key too Small
58
+
59
+ Log:
60
+
61
+ ```
62
+ [Hyundai] Client Error GotError [RequestError]: write EPROTO 1995553232:error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small:../deps/openssl/openssl/ssl/statem/statem_clnt.c:2158:
63
+ ```
64
+
65
+ This happens because the Bluelink API used has insecure SSL settings.
66
+
67
+ Workaround: Edit `/etc/ssl/openssl.cnf`, change the line `CipherString = DEFAULT@SECLEVEL=2` to `CipherString = DEFAULT@SECLEVEL=1` (change 2 to 1 at end of line)
68
+
69
+ Source: https://github.com/FreshRSS/FreshRSS/issues/3029
70
+
71
+ ### Status Refresh Delay
72
+
73
+ Due to Hyundai's [API Rate Limits](https://github.com/Hacksore/bluelinky/wiki/API-Rate-Limits), the car status (locked, on/off, range) is only updated once per hour. Actions taken from homebridge get automatically refreshed, but actions taken elsewhere (e.g. bluelink app, key fab) may not display in homebridge for up to an hour.
@@ -0,0 +1,105 @@
1
+ {
2
+ "pluginAlias": "Hyundai",
3
+ "pluginType": "platform",
4
+ "singular": true,
5
+ "schema": {
6
+ "type": "object",
7
+ "properties": {
8
+ "credentials": {
9
+ "type": "object",
10
+ "properties": {
11
+ "username": {
12
+ "title": "Username",
13
+ "type": "string",
14
+ "required": true
15
+ },
16
+ "password": {
17
+ "title": "Password",
18
+ "type": "string",
19
+ "required": true
20
+ },
21
+ "region": {
22
+ "title": "Region",
23
+ "type": "string",
24
+ "required": true,
25
+ "placeholder": "US",
26
+ "oneOf": [
27
+ { "title": "United States", "enum": ["US"] },
28
+ { "title": "Canada", "enum": ["CA"] },
29
+ { "title": "Europe", "enum": ["EU"] }
30
+ ]
31
+ },
32
+ "brand": {
33
+ "title": "Brand",
34
+ "type": "string",
35
+ "required": true,
36
+ "default": "hyundai",
37
+ "oneOf": [
38
+ { "title": "Hyundai", "enum": ["hyundai"] },
39
+ { "title": "Kia", "enum": ["kia"] }
40
+ ]
41
+ },
42
+ "pin": {
43
+ "title": "Pin",
44
+ "type": "string",
45
+ "placeholder": "1234",
46
+ "required": true
47
+ }
48
+ }
49
+ },
50
+ "vehicles": {
51
+ "type": "array",
52
+ "items": {
53
+ "type": "object",
54
+ "properties": {
55
+ "vin": {
56
+ "title": "VIN Number",
57
+ "type": "string",
58
+ "required": true
59
+ },
60
+ "maxRange": {
61
+ "type": "number",
62
+ "title": "Maximum Range (mi/km)",
63
+ "required": false
64
+ }
65
+ }
66
+ }
67
+ },
68
+ "remoteStart": {
69
+ "type": "object",
70
+ "properties": {
71
+ "airCtrl": {
72
+ "type": "boolean",
73
+ "title": "Turn on A/C",
74
+ "required": false,
75
+ "default": false
76
+ },
77
+ "heating1": {
78
+ "type": "boolean",
79
+ "title": "Turn on Heat",
80
+ "required": false,
81
+ "default": false
82
+ },
83
+ "defrost": {
84
+ "type": "boolean",
85
+ "title": "Defrost",
86
+ "required": false,
87
+ "default": false
88
+ },
89
+ "airTempvalue": {
90
+ "type": "number",
91
+ "title": "Desired temperature",
92
+ "required": false,
93
+ "placeholder": 72
94
+ },
95
+ "igniOnDuration": {
96
+ "type": "number",
97
+ "title": "How long (minutes)",
98
+ "required": true,
99
+ "default": 15
100
+ }
101
+ }
102
+ }
103
+ }
104
+ }
105
+ }
@@ -0,0 +1,7 @@
1
+ import { API } from 'homebridge';
2
+ /**
3
+ * This method registers the platform with Homebridge
4
+ */
5
+ declare const _default: (api: API) => void;
6
+ export = _default;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAKjC;;GAEG;yBACO,KAAK,GAAG,KAAG,IAAI;AAAzB,kBAEE"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ const settings_1 = require("./settings");
3
+ const platform_1 = require("./platform");
4
+ module.exports = (api) => {
5
+ api.registerPlatform(settings_1.PLATFORM_NAME, platform_1.HyundaiPlatform);
6
+ };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,yCAA2C;AAC3C,yCAA6C;AAK7C,iBAAS,CAAC,GAAQ,EAAQ,EAAE;IAC1B,GAAG,CAAC,gBAAgB,CAAC,wBAAa,EAAE,0BAAe,CAAC,CAAC;AACvD,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { API, DynamicPlatformPlugin, Logger, PlatformAccessory, PlatformConfig, Service, Characteristic } from 'homebridge';
2
+ import { HyundaiConfig } from './config';
3
+ export declare class HyundaiPlatform implements DynamicPlatformPlugin {
4
+ readonly log: Logger;
5
+ readonly api: API;
6
+ readonly Service: typeof Service;
7
+ readonly Characteristic: typeof Characteristic;
8
+ readonly config: HyundaiConfig;
9
+ readonly accessories: PlatformAccessory[];
10
+ constructor(log: Logger, config: PlatformConfig, api: API);
11
+ /**
12
+ * This function is invoked when homebridge restores cached accessories from disk at startup.
13
+ * It should be used to setup event handlers for characteristics and update respective values.
14
+ */
15
+ configureAccessory(accessory: PlatformAccessory): void;
16
+ /**
17
+ * This is an example method showing how to register discovered accessories.
18
+ * Accessories must only be registered once, previously created accessories
19
+ * must not be registered again to prevent "duplicate UUID" errors.
20
+ */
21
+ discoverDevices(): void;
22
+ }
23
+ //# sourceMappingURL=platform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,qBAAqB,EACrB,MAAM,EACN,iBAAiB,EACjB,cAAc,EACd,OAAO,EACP,cAAc,EACf,MAAM,YAAY,CAAC;AAKpB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,qBAAa,eAAgB,YAAW,qBAAqB;aASzC,GAAG,EAAE,MAAM;aAEX,GAAG,EAAE,GAAG;IAV1B,SAAgB,OAAO,EAAE,OAAO,OAAO,CAAC;IACxC,SAAgB,cAAc,EAAE,OAAO,cAAc,CAAC;IAGtD,SAAgB,MAAM,EAAE,aAAa,CAAC;IACtC,SAAgB,WAAW,EAAE,iBAAiB,EAAE,CAAM;gBAGpC,GAAG,EAAE,MAAM,EAC3B,MAAM,EAAE,cAAc,EACN,GAAG,EAAE,GAAG;IAoB1B;;;OAGG;IACH,kBAAkB,CAAC,SAAS,EAAE,iBAAiB,GAAG,IAAI;IAOtD;;;;OAIG;IACH,eAAe,IAAI,IAAI;CA4FxB"}
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.HyundaiPlatform = void 0;
7
+ const bluelinky_1 = __importDefault(require("bluelinky"));
8
+ const settings_1 = require("./settings");
9
+ const platformAccessory_1 = require("./platformAccessory");
10
+ class HyundaiPlatform {
11
+ log;
12
+ api;
13
+ Service;
14
+ Characteristic;
15
+ // this is used to track restored cached accessories
16
+ config;
17
+ accessories = [];
18
+ constructor(log, config, api) {
19
+ this.log = log;
20
+ this.api = api;
21
+ this.Service = this.api.hap.Service;
22
+ this.Characteristic = this.api.hap.Characteristic;
23
+ this.config = config;
24
+ // When this event is fired it means Homebridge has restored all cached accessories from disk.
25
+ // Dynamic Platform plugins should only register new accessories after this event was fired,
26
+ // in order to ensure they weren't added to homebridge already. This event can also be used
27
+ // to start discovery of new accessories.
28
+ this.api.on('didFinishLaunching', () => {
29
+ log.debug('Executed didFinishLaunching callback');
30
+ // run the method to discover / register your devices as accessories
31
+ try {
32
+ this.discoverDevices();
33
+ }
34
+ catch (e) {
35
+ log.error('discoverDevices Error', e);
36
+ }
37
+ });
38
+ }
39
+ /**
40
+ * This function is invoked when homebridge restores cached accessories from disk at startup.
41
+ * It should be used to setup event handlers for characteristics and update respective values.
42
+ */
43
+ configureAccessory(accessory) {
44
+ this.log.info('Loading accessory from cache:', accessory.displayName);
45
+ // add the restored accessory to the accessories cache so we can track if it has already been registered
46
+ this.accessories.push(accessory);
47
+ }
48
+ /**
49
+ * This is an example method showing how to register discovered accessories.
50
+ * Accessories must only be registered once, previously created accessories
51
+ * must not be registered again to prevent "duplicate UUID" errors.
52
+ */
53
+ discoverDevices() {
54
+ this.log.debug('Hyundai config:', this.config);
55
+ const client = new bluelinky_1.default(this.config.credentials);
56
+ client.on('ready', async () => {
57
+ this.log.debug('Client Ready');
58
+ for (const { vin, maxRange } of this.config.vehicles) {
59
+ const uuid = this.api.hap.uuid.generate(vin);
60
+ const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
61
+ this.log.debug('Fetching vehicle:', vin);
62
+ const vehicle = client.getVehicle(vin);
63
+ this.log.debug('Vehicle found', vehicle?.vehicleConfig);
64
+ if (existingAccessory) {
65
+ // the accessory already exists
66
+ if (vehicle) {
67
+ this.log.info('Restoring existing accessory from cache:', existingAccessory.displayName);
68
+ // if you need to update the accessory.context then you should run `api.updatePlatformAccessories`. eg.:
69
+ // existingAccessory.context.device = device;
70
+ // this.api.updatePlatformAccessories([existingAccessory]);
71
+ existingAccessory.context.device = vehicle.vehicleConfig;
72
+ existingAccessory.context.device.maxRange = maxRange;
73
+ // create the accessory handler for the restored accessory
74
+ // this is imported from `platformAccessory.ts`
75
+ new platformAccessory_1.VehicleAccessory(this, existingAccessory, vehicle);
76
+ // update accessory cache with any changes to the accessory details and information
77
+ this.api.updatePlatformAccessories([existingAccessory]);
78
+ }
79
+ else if (!vehicle) {
80
+ // it is possible to remove platform accessories at any time using `api.unregisterPlatformAccessories`, eg.:
81
+ // remove platform accessories when no longer present
82
+ this.api.unregisterPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [
83
+ existingAccessory,
84
+ ]);
85
+ this.log.info('Removing existing accessory from cache:', existingAccessory.displayName);
86
+ }
87
+ }
88
+ else {
89
+ if (!vehicle) {
90
+ this.log.warn('Vehicle not found', vin);
91
+ continue;
92
+ }
93
+ // the accessory does not yet exist, so we need to create it
94
+ this.log.info('Adding new accessory:', vehicle.nickname());
95
+ // create a new accessory
96
+ const accessory = new this.api.platformAccessory(vehicle.nickname(), uuid);
97
+ // store a copy of the device object in the `accessory.context`
98
+ // the `context` property can be used to store any data about the accessory you may need
99
+ accessory.context.device = vehicle.vehicleConfig;
100
+ accessory.context.device.maxRange = maxRange;
101
+ // create the accessory handler for the newly create accessory
102
+ // this is imported from `platformAccessory.ts`
103
+ new platformAccessory_1.VehicleAccessory(this, accessory, vehicle);
104
+ // link the accessory to your platform
105
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [
106
+ accessory,
107
+ ]);
108
+ }
109
+ }
110
+ });
111
+ client.on('error', async (err) => {
112
+ this.log.error('Client Error', err);
113
+ });
114
+ const uuids = this.config.vehicles?.map(({ vin }) => this.api.hap.uuid.generate(vin));
115
+ for (const accessory of this.accessories) {
116
+ if (!uuids?.includes(accessory.UUID)) {
117
+ this.api.unregisterPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [
118
+ accessory,
119
+ ]);
120
+ this.log.info('Removing existing accessory from cache:', accessory.displayName);
121
+ }
122
+ }
123
+ }
124
+ }
125
+ exports.HyundaiPlatform = HyundaiPlatform;
126
+ //# sourceMappingURL=platform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";;;;;;AASA,0DAAkC;AAElC,yCAAwD;AACxD,2DAAuD;AAGvD,MAAa,eAAe;IASR;IAEA;IAVF,OAAO,CAAiB;IACxB,cAAc,CAAwB;IAEtD,oDAAoD;IACpC,MAAM,CAAgB;IACtB,WAAW,GAAwB,EAAE,CAAC;IAEtD,YACkB,GAAW,EAC3B,MAAsB,EACN,GAAQ;QAFR,QAAG,GAAH,GAAG,CAAQ;QAEX,QAAG,GAAH,GAAG,CAAK;QAExB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC;QACpC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC;QAClD,IAAI,CAAC,MAAM,GAAkB,MAAM,CAAC;QACpC,8FAA8F;QAC9F,4FAA4F;QAC5F,2FAA2F;QAC3F,yCAAyC;QACzC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,oBAAoB,EAAE,GA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gBACH,IAAI,CAAC,GAAG,CAAC,IAAI,CACX,yCAAyC,EACzC,SAAS,CAAC,WAAW,CACtB,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA3ID,0CA2IC"}
@@ -0,0 +1,14 @@
1
+ import { Vehicle } from 'bluelinky/dist/vehicles/vehicle';
2
+ import { EventEmitter } from 'events';
3
+ import { PlatformAccessory } from 'homebridge';
4
+ import { HyundaiPlatform } from './platform';
5
+ export declare class VehicleAccessory extends EventEmitter {
6
+ readonly platform: HyundaiPlatform;
7
+ readonly accessory: PlatformAccessory;
8
+ readonly vehicle: Vehicle;
9
+ private isFetching;
10
+ constructor(platform: HyundaiPlatform, accessory: PlatformAccessory, vehicle: Vehicle);
11
+ fetchStatus(force?: boolean): void;
12
+ setInformation(): void;
13
+ }
14
+ //# sourceMappingURL=platformAccessory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platformAccessory.d.ts","sourceRoot":"","sources":["../src/platformAccessory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAK7C,qBAAa,gBAAiB,SAAQ,YAAY;aAG9B,QAAQ,EAAE,eAAe;aACzB,SAAS,EAAE,iBAAiB;aAC5B,OAAO,EAAE,OAAO;IAJlC,OAAO,CAAC,UAAU,CAAS;gBAET,QAAQ,EAAE,eAAe,EACzB,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE,OAAO;IASlC,WAAW,CAAC,KAAK,UAAQ,GAAG,IAAI;IAiBhC,cAAc,IAAI,IAAI;CAavB"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.VehicleAccessory = void 0;
7
+ const events_1 = require("events");
8
+ const services_1 = __importDefault(require("./services"));
9
+ const REFRESH_INTERVAL = 1000 * 60 * 60; // once per hour, per https://github.com/Hacksore/bluelinky/wiki/API-Rate-Limits
10
+ class VehicleAccessory extends events_1.EventEmitter {
11
+ platform;
12
+ accessory;
13
+ vehicle;
14
+ isFetching = false;
15
+ constructor(platform, accessory, vehicle) {
16
+ super();
17
+ this.platform = platform;
18
+ this.accessory = accessory;
19
+ this.vehicle = vehicle;
20
+ this.setInformation();
21
+ (0, services_1.default)(this);
22
+ this.fetchStatus();
23
+ setInterval(this.fetchStatus.bind(this), REFRESH_INTERVAL);
24
+ }
25
+ fetchStatus(force = false) {
26
+ if (!this.isFetching) {
27
+ this.isFetching = true;
28
+ this.vehicle
29
+ .status({ refresh: force, parsed: true })
30
+ .then(response => {
31
+ this.platform.log.debug('Received status update', response);
32
+ this.emit('update', response);
33
+ this.isFetching = false;
34
+ })
35
+ .catch(error => {
36
+ this.platform.log.error('Status fetch error', error);
37
+ this.isFetching = false;
38
+ });
39
+ }
40
+ }
41
+ setInformation() {
42
+ this.accessory
43
+ ?.getService(this.platform.Service.AccessoryInformation)
44
+ ?.setCharacteristic(this.platform.Characteristic.Manufacturer, 'Hyundai')
45
+ .setCharacteristic(this.platform.Characteristic.Model, this.accessory.context.device.name)
46
+ .setCharacteristic(this.platform.Characteristic.SerialNumber, this.accessory.context.device.vin);
47
+ }
48
+ }
49
+ exports.VehicleAccessory = VehicleAccessory;
50
+ //# sourceMappingURL=platformAccessory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platformAccessory.js","sourceRoot":"","sources":["../src/platformAccessory.ts"],"names":[],"mappings":";;;;;;AAEA,mCAAsC;AAItC,0DAAsC;AAEtC,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,gFAAgF;AAEzH,MAAa,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,QAAQ,CAAC,OAAO,CAAC,oBAAoB,CAAC;YACxD,EAAE,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,YAAY,EAAE,SAAS,CAAC;aACxE,iBAAiB,CAChB,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,EAClC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CACnC;aACA,iBAAiB,CAChB,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,YAAY,EACzC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAClC,CAAC;IACN,CAAC;CACF;AA5CD,4CA4CC"}
@@ -0,0 +1,25 @@
1
+ import { VehicleStatus } from 'bluelinky/dist/interfaces/common.interfaces';
2
+ import { Vehicle } from 'bluelinky/dist/vehicles/vehicle';
3
+ import { Characteristic, Logger, PlatformAccessory, Service } from 'homebridge';
4
+ import { HyundaiConfig } from '../config';
5
+ import { HyundaiPlatform } from '../platform';
6
+ import { VehicleAccessory } from '../platformAccessory';
7
+ import { UsCommandClient } from './usCommandClient';
8
+ export declare abstract class HyundaiService {
9
+ protected readonly va: VehicleAccessory;
10
+ protected readonly accessory: PlatformAccessory;
11
+ protected readonly vehicle: Vehicle;
12
+ protected readonly platform: HyundaiPlatform;
13
+ protected readonly Characteristic: typeof Characteristic;
14
+ protected readonly log: Logger;
15
+ protected readonly config: HyundaiConfig;
16
+ private _usCommandClient?;
17
+ constructor(va: VehicleAccessory);
18
+ protected get usCommandClient(): UsCommandClient | undefined;
19
+ protected get service(): Service;
20
+ abstract name: string;
21
+ abstract serviceType: string;
22
+ abstract initService(): void;
23
+ abstract setCurrentState(status: VehicleStatus): void;
24
+ }
25
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/services/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6CA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