mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Tibber, Use a dedicated executor pool for database operations (#69208)
This commit is contained in:
parent
20f95fa6b3
commit
40fba130e8
@ -8,6 +8,7 @@ from random import randrange
|
|||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
|
from homeassistant.components.recorder import get_instance
|
||||||
from homeassistant.components.recorder.models import StatisticData, StatisticMetaData
|
from homeassistant.components.recorder.models import StatisticData, StatisticMetaData
|
||||||
from homeassistant.components.recorder.statistics import (
|
from homeassistant.components.recorder.statistics import (
|
||||||
async_add_external_statistics,
|
async_add_external_statistics,
|
||||||
@ -574,7 +575,7 @@ class TibberDataCoordinator(DataUpdateCoordinator):
|
|||||||
f"{home.home_id.replace('-', '')}"
|
f"{home.home_id.replace('-', '')}"
|
||||||
)
|
)
|
||||||
|
|
||||||
last_stats = await self.hass.async_add_executor_job(
|
last_stats = await get_instance(self.hass).async_add_executor_job(
|
||||||
get_last_statistics, self.hass, 1, statistic_id, True
|
get_last_statistics, self.hass, 1, statistic_id, True
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -594,7 +595,7 @@ class TibberDataCoordinator(DataUpdateCoordinator):
|
|||||||
start = dt_util.parse_datetime(
|
start = dt_util.parse_datetime(
|
||||||
hourly_consumption_data[0]["from"]
|
hourly_consumption_data[0]["from"]
|
||||||
) - timedelta(hours=1)
|
) - timedelta(hours=1)
|
||||||
stat = await self.hass.async_add_executor_job(
|
stat = await get_instance(self.hass).async_add_executor_job(
|
||||||
statistics_during_period,
|
statistics_during_period,
|
||||||
self.hass,
|
self.hass,
|
||||||
start,
|
start,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user