grist update
This commit is contained in:
@@ -19,7 +19,6 @@ export class HomepageService extends BaseService<null> {
|
||||
private haService: HomeAssistantService;
|
||||
private tidalService: TidalService;
|
||||
private wsService: WsService;
|
||||
private pollingIntervals: ReturnType<typeof setInterval>[] = [];
|
||||
private lastPoll: FullInformation = {
|
||||
ha_desk_position: null,
|
||||
ha_temp: null,
|
||||
@@ -38,7 +37,6 @@ export class HomepageService extends BaseService<null> {
|
||||
this.haService = haService;
|
||||
this.tidalService = tidalService;
|
||||
this.wsService = wsService;
|
||||
this.listenForClientChange();
|
||||
}
|
||||
|
||||
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 = [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user