diff --git a/homeassistant/components/recorder/util.py b/homeassistant/components/recorder/util.py index 939a016c960..5894c8c3ce6 100644 --- a/homeassistant/components/recorder/util.py +++ b/homeassistant/components/recorder/util.py @@ -134,7 +134,7 @@ def session_scope( need_rollback = False try: yield session - if session.get_transaction() and not read_only: + if not read_only and session.get_transaction(): need_rollback = True session.commit() except Exception as err: