Revert "Revert "Use recorder executor in demo (#69327)" (#69334)" (#69545)

- We have found the issue causing the CI failures and its
  being solved in #69410.

This reverts commit 28350b9792.
pull/70269/head
J. Nick Koston 2022-04-18 23:09:16 -10:00 committed by GitHub
parent 506be5a818
commit 95b98ac9f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -5,6 +5,7 @@ from random import random
from homeassistant import config_entries, setup
from homeassistant.components import persistent_notification
from homeassistant.components.recorder import get_instance
from homeassistant.components.recorder.statistics import (
async_add_external_statistics,
get_last_statistics,
@ -245,7 +246,7 @@ async def _insert_statistics(hass):
}
statistic_id = f"{DOMAIN}:energy_consumption"
sum_ = 0
last_stats = await hass.async_add_executor_job(
last_stats = await get_instance(hass).async_add_executor_job(
get_last_statistics, hass, 1, statistic_id, True
)
if "domain:energy_consumption" in last_stats: