Switch filter to use the database executor (#68594)
This commit is contained in:
parent
dbef90654f
commit
e5f424a280
1 changed files with 3 additions and 3 deletions
|
@ -13,7 +13,7 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
|
||||
from homeassistant.components.input_number import DOMAIN as INPUT_NUMBER_DOMAIN
|
||||
from homeassistant.components.recorder import history
|
||||
from homeassistant.components.recorder import get_instance, history
|
||||
from homeassistant.components.sensor import (
|
||||
ATTR_STATE_CLASS,
|
||||
DEVICE_CLASSES as SENSOR_DEVICE_CLASSES,
|
||||
|
@ -296,7 +296,7 @@ class SensorFilter(SensorEntity):
|
|||
|
||||
# Retrieve the largest window_size of each type
|
||||
if largest_window_items > 0:
|
||||
filter_history = await self.hass.async_add_executor_job(
|
||||
filter_history = await get_instance(self.hass).async_add_executor_job(
|
||||
partial(
|
||||
history.get_last_state_changes,
|
||||
self.hass,
|
||||
|
@ -308,7 +308,7 @@ class SensorFilter(SensorEntity):
|
|||
history_list.extend(filter_history[self._entity])
|
||||
if largest_window_time > timedelta(seconds=0):
|
||||
start = dt_util.utcnow() - largest_window_time
|
||||
filter_history = await self.hass.async_add_executor_job(
|
||||
filter_history = await get_instance(self.hass).async_add_executor_job(
|
||||
partial(
|
||||
history.state_changes_during_period,
|
||||
self.hass,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue