Run energy db calls in the db executor (#69544)

Fixes #69537
pull/69580/head
J. Nick Koston 2022-04-06 23:50:49 -10:00 committed by GitHub
parent 6773c252d2
commit 97aa65d9a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -489,7 +489,7 @@ async def async_validate(hass: HomeAssistant) -> EnergyPreferencesValidation:
# Fetch the needed statistics metadata # Fetch the needed statistics metadata
statistics_metadata.update( statistics_metadata.update(
await hass.async_add_executor_job( await recorder.get_instance(hass).async_add_executor_job(
functools.partial( functools.partial(
recorder.statistics.get_metadata, recorder.statistics.get_metadata,
hass, hass,

View File

@ -260,7 +260,7 @@ async def ws_get_fossil_energy_consumption(
statistic_ids.append(msg["co2_statistic_id"]) statistic_ids.append(msg["co2_statistic_id"])
# Fetch energy + CO2 statistics # Fetch energy + CO2 statistics
statistics = await hass.async_add_executor_job( statistics = await recorder.get_instance(hass).async_add_executor_job(
recorder.statistics.statistics_during_period, recorder.statistics.statistics_during_period,
hass, hass,
start_time, start_time,