@homebridge-plugins/homebridge-tado 7.5.2 → 7.6.0

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## v7.6.0 - 2025-04-24
4
+ - Fixed crash on telegram event (#164)
5
+ - Rewrote Tado-Platform as ES6 class
6
+ - Updated dependencies
7
+
8
+ ## v7.5.3 - 2025-03-27
9
+ - Fixed crash on startup for node 20 (unexpected token 'with')
10
+
3
11
  ## v7.5.2 - 2025-03-27
4
12
  - Update plugin name to homebridge tado
5
13
 
package/README.md CHANGED
@@ -10,11 +10,10 @@
10
10
  [![verified-by-homebridge](https://badgen.net/badge/homebridge/verified/purple)](https://github.com/homebridge/homebridge/wiki/Verified-Plugins)
11
11
  [![Donate](https://img.shields.io/badge/Buy%20Me%20a%20Coffee-ffdd00?&logo=buy-me-a-coffee&logoColor=black)](https://buymeacoffee.com/smart7324)
12
12
 
13
- ## Fork
13
+ ## Info
14
14
 
15
- This plugin is originally created by [Sedyx](https://github.com/seydx/). Donate to him: [![Donate](https://img.shields.io/badge/Donate-PayPal-blue.svg?style=flat-square&maxAge=2592000)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NP4T3KASWQLD8)
15
+ This plugin has originally been created by [Seydx](https://github.com/seydx/). Donate to him: [![Donate](https://img.shields.io/badge/Donate-PayPal-blue.svg?style=flat-square&maxAge=2592000)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NP4T3KASWQLD8)
16
16
 
17
- ## Info
18
17
 
19
18
  **Homebridge Tado** is possibly the biggest homebridge plugin for Tado devices.
20
19
 
package/index.js CHANGED
@@ -6,9 +6,8 @@
6
6
  *
7
7
  **/
8
8
 
9
- import TadoPlatformModule from './src/platform.js';
9
+ import TadoPlatform from './src/platform.js';
10
10
 
11
11
  export default function (homebridge) {
12
- const TadoPlatform = TadoPlatformModule(homebridge);
13
- homebridge.registerPlatform('TadoPlatform', TadoPlatform);
12
+ homebridge.registerPlatform('TadoPlatform', TadoPlatform(homebridge));
14
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebridge-plugins/homebridge-tado",
3
- "version": "7.5.2",
3
+ "version": "7.6.0",
4
4
  "description": "Homebridge plugin for controlling tado° devices.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -32,23 +32,23 @@
32
32
  "homebridge": "^1.6.0||^2.0.0-beta.0"
33
33
  },
34
34
  "dependencies": {
35
- "@homebridge/plugin-ui-utils": "^2.0.1",
35
+ "@homebridge/plugin-ui-utils": "^2.0.2",
36
36
  "fakegato-history": "^0.6.7",
37
37
  "form-data": "^4.0.2",
38
38
  "fs-extra": "^11.3.0",
39
- "got": "^14.4.6",
39
+ "got": "^14.4.7",
40
40
  "moment": "^2.30.1"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@babel/core": "7.26.10",
44
44
  "@babel/eslint-parser": "7.27.0",
45
45
  "@babel/eslint-plugin": "7.27.0",
46
- "@eslint/js": "^9.23.0",
47
- "eslint": "^9.23.0",
48
- "eslint-config-prettier": "^10.1.1",
46
+ "@eslint/js": "^9.25.1",
47
+ "eslint": "^9.25.1",
48
+ "eslint-config-prettier": "^10.1.2",
49
49
  "eslint-plugin-import": "^2.31.0",
50
- "eslint-plugin-prettier": "^5.2.5",
50
+ "eslint-plugin-prettier": "^5.2.6",
51
51
  "globals": "^16.0.0",
52
52
  "prettier": "^3.5.3"
53
53
  }
54
- }
54
+ }
@@ -1,4 +1,5 @@
1
1
  import Logger from './logger.js';
2
+ import FormData from 'form-data';
2
3
 
3
4
  export default class Telegram {
4
5
  constructor(options, messages) {
package/src/platform.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import DeviceHandler from './helper/handler.js';
2
2
  import Logger from './helper/logger.js';
3
- import packageFile from '../package.json' with { type: 'json' };
4
3
  import TadoConfig from './tado/tado-config.js';
5
4
  import fakeGatoHistory from 'fakegato-history';
5
+ import { readFileSync } from 'fs';
6
+ import { fileURLToPath } from "url";
7
+ import { join, dirname } from "path";
6
8
 
7
9
  // Accessories
8
10
  import ContactAccessory from './accessories/contact.js';
@@ -24,45 +26,37 @@ import EveTypes from './types/eve.js';
24
26
 
25
27
  const PLUGIN_NAME = '@homebridge-plugins/homebridge-tado';
26
28
  const PLATFORM_NAME = 'TadoPlatform';
27
-
28
- var Accessory, UUIDGen, FakeGatoHistoryService;
29
+ let Accessory, UUIDGen, FakeGatoHistoryService;
29
30
 
30
31
  export default function (homebridge) {
31
32
  Accessory = homebridge.platformAccessory;
32
33
  UUIDGen = homebridge.hap.uuid;
33
-
34
34
  return TadoPlatform;
35
- };
36
-
37
- function TadoPlatform(log, config, api) {
38
- if (!api || !config) return;
39
-
40
- //init logger
41
- Logger.init(log, config.debug);
42
-
43
- //init types/fakegato
44
- CustomTypes.registerWith(api.hap);
45
- EveTypes.registerWith(api.hap);
46
- FakeGatoHistoryService = fakeGatoHistory(api);
47
-
48
- this.api = api;
49
- this.accessories = [];
50
- this.config = config;
35
+ }
51
36
 
52
- this.user = [];
37
+ class TadoPlatform {
38
+ constructor(log, config, api) {
39
+ if (!api || !config) return;
53
40
 
54
- const storagePath = this.api.user.storagePath();
41
+ Logger.init(log, config.debug);
42
+ CustomTypes.registerWith(api.hap);
43
+ EveTypes.registerWith(api.hap);
44
+ FakeGatoHistoryService = fakeGatoHistory(api);
55
45
 
56
- //setup config/plugin
57
- this.setupPlugin(storagePath);
46
+ this.api = api;
47
+ this.accessories = [];
48
+ this.config = config;
49
+ this.user = [];
50
+ this.packageJson = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), "..", "package.json"), "utf-8"));
51
+ const storagePath = this.api.user.storagePath();
58
52
 
59
- if (!this.user.length) this.setupConfig(storagePath);
53
+ this.setupPlugin(storagePath);
54
+ if (!this.user.length) this.setupConfig(storagePath);
60
55
 
61
- this.api.on('didFinishLaunching', this.didFinishLaunching.bind(this));
62
- }
56
+ this.api.on('didFinishLaunching', this.didFinishLaunching.bind(this));
57
+ }
63
58
 
64
- TadoPlatform.prototype = {
65
- setupPlugin: async function (storagePath) {
59
+ async setupPlugin(storagePath) {
66
60
  try {
67
61
  if (this.config.user && this.config.user.length) {
68
62
  for (const credentials of this.config.user) {
@@ -140,11 +134,9 @@ TadoPlatform.prototype = {
140
134
  Logger.error('An error occured during setting up plugin!');
141
135
  Logger.error(err);
142
136
  }
137
+ }
143
138
 
144
- return;
145
- },
146
-
147
- setupConfig: function (storagePath) {
139
+ setupConfig(storagePath) {
148
140
  try {
149
141
  const { config, devices, deviceHandler, telegram } = TadoConfig.setup(this.config, UUIDGen, storagePath);
150
142
 
@@ -156,11 +148,9 @@ TadoPlatform.prototype = {
156
148
  Logger.error('An error occured during setting up plugin!');
157
149
  Logger.error(err);
158
150
  }
151
+ }
159
152
 
160
- return;
161
- },
162
-
163
- didFinishLaunching: function () {
153
+ didFinishLaunching() {
164
154
  if (this.user.length) return;
165
155
 
166
156
  for (const entry of this.devices.entries()) {
@@ -205,9 +195,9 @@ TadoPlatform.prototype = {
205
195
  const deviceHandler = DeviceHandler(this.api, accessories, config, tado, this.telegram);
206
196
  deviceHandler.getStates();
207
197
  }
208
- },
198
+ }
209
199
 
210
- setupAccessory: function (accessory, device) {
200
+ setupAccessory(accessory, device) {
211
201
  accessory.on('identify', () => {
212
202
  Logger.info('Identify requested.', accessory.displayName);
213
203
  });
@@ -223,7 +213,7 @@ TadoPlatform.prototype = {
223
213
  AccessoryInformation.setCharacteristic(this.api.hap.Characteristic.Manufacturer, manufacturer)
224
214
  .setCharacteristic(this.api.hap.Characteristic.Model, model)
225
215
  .setCharacteristic(this.api.hap.Characteristic.SerialNumber, serialNumber)
226
- .setCharacteristic(this.api.hap.Characteristic.FirmwareRevision, packageFile.version);
216
+ .setCharacteristic(this.api.hap.Characteristic.FirmwareRevision, this.packageJson.version);
227
217
 
228
218
  const tado = device.tado;
229
219
 
@@ -295,9 +285,9 @@ TadoPlatform.prototype = {
295
285
  }
296
286
 
297
287
  return;
298
- },
288
+ }
299
289
 
300
- configureAccessory: function (accessory, refresh) {
290
+ configureAccessory(accessory, refresh) {
301
291
  if (!this.user.length) {
302
292
  const device = this.devices.get(accessory.UUID);
303
293
 
@@ -308,9 +298,9 @@ TadoPlatform.prototype = {
308
298
  }
309
299
 
310
300
  if (!refresh) this.accessories.push(accessory);
311
- },
301
+ }
312
302
 
313
- removeAccessory: function (accessory) {
303
+ removeAccessory(accessory) {
314
304
  Logger.info('Removing accessory...', accessory.displayName);
315
305
 
316
306
  let accessories = this.accessories.map((cachedAccessory) => {
@@ -324,5 +314,5 @@ TadoPlatform.prototype = {
324
314
  });
325
315
 
326
316
  this.api.unregisterPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
327
- },
328
- };
317
+ }
318
+ }