From 2aaeb1fa99f3f691a5c4adfff984e25bf96d787d Mon Sep 17 00:00:00 2001 From: Antonio Larrosa Date: Tue, 15 Mar 2022 22:33:59 +0100 Subject: [PATCH] Fix finding matrix room that is already joined (#67967) After some debugging, it seems room.canonical_alias contains the room alias that matches the room_id_or_alias value but is not contained in room.aliases (which is empty). As a result, the matrix component thought the room wasn't alread joined, joins again, and this replaces the previous room which had the listener. This resulted in the component callback not being called for new messages in the room. This fixes #66372 --- homeassistant/components/matrix/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/matrix/__init__.py b/homeassistant/components/matrix/__init__.py index 76e2630b26e..03772630a9e 100644 --- a/homeassistant/components/matrix/__init__.py +++ b/homeassistant/components/matrix/__init__.py @@ -243,7 +243,10 @@ class MatrixBot: room.update_aliases() self._aliases_fetched_for.add(room.room_id) - if room_id_or_alias in room.aliases: + if ( + room_id_or_alias in room.aliases + or room_id_or_alias == room.canonical_alias + ): _LOGGER.debug( "Already in room %s (known as %s)", room.room_id, room_id_or_alias )