@homebridge-plugins/homebridge-tado 8.3.0-beta.1 → 8.3.0-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 +7 -0
- package/config.schema.json +4 -4
- package/homebridge-ui/public/js/main.js +3 -3
- package/homebridge-ui/public/js/schema.js +4 -4
- package/package.json +1 -1
- package/src/helper/handler.js +20 -21
- package/src/platform.js +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v8.3.0 - 2025-10-25
|
|
4
|
+
- Add tado API counter
|
|
5
|
+
- Improve task scheduling and interval handling
|
|
6
|
+
- Refresh history service directly after polling
|
|
7
|
+
- Add option to disable the history service
|
|
8
|
+
- Persist tado zone states to storage directory after every polling
|
|
9
|
+
|
|
3
10
|
## v8.2.0 - 2025-10-23
|
|
4
11
|
- Query all zone states in a single API request to significantly reduce the number of API calls to tado during polling
|
|
5
12
|
- Update zone state after clearing a zone overlay
|
package/config.schema.json
CHANGED
|
@@ -564,10 +564,10 @@
|
|
|
564
564
|
"type": "boolean",
|
|
565
565
|
"description": "Optional: Skip authentication for tado api."
|
|
566
566
|
},
|
|
567
|
-
"
|
|
568
|
-
"title": "
|
|
567
|
+
"disableHistoryService": {
|
|
568
|
+
"title": "Disable History Service",
|
|
569
569
|
"type": "boolean",
|
|
570
|
-
"description": "Optional: Skip creation of
|
|
570
|
+
"description": "Optional: Skip creation of history service."
|
|
571
571
|
}
|
|
572
572
|
}
|
|
573
573
|
},
|
|
@@ -576,7 +576,7 @@
|
|
|
576
576
|
"debug",
|
|
577
577
|
"tadoApiUrl",
|
|
578
578
|
"skipAuth",
|
|
579
|
-
"
|
|
579
|
+
"disableHistoryService",
|
|
580
580
|
{
|
|
581
581
|
"key": "homes",
|
|
582
582
|
"type": "array",
|
|
@@ -134,7 +134,7 @@ async function createCustomSchema(home) {
|
|
|
134
134
|
debug: pluginConfig[0].debug,
|
|
135
135
|
tadoApiUrl: pluginConfig[0].tadoApiUrl,
|
|
136
136
|
skipAuth: pluginConfig[0].skipAuth,
|
|
137
|
-
|
|
137
|
+
disableHistoryService: pluginConfig[0].disableHistoryService,
|
|
138
138
|
homes: home
|
|
139
139
|
});
|
|
140
140
|
|
|
@@ -144,7 +144,7 @@ async function createCustomSchema(home) {
|
|
|
144
144
|
pluginConfig[0].debug = config.debug;
|
|
145
145
|
pluginConfig[0].tadoApiUrl = config.tadoApiUrl;
|
|
146
146
|
pluginConfig[0].skipAuth = config.skipAuth;
|
|
147
|
-
pluginConfig[0].
|
|
147
|
+
pluginConfig[0].disableHistoryService = config.disableHistoryService;
|
|
148
148
|
pluginConfig[0].homes = pluginConfig[0].homes.map(myHome => {
|
|
149
149
|
if (myHome.name === config.homes.name) {
|
|
150
150
|
myHome = config.homes;
|
|
@@ -287,7 +287,7 @@ async function removeDeviceFromConfig(name) {
|
|
|
287
287
|
delete pluginConfig[0].debug;
|
|
288
288
|
delete pluginConfig[0].tadoApiUrl;
|
|
289
289
|
delete pluginConfig[0].skipAuth;
|
|
290
|
-
delete pluginConfig[0].
|
|
290
|
+
delete pluginConfig[0].disableHistoryService;
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
await homebridge.updatePluginConfig(pluginConfig);
|
|
@@ -556,10 +556,10 @@ const schema = {
|
|
|
556
556
|
'type': 'boolean',
|
|
557
557
|
'description': 'Optional: Skip authentication for tado api.'
|
|
558
558
|
},
|
|
559
|
-
'
|
|
560
|
-
'title': '
|
|
559
|
+
'disableHistoryService': {
|
|
560
|
+
'title': 'Disable History Service',
|
|
561
561
|
'type': 'boolean',
|
|
562
|
-
'description': 'Optional: Skip creation of
|
|
562
|
+
'description': 'Optional: Skip creation of history service.'
|
|
563
563
|
}
|
|
564
564
|
},
|
|
565
565
|
'layout': [
|
|
@@ -567,7 +567,7 @@ const schema = {
|
|
|
567
567
|
'debug',
|
|
568
568
|
'tadoApiUrl',
|
|
569
569
|
'skipAuth',
|
|
570
|
-
'
|
|
570
|
+
'disableHistoryService',
|
|
571
571
|
'homes.name',
|
|
572
572
|
'homes.polling',
|
|
573
573
|
'homes.temperatureUnit',
|
package/package.json
CHANGED
package/src/helper/handler.js
CHANGED
|
@@ -5,16 +5,13 @@ import { join } from "path";
|
|
|
5
5
|
|
|
6
6
|
var settingState = false;
|
|
7
7
|
var delayTimer = {};
|
|
8
|
-
|
|
9
|
-
let statesInterval;
|
|
10
|
-
let counterInterval;
|
|
8
|
+
let tasksInitialized = false;
|
|
11
9
|
|
|
12
10
|
const timeout = (ms) => new Promise((res) => setTimeout(res, ms));
|
|
13
11
|
const aRefreshHistoryHandlers = [];
|
|
14
12
|
|
|
15
13
|
export default (api, accessories, config, tado, telegram) => {
|
|
16
14
|
const storagePath = api.user.storagePath();
|
|
17
|
-
initTasks();
|
|
18
15
|
|
|
19
16
|
async function setStates(accessory, accs, target, value) {
|
|
20
17
|
accessories = accs.filter((acc) => acc && acc.context.config.homeName === config.homeName);
|
|
@@ -706,22 +703,24 @@ export default (api, accessories, config, tado, telegram) => {
|
|
|
706
703
|
}
|
|
707
704
|
}
|
|
708
705
|
|
|
709
|
-
async function
|
|
706
|
+
async function persistStates(homeId, zoneStates) {
|
|
710
707
|
try {
|
|
711
708
|
const data = {};
|
|
712
|
-
data.
|
|
713
|
-
await writeFile(join(storagePath,
|
|
709
|
+
data.zoneStates = zoneStates ?? {};
|
|
710
|
+
await writeFile(join(storagePath, `tado-states-${homeId}.json`), JSON.stringify(data, null, 2), "utf-8");
|
|
714
711
|
} catch (error) {
|
|
715
|
-
Logger.error(`Error while updating tado
|
|
712
|
+
Logger.error(`Error while updating tado states file for home id ${homeId}: ${error.message || error}`);
|
|
716
713
|
}
|
|
717
714
|
try {
|
|
718
715
|
const data = {};
|
|
719
|
-
data.
|
|
720
|
-
await writeFile(join(storagePath,
|
|
716
|
+
data.counterData = await tado.getCounterData();
|
|
717
|
+
await writeFile(join(storagePath, "tado-counter.json"), JSON.stringify(data, null, 2), "utf-8");
|
|
721
718
|
} catch (error) {
|
|
722
|
-
Logger.error(`Error while updating tado
|
|
719
|
+
Logger.error(`Error while updating tado counter file: ${error.message || error}`);
|
|
723
720
|
}
|
|
724
721
|
try {
|
|
722
|
+
//wait for fakegato services to be loaded
|
|
723
|
+
await new Promise(r => setTimeout(r, 4000));
|
|
725
724
|
for (const fnRefreshHistory of aRefreshHistoryHandlers) {
|
|
726
725
|
fnRefreshHistory();
|
|
727
726
|
}
|
|
@@ -740,16 +739,18 @@ export default (api, accessories, config, tado, telegram) => {
|
|
|
740
739
|
}
|
|
741
740
|
|
|
742
741
|
function initTasks() {
|
|
743
|
-
if (
|
|
742
|
+
if (tasksInitialized) return;
|
|
743
|
+
tasksInitialized = true;
|
|
744
|
+
|
|
744
745
|
void getStates();
|
|
745
|
-
|
|
746
|
+
setInterval(() => getStates(), Math.max(config.polling, 300) * 1000);
|
|
746
747
|
|
|
747
|
-
if (counterInterval) clearInterval(counterInterval);
|
|
748
748
|
void logCounter();
|
|
749
|
-
|
|
749
|
+
setInterval(() => logCounter(), 60 * 60 * 1000);
|
|
750
750
|
}
|
|
751
751
|
|
|
752
752
|
async function getStates() {
|
|
753
|
+
let zoneStates = {};
|
|
753
754
|
try {
|
|
754
755
|
//ME
|
|
755
756
|
if (!config.homeId) await updateMe();
|
|
@@ -758,12 +759,7 @@ export default (api, accessories, config, tado, telegram) => {
|
|
|
758
759
|
if (!config.temperatureUnit) await updateHome();
|
|
759
760
|
|
|
760
761
|
//Zones
|
|
761
|
-
|
|
762
|
-
try {
|
|
763
|
-
if (config.zones.length) zoneStates = await updateZones();
|
|
764
|
-
} finally {
|
|
765
|
-
void refreshHistory(config.homeId, zoneStates);
|
|
766
|
-
}
|
|
762
|
+
if (config.zones.length) zoneStates = await updateZones();
|
|
767
763
|
|
|
768
764
|
//MobileDevices
|
|
769
765
|
if (config.presence.length) await updateMobileDevices();
|
|
@@ -781,6 +777,8 @@ export default (api, accessories, config, tado, telegram) => {
|
|
|
781
777
|
if (config.childLock.length) await updateDevices();
|
|
782
778
|
} catch (err) {
|
|
783
779
|
errorHandler(err);
|
|
780
|
+
} finally {
|
|
781
|
+
void persistStates(config.homeId, zoneStates);
|
|
784
782
|
}
|
|
785
783
|
}
|
|
786
784
|
|
|
@@ -1564,6 +1562,7 @@ export default (api, accessories, config, tado, telegram) => {
|
|
|
1564
1562
|
}
|
|
1565
1563
|
|
|
1566
1564
|
return {
|
|
1565
|
+
initTasks: initTasks,
|
|
1567
1566
|
getStates: getStates,
|
|
1568
1567
|
setStates: setStates,
|
|
1569
1568
|
changedStates: changedStates,
|
package/src/platform.js
CHANGED
|
@@ -41,7 +41,7 @@ class TadoPlatform {
|
|
|
41
41
|
Logger.init(log, config.debug);
|
|
42
42
|
CustomTypes.registerWith(api.hap);
|
|
43
43
|
EveTypes.registerWith(api.hap);
|
|
44
|
-
FakeGatoHistoryService = config.
|
|
44
|
+
FakeGatoHistoryService = config.disableHistoryService ? undefined : fakeGatoHistory(api);
|
|
45
45
|
|
|
46
46
|
this.api = api;
|
|
47
47
|
this.accessories = [];
|
|
@@ -192,7 +192,8 @@ class TadoPlatform {
|
|
|
192
192
|
|
|
193
193
|
let accessories = this.accessories.filter((acc) => acc && acc.context.config.homeName === name);
|
|
194
194
|
|
|
195
|
-
DeviceHandler(this.api, accessories, config, tado, this.telegram);
|
|
195
|
+
const deviceHandler = DeviceHandler(this.api, accessories, config, tado, this.telegram);
|
|
196
|
+
deviceHandler.initTasks();
|
|
196
197
|
}
|
|
197
198
|
}
|
|
198
199
|
|