diff --git a/homeassistant/components/recorder/__init__.py b/homeassistant/components/recorder/__init__.py index db645b3a195..48f565ddb56 100644 --- a/homeassistant/components/recorder/__init__.py +++ b/homeassistant/components/recorder/__init__.py @@ -1119,8 +1119,7 @@ class Recorder(threading.Thread): self.event_session.add(dbstate) dbstate.event = dbevent - # If they do not have a commit interval - # than we commit right away + # Commit right away if the commit interval is zero if not self.commit_interval: self._commit_event_session_or_retry() diff --git a/tests/common.py b/tests/common.py index 98fc6188777..4920d27fd1c 100644 --- a/tests/common.py +++ b/tests/common.py @@ -905,7 +905,10 @@ def assert_setup_component(count, domain=None): def init_recorder_component(hass, add_config=None): """Initialize the recorder.""" config = dict(add_config) if add_config else {} - config[recorder.CONF_DB_URL] = "sqlite://" # In memory DB + if recorder.CONF_DB_URL not in config: + config[recorder.CONF_DB_URL] = "sqlite://" # In memory DB + if recorder.CONF_COMMIT_INTERVAL not in config: + config[recorder.CONF_COMMIT_INTERVAL] = 0 with patch("homeassistant.components.recorder.migration.migrate_schema"): assert setup_component(hass, recorder.DOMAIN, {recorder.DOMAIN: config}) @@ -915,9 +918,11 @@ def init_recorder_component(hass, add_config=None): async def async_init_recorder_component(hass, add_config=None): """Initialize the recorder asynchronously.""" - config = add_config or {recorder.CONF_COMMIT_INTERVAL: 0} + config = dict(add_config) if add_config else {} if recorder.CONF_DB_URL not in config: - config[recorder.CONF_DB_URL] = "sqlite://" + config[recorder.CONF_DB_URL] = "sqlite://" # In memory DB + if recorder.CONF_COMMIT_INTERVAL not in config: + config[recorder.CONF_COMMIT_INTERVAL] = 0 with patch("homeassistant.components.recorder.migration.migrate_schema"): assert await async_setup_component(