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"),