@homebridge-plugins/homebridge-tado 8.5.1-beta.2 → 8.5.1-beta.3

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,8 +1,8 @@
1
1
  # Changelog
2
2
 
3
- ## v8.5.1 - 2025-10-29
4
- - Fix: Incorrect update of config zone properties leading to unwanted heating changes (#178)
5
- - Improve zone update handling when setting state
3
+ ## v8.6.0 - 2025-10-30
4
+ - Fix: Incorrect update zones handling leading to unwanted heating changes (#178)
5
+ - Improve zone update handling when setting state and update all zones if next scheduled update is more than 10s away
6
6
 
7
7
  ## v8.5.0 - 2025-10-27
8
8
  - Change minimum polling interval to 30s due to improvements made in v8.2.0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homebridge-plugins/homebridge-tado",
3
- "version": "8.5.1-beta.2",
3
+ "version": "8.5.1-beta.3",
4
4
  "description": "Homebridge plugin for controlling tado° devices.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -5,6 +5,7 @@ import { join } from "path";
5
5
 
6
6
  let settingState = false;
7
7
  let tasksInitialized = false;
8
+ let lastGetStates = 0;
8
9
  const delayTimer = {};
9
10
 
10
11
  const timeout = (ms) => new Promise((res) => setTimeout(res, ms));
@@ -23,6 +24,7 @@ export async function getPersistedStates(storagePath) {
23
24
  }
24
25
 
25
26
  export default (api, accessories, config, tado, telegram) => {
27
+ const statesIntervalTime = Math.max(config.polling, 30) * 1000;
26
28
  const storagePath = api.user.storagePath();
27
29
 
28
30
  async function setStates(accessory, accs, target, value) {
@@ -565,9 +567,11 @@ export default (api, accessories, config, tado, telegram) => {
565
567
  } catch (err) {
566
568
  errorHandler(err);
567
569
  } finally {
568
- //always update zone to set correct state in Apple Home
569
- if (zoneUpdated) await updateZones(accessory.context.config.zoneId);
570
570
  settingState = false;
571
+ //update zones to ensure correct state in Apple Home
572
+ const timeSinceLastGetStates = Date.now() - lastGetStates;
573
+ const statesIntervalTimeLeft = statesIntervalTime - timeSinceLastGetStates;
574
+ if (zoneUpdated && statesIntervalTimeLeft > 10_000) await updateZones();
571
575
  }
572
576
  }
573
577
 
@@ -769,13 +773,14 @@ export default (api, accessories, config, tado, telegram) => {
769
773
  tasksInitialized = true;
770
774
 
771
775
  void getStates();
772
- setInterval(() => getStates(), Math.max(config.polling, 30) * 1000);
776
+ setInterval(() => getStates(), statesIntervalTime);
773
777
 
774
778
  void logCounter();
775
779
  setInterval(() => logCounter(), 60 * 60 * 1000);
776
780
  }
777
781
 
778
782
  async function getStates() {
783
+ lastGetStates = Date.now();
779
784
  let zoneStates = {};
780
785
  try {
781
786
  //ME
@@ -845,12 +850,8 @@ export default (api, accessories, config, tado, telegram) => {
845
850
  }
846
851
  }
847
852
 
848
- async function updateZones(idToUpdate) {
849
- let zoneStates = {};
850
- if (settingState && idToUpdate === undefined) {
851
- await timeout(10 * 1000);
852
- if (settingState) return zoneStates;
853
- }
853
+ async function updateZones() {
854
+ if (settingState) return;
854
855
 
855
856
  Logger.debug('Polling Zones...', config.homeName);
856
857
 
@@ -901,17 +902,12 @@ export default (api, accessories, config, tado, telegram) => {
901
902
  });
902
903
  }
903
904
 
904
- let zonesToUpdate = [];
905
- if (idToUpdate !== undefined) {
906
- zoneStates[idToUpdate] = await tado.getZoneState(config.homeId, idToUpdate);
907
- zonesToUpdate = config.zones.filter(zone => zone.id === idToUpdate);
908
- } else {
909
- zoneStates = (await tado.getZoneStates(config.homeId))["zoneStates"];
910
- zonesToUpdate = config.zones;
911
- }
905
+ const zoneStates = (await tado.getZoneStates(config.homeId))["zoneStates"] ?? {};
906
+ const zonesToUpdate = config.zones;
912
907
 
913
908
  for (const zone of zonesToUpdate) {
914
- const zoneState = zoneStates[zone.id];
909
+ const zoneState = zoneStates[zone.id.toString()];
910
+ Logger.debug(`Update state of zone ${zone.id} to:`, zoneState);
915
911
 
916
912
  let currentState, targetState, currentTemp, targetTemp, humidity, active, battery, tempEqual;
917
913
 
@@ -1244,6 +1240,8 @@ export default (api, accessories, config, tado, telegram) => {
1244
1240
  if (windowContactAccessory.length) {
1245
1241
  windowContactAccessory.forEach((acc) => {
1246
1242
  if (acc.displayName.includes(zone.name)) {
1243
+ Logger.debug("Update window contact sensor.");
1244
+
1247
1245
  let serviceBattery = acc.getService(api.hap.Service.BatteryService);
1248
1246
  let characteristicBattery = api.hap.Characteristic.BatteryLevel;
1249
1247
 
@@ -1264,6 +1262,8 @@ export default (api, accessories, config, tado, telegram) => {
1264
1262
  if (windowSwitchAccessory.length) {
1265
1263
  windowSwitchAccessory[0].services.forEach((switchService) => {
1266
1264
  if (switchService.subtype && switchService.subtype.includes(zone.name)) {
1265
+ Logger.debug("Update window switch accessory.");
1266
+
1267
1267
  let service = windowSwitchAccessory[0].getServiceById(api.hap.Service.Switch, switchService.subtype);
1268
1268
  let characteristic = api.hap.Characteristic.On;
1269
1269
 
@@ -1301,12 +1301,11 @@ export default (api, accessories, config, tado, telegram) => {
1301
1301
 
1302
1302
  let state = (inManualMode || inAutoMode) !== 0;
1303
1303
 
1304
- serviceSwitch.getCharacteristic(characteristicAuto).updateValue(inAutoMode);
1304
+ Logger.debug(`Update central switch:`, { inAutoMode: inAutoMode, inManualMode: inManualMode, inOffMode: inOffMode, state: state });
1305
1305
 
1306
+ serviceSwitch.getCharacteristic(characteristicAuto).updateValue(inAutoMode);
1306
1307
  serviceSwitch.getCharacteristic(characteristicManual).updateValue(inManualMode);
1307
-
1308
1308
  serviceSwitch.getCharacteristic(characteristicOff).updateValue(inOffMode);
1309
-
1310
1309
  serviceSwitch.getCharacteristic(characteristicOn).updateValue(state);
1311
1310
  }
1312
1311
  });