mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 17:56:46 +00:00
Fix some issues with energy period update scheduling (#24563)
This commit is contained in:
parent
07c4296771
commit
a4cdb294b1
@ -711,8 +711,10 @@ export const getEnergyDataCollection = (
|
|||||||
);
|
);
|
||||||
scheduleUpdatePeriod();
|
scheduleUpdatePeriod();
|
||||||
},
|
},
|
||||||
addHours(calcDate(now, endOfDay, hass.locale, hass.config), 1).getTime() -
|
addHours(
|
||||||
Date.now() // Switch to next day an hour after the day changed
|
calcDate(new Date(), endOfDay, hass.locale, hass.config),
|
||||||
|
1
|
||||||
|
).getTime() - Date.now() // Switch to next day an hour after the day changed
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
scheduleUpdatePeriod();
|
scheduleUpdatePeriod();
|
||||||
@ -721,19 +723,19 @@ export const getEnergyDataCollection = (
|
|||||||
collection.prefs = undefined;
|
collection.prefs = undefined;
|
||||||
};
|
};
|
||||||
collection.setPeriod = (newStart: Date, newEnd?: Date) => {
|
collection.setPeriod = (newStart: Date, newEnd?: Date) => {
|
||||||
|
if (collection._updatePeriodTimeout) {
|
||||||
|
clearTimeout(collection._updatePeriodTimeout);
|
||||||
|
collection._updatePeriodTimeout = undefined;
|
||||||
|
}
|
||||||
collection.start = newStart;
|
collection.start = newStart;
|
||||||
collection.end = newEnd;
|
collection.end = newEnd;
|
||||||
if (
|
if (
|
||||||
collection.start.getTime() ===
|
collection.start.getTime() ===
|
||||||
calcDate(new Date(), startOfDay, hass.locale, hass.config).getTime() &&
|
calcDate(new Date(), startOfDay, hass.locale, hass.config).getTime() &&
|
||||||
collection.end?.getTime() ===
|
collection.end?.getTime() ===
|
||||||
calcDate(new Date(), endOfDay, hass.locale, hass.config).getTime() &&
|
calcDate(new Date(), endOfDay, hass.locale, hass.config).getTime()
|
||||||
!collection._updatePeriodTimeout
|
|
||||||
) {
|
) {
|
||||||
scheduleUpdatePeriod();
|
scheduleUpdatePeriod();
|
||||||
} else if (collection._updatePeriodTimeout) {
|
|
||||||
clearTimeout(collection._updatePeriodTimeout);
|
|
||||||
collection._updatePeriodTimeout = undefined;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
collection.setCompare = (compare: boolean) => {
|
collection.setCompare = (compare: boolean) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user