From 28dd92d92888e672917556ae77a7174992a055b3 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 23 Jun 2022 16:35:10 -0500 Subject: [PATCH] Fix logbook state query with postgresql (#73924) --- homeassistant/components/logbook/processor.py | 4 ++-- homeassistant/components/logbook/queries/common.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/logbook/processor.py b/homeassistant/components/logbook/processor.py index 82225df8364..6d491ec2892 100644 --- a/homeassistant/components/logbook/processor.py +++ b/homeassistant/components/logbook/processor.py @@ -377,9 +377,9 @@ def _rows_match(row: Row | EventAsRow, other_row: Row | EventAsRow) -> bool: """Check of rows match by using the same method as Events __hash__.""" if ( row is other_row - or (state_id := row.state_id) is not None + or (state_id := row.state_id) and state_id == other_row.state_id - or (event_id := row.event_id) is not None + or (event_id := row.event_id) and event_id == other_row.event_id ): return True diff --git a/homeassistant/components/logbook/queries/common.py b/homeassistant/components/logbook/queries/common.py index 5b79f6e0d32..466df668da8 100644 --- a/homeassistant/components/logbook/queries/common.py +++ b/homeassistant/components/logbook/queries/common.py @@ -87,7 +87,7 @@ EVENT_COLUMNS_FOR_STATE_SELECT = [ ] EMPTY_STATE_COLUMNS = ( - literal(value=None, type_=sqlalchemy.String).label("state_id"), + literal(value=0, type_=sqlalchemy.Integer).label("state_id"), literal(value=None, type_=sqlalchemy.String).label("state"), literal(value=None, type_=sqlalchemy.String).label("entity_id"), literal(value=None, type_=sqlalchemy.String).label("icon"),