diff --git a/homeassistant/components/statistics/sensor.py b/homeassistant/components/statistics/sensor.py index 51868c6d0a8..6e042b1536f 100644 --- a/homeassistant/components/statistics/sensor.py +++ b/homeassistant/components/statistics/sensor.py @@ -1,25 +1,26 @@ """Support for statistics for sensor values.""" +from collections import deque import logging import statistics -from collections import deque import voluptuous as vol -import homeassistant.helpers.config_validation as cv +from homeassistant.components.recorder.models import States +from homeassistant.components.recorder.util import execute, session_scope from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( - CONF_NAME, - CONF_ENTITY_ID, - EVENT_HOMEASSISTANT_START, - STATE_UNKNOWN, - STATE_UNAVAILABLE, ATTR_UNIT_OF_MEASUREMENT, + CONF_ENTITY_ID, + CONF_NAME, + EVENT_HOMEASSISTANT_START, + STATE_UNAVAILABLE, + STATE_UNKNOWN, ) from homeassistant.core import callback +import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import async_track_state_change from homeassistant.util import dt as dt_util -from homeassistant.components.recorder.util import session_scope, execute _LOGGER = logging.getLogger(__name__) @@ -275,7 +276,6 @@ class StatisticsSensor(Entity): If MaxAge is provided then query will restrict to entries younger then current datetime - MaxAge. """ - from homeassistant.components.recorder.models import States _LOGGER.debug("%s: initializing values from the database", self.entity_id)