grist update

This commit is contained in:
Darius
2026-02-08 16:31:44 +01:00
parent 12e7611267
commit ff87c3b5ce

View File

@@ -19,7 +19,6 @@ export class HomepageService extends BaseService<null> {
private haService: HomeAssistantService; private haService: HomeAssistantService;
private tidalService: TidalService; private tidalService: TidalService;
private wsService: WsService; private wsService: WsService;
private pollingIntervals: ReturnType<typeof setInterval>[] = [];
private lastPoll: FullInformation = { private lastPoll: FullInformation = {
ha_desk_position: null, ha_desk_position: null,
ha_temp: null, ha_temp: null,
@@ -38,7 +37,6 @@ export class HomepageService extends BaseService<null> {
this.haService = haService; this.haService = haService;
this.tidalService = tidalService; this.tidalService = tidalService;
this.wsService = wsService; this.wsService = wsService;
this.listenForClientChange();
} }
async getFullInformation(): Promise<ServiceResult<FullInformation | string>> { async getFullInformation(): Promise<ServiceResult<FullInformation | string>> {
@@ -223,45 +221,4 @@ export class HomepageService extends BaseService<null> {
}); });
} }
} }
listenForClientChange(): void {
this.wsService.onClientChange((clients: number) => {
if (clients === 0) {
this.stopPolling();
} else {
if (this.pollingIntervals.length === 0) {
this.startPolling();
}
}
});
}
startPolling(): void {
logInfo("Polling started");
const config: [ComponentUpdate[], number][] = [
//[[{ component: "tidal", data: null }], 20_000],
//[[{ component: "desk", data: null }], 60_000],
[
[
//{ component: "temp", data: null },
{ component: "grist", data: null },
],
600_000,
],
];
this.pollingIntervals = config.map(([components, interval]) =>
setInterval(() => {
logInfo(`Polling ${components.join(", ")}`);
this.updatePartial(components);
}, interval),
);
}
stopPolling(): void {
logInfo("Polling ended");
this.pollingIntervals.forEach(clearInterval);
this.pollingIntervals = [];
}
} }