This commit is contained in:
J. Nick Koston 2023-02-27 15:04:16 -06:00
parent 97b6fc03b3
commit 77e05af465
No known key found for this signature in database

View File

@ -614,7 +614,9 @@ export const getEnergyDataCollection = (
} }
energyCollectionKeys.push(options.key); energyCollectionKeys.push(options.key);
let energyInfoAndCO2Signal: EnergyInfoAndCO2Signal | undefined; let energyInfoAndCO2Signal: EnergyInfoAndCO2Signal | undefined;
let forceRefreshEnergyInfo: bool = false;
const collection = getCollection<EnergyData>( const collection = getCollection<EnergyData>(
hass.connection, hass.connection,
@ -643,13 +645,13 @@ export const getEnergyDataCollection = (
} }
nextFetch.setMinutes(20, 0, 0); nextFetch.setMinutes(20, 0, 0);
collection._refreshTimeout = window.setTimeout( collection._refreshTimeout = window.setTimeout(() => {
() => collection.refresh(), forceRefreshEnergyInfo = true;
nextFetch.getTime() - Date.now() collection.refresh();
); }, nextFetch.getTime() - Date.now());
} }
if (!energyInfoAndCO2Signal) { if (!energyInfoAndCO2Signal || forceRefreshEnergyInfo) {
energyInfoAndCO2Signal = await getEnergyInfoAndCO2Signal(hass); energyInfoAndCO2Signal = await getEnergyInfoAndCO2Signal(hass);
} }