From fccca0919a344e96c067bccb557cf56841314cd7 Mon Sep 17 00:00:00 2001 From: Robert Resch Date: Sat, 5 Mar 2022 21:10:03 +0100 Subject: [PATCH] fix check if session has state connected --- bumper/models.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bumper/models.py b/bumper/models.py index b570603..129637e 100644 --- a/bumper/models.py +++ b/bumper/models.py @@ -5,6 +5,8 @@ import uuid from datetime import datetime, timedelta from typing import Any +from amqtt.session import Session + import bumper @@ -154,9 +156,10 @@ def include_EcoVacsHomeProducts_info(bot) -> dict[str, Any]: ) # mqtt_connection is not always set correctly, therefore workaround until fixed properly - for session in bumper.mqtt_server.broker._sessions: - did = session.split("@")[0] - if did == bot["did"]: + session: Session + for (session, _) in bumper.mqtt_server.broker._sessions.values(): + did = session.client_id.split("@")[0] + if did == bot["did"] and session.transitions.state == "connected": result["status"] = 1 return result