Config UI: improve device updates (#18405)

This commit is contained in:
Michael Geers 2025-01-25 12:52:31 +01:00 • committed by GitHub
parent 0a83391856
commit 8694917440
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -619,16 +619,17 @@ export default {
async updateValues() {
clearTimeout(this.deviceValueTimeout);
if (!this.offline) {
const promises = [
...this.meters.map((meter) => this.updateDeviceValue("meter", meter.name)),
...this.vehicles.map((vehicle) =>
this.updateDeviceValue("vehicle", vehicle.name)
),
];
await Promise.all(promises);
for (const meter of this.meters) {
await this.updateDeviceValue("meter", meter.name);
}
for (const vehicle of this.vehicles) {
await this.updateDeviceValue("vehicle", vehicle.name);
}
}
this.deviceValueTimeout = setTimeout(this.updateValues, 10000);
// ensure that component is still mounted
if (!this.$el) return;
const interval = (store.state?.interval || 30) * 1000;
this.deviceValueTimeout = setTimeout(this.updateValues, interval);
},
deviceTags(type, id) {
return this.deviceValues[type]?.[id] || [];