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.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
|
||||||
from homeassistant.components.input_number import DOMAIN as INPUT_NUMBER_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 (
|
from homeassistant.components.sensor import (
|
||||||
ATTR_STATE_CLASS,
|
ATTR_STATE_CLASS,
|
||||||
DEVICE_CLASSES as SENSOR_DEVICE_CLASSES,
|
DEVICE_CLASSES as SENSOR_DEVICE_CLASSES,
|
||||||
|
@ -296,7 +296,7 @@ class SensorFilter(SensorEntity):
|
||||||
|
|
||||||
# Retrieve the largest window_size of each type
|
# Retrieve the largest window_size of each type
|
||||||
if largest_window_items > 0:
|
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(
|
partial(
|
||||||
history.get_last_state_changes,
|
history.get_last_state_changes,
|
||||||
self.hass,
|
self.hass,
|
||||||
|
@ -308,7 +308,7 @@ class SensorFilter(SensorEntity):
|
||||||
history_list.extend(filter_history[self._entity])
|
history_list.extend(filter_history[self._entity])
|
||||||
if largest_window_time > timedelta(seconds=0):
|
if largest_window_time > timedelta(seconds=0):
|
||||||
start = dt_util.utcnow() - largest_window_time
|
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(
|
partial(
|
||||||
history.state_changes_during_period,
|
history.state_changes_during_period,
|
||||||
self.hass,
|
self.hass,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue