diff --git a/homeassistant/components/recorder/__init__.py b/homeassistant/components/recorder/__init__.py index 51da2d470ea..1c9524223e5 100644 --- a/homeassistant/components/recorder/__init__.py +++ b/homeassistant/components/recorder/__init__.py @@ -8,33 +8,33 @@ For more details about this component, please refer to the documentation at https://home-assistant.io/components/recorder/ """ import asyncio +from collections import namedtuple import concurrent.futures +from datetime import datetime, timedelta import logging import queue import threading import time -from collections import namedtuple -from datetime import datetime, timedelta -from typing import Optional, Dict + +from typing import Dict, Optional import voluptuous as vol -from homeassistant.core import ( - HomeAssistant, callback, CoreState) from homeassistant.const import ( - ATTR_ENTITY_ID, CONF_ENTITIES, CONF_EXCLUDE, CONF_DOMAINS, - CONF_INCLUDE, EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_START, - EVENT_STATE_CHANGED, EVENT_TIME_CHANGED, MATCH_ALL) + ATTR_ENTITY_ID, CONF_DOMAINS, CONF_ENTITIES, CONF_EXCLUDE, CONF_INCLUDE, + EVENT_HOMEASSISTANT_START, EVENT_HOMEASSISTANT_STOP, EVENT_STATE_CHANGED, + EVENT_TIME_CHANGED, MATCH_ALL) +from homeassistant.core import CoreState, HomeAssistant, callback import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entityfilter import generate_filter from homeassistant.helpers.typing import ConfigType import homeassistant.util.dt as dt_util -from . import purge, migration +from . import migration, purge from .const import DATA_INSTANCE from .util import session_scope -REQUIREMENTS = ['sqlalchemy==1.2.0'] +REQUIREMENTS = ['sqlalchemy==1.2.1'] _LOGGER = logging.getLogger(__name__) @@ -140,9 +140,9 @@ def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Handle calls to the purge service.""" instance.do_adhoc_purge(service.data[ATTR_KEEP_DAYS]) - hass.services.async_register(DOMAIN, SERVICE_PURGE, - async_handle_purge_service, - schema=SERVICE_PURGE_SCHEMA) + hass.services.async_register( + DOMAIN, SERVICE_PURGE, async_handle_purge_service, + schema=SERVICE_PURGE_SCHEMA) return (yield from instance.async_db_ready) @@ -169,10 +169,9 @@ class Recorder(threading.Thread): self.engine = None # type: Any self.run_info = None # type: Any - self.entity_filter = generate_filter(include.get(CONF_DOMAINS, []), - include.get(CONF_ENTITIES, []), - exclude.get(CONF_DOMAINS, []), - exclude.get(CONF_ENTITIES, [])) + self.entity_filter = generate_filter( + include.get(CONF_DOMAINS, []), include.get(CONF_ENTITIES, []), + exclude.get(CONF_DOMAINS, []), exclude.get(CONF_ENTITIES, [])) self.exclude_t = exclude.get(CONF_EVENT_TYPES, []) self.get_session = None @@ -238,8 +237,7 @@ class Recorder(threading.Thread): self.queue.put(None) self.join() - self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, - shutdown) + self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, shutdown) if self.hass.state == CoreState.running: hass_started.set_result(None) @@ -249,8 +247,8 @@ class Recorder(threading.Thread): """Notify that hass has started.""" hass_started.set_result(None) - self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_START, - notify_hass_started) + self.hass.bus.async_listen_once( + EVENT_HOMEASSISTANT_START, notify_hass_started) if self.keep_days and self.purge_interval: @callback diff --git a/requirements_all.txt b/requirements_all.txt index 58b28b6a73d..ee6de0be56c 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1098,7 +1098,7 @@ speedtest-cli==1.0.7 # homeassistant.components.recorder # homeassistant.scripts.db_migrator -sqlalchemy==1.2.0 +sqlalchemy==1.2.1 # homeassistant.components.statsd statsd==3.2.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index cbd84af48a5..a7501f3e618 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -165,7 +165,7 @@ somecomfort==0.5.0 # homeassistant.components.recorder # homeassistant.scripts.db_migrator -sqlalchemy==1.2.0 +sqlalchemy==1.2.1 # homeassistant.components.statsd statsd==3.2.1