@homebridge-plugins/homebridge-tado 7.5.3 → 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,10 @@
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
+
3
8
  ## v7.5.3 - 2025-03-27
4
9
  - Fixed crash on startup for node 20 (unexpected token 'with')
5
10
 
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.3",
3
+ "version": "7.6.0",
4
4
  "description": "Homebridge plugin for controlling tado° devices.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -32,22 +32,22 @@
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
  }
@@ -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
@@ -26,44 +26,37 @@ import EveTypes from './types/eve.js';
26
26
 
27
27
  const PLUGIN_NAME = '@homebridge-plugins/homebridge-tado';
28
28
  const PLATFORM_NAME = 'TadoPlatform';
29
-
30
- var Accessory, UUIDGen, FakeGatoHistoryService;
29
+ let Accessory, UUIDGen, FakeGatoHistoryService;
31
30
 
32
31
  export default function (homebridge) {
33
32
  Accessory = homebridge.platformAccessory;
34
33
  UUIDGen = homebridge.hap.uuid;
35
-
36
34
  return TadoPlatform;
37
- };
38
-
39
- function TadoPlatform(log, config, api) {
40
- if (!api || !config) return;
41
-
42
- //init logger
43
- Logger.init(log, config.debug);
35
+ }
44
36
 
45
- //init types/fakegato
46
- CustomTypes.registerWith(api.hap);
47
- EveTypes.registerWith(api.hap);
48
- FakeGatoHistoryService = fakeGatoHistory(api);
37
+ class TadoPlatform {
38
+ constructor(log, config, api) {
39
+ if (!api || !config) return;
49
40
 
50
- this.api = api;
51
- this.accessories = [];
52
- this.config = config;
53
- this.user = [];
54
- this.packageJson = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), "..", "package.json"), "utf-8"));
55
- 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);
56
45
 
57
- //setup config/plugin
58
- 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();
59
52
 
60
- if (!this.user.length) this.setupConfig(storagePath);
53
+ this.setupPlugin(storagePath);
54
+ if (!this.user.length) this.setupConfig(storagePath);
61
55
 
62
- this.api.on('didFinishLaunching', this.didFinishLaunching.bind(this));
63
- }
56
+ this.api.on('didFinishLaunching', this.didFinishLaunching.bind(this));
57
+ }
64
58
 
65
- TadoPlatform.prototype = {
66
- setupPlugin: async function (storagePath) {
59
+ async setupPlugin(storagePath) {
67
60
  try {
68
61
  if (this.config.user && this.config.user.length) {
69
62
  for (const credentials of this.config.user) {
@@ -141,11 +134,9 @@ TadoPlatform.prototype = {
141
134
  Logger.error('An error occured during setting up plugin!');
142
135
  Logger.error(err);
143
136
  }
137
+ }
144
138
 
145
- return;
146
- },
147
-
148
- setupConfig: function (storagePath) {
139
+ setupConfig(storagePath) {
149
140
  try {
150
141
  const { config, devices, deviceHandler, telegram } = TadoConfig.setup(this.config, UUIDGen, storagePath);
151
142
 
@@ -157,11 +148,9 @@ TadoPlatform.prototype = {
157
148
  Logger.error('An error occured during setting up plugin!');
158
149
  Logger.error(err);
159
150
  }
151
+ }
160
152
 
161
- return;
162
- },
163
-
164
- didFinishLaunching: function () {
153
+ didFinishLaunching() {
165
154
  if (this.user.length) return;
166
155
 
167
156
  for (const entry of this.devices.entries()) {
@@ -206,9 +195,9 @@ TadoPlatform.prototype = {
206
195
  const deviceHandler = DeviceHandler(this.api, accessories, config, tado, this.telegram);
207
196
  deviceHandler.getStates();
208
197
  }
209
- },
198
+ }
210
199
 
211
- setupAccessory: function (accessory, device) {
200
+ setupAccessory(accessory, device) {
212
201
  accessory.on('identify', () => {
213
202
  Logger.info('Identify requested.', accessory.displayName);
214
203
  });
@@ -296,9 +285,9 @@ TadoPlatform.prototype = {
296
285
  }
297
286
 
298
287
  return;
299
- },
288
+ }
300
289
 
301
- configureAccessory: function (accessory, refresh) {
290
+ configureAccessory(accessory, refresh) {
302
291
  if (!this.user.length) {
303
292
  const device = this.devices.get(accessory.UUID);
304
293
 
@@ -309,9 +298,9 @@ TadoPlatform.prototype = {
309
298
  }
310
299
 
311
300
  if (!refresh) this.accessories.push(accessory);
312
- },
301
+ }
313
302
 
314
- removeAccessory: function (accessory) {
303
+ removeAccessory(accessory) {
315
304
  Logger.info('Removing accessory...', accessory.displayName);
316
305
 
317
306
  let accessories = this.accessories.map((cachedAccessory) => {
@@ -325,5 +314,5 @@ TadoPlatform.prototype = {
325
314
  });
326
315
 
327
316
  this.api.unregisterPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
328
- },
329
- };
317
+ }
318
+ }