switch to aiomqtt version 2.0.0

This commit is contained in:
Stefan Allius
2024-04-08 21:58:06 +02:00
parent 9264c936c8
commit ddde988e2c
2 changed files with 12 additions and 12 deletions

View File

@@ -73,17 +73,17 @@ class Mqtt(metaclass=Singleton):
if self.cb_MqttIsUp:
await self.cb_MqttIsUp()
async with self.__client.messages() as messages:
await self.__client.subscribe(
f"{ha['auto_conf_prefix']}"
"/status")
async for message in messages:
status = message.payload.decode("UTF-8")
logger_mqtt.info('Home-Assistant Status:'
f' {status}')
if status == 'online':
self.ha_restarts += 1
await self.cb_MqttIsUp()
# async with self.__client.messages() as messages:
await self.__client.subscribe(
f"{ha['auto_conf_prefix']}"
"/status")
async for message in self.__client.messages:
status = message.payload.decode("UTF-8")
logger_mqtt.info('Home-Assistant Status:'
f' {status}')
if status == 'online':
self.ha_restarts += 1
await self.cb_MqttIsUp()
except aiomqtt.MqttError:
logger_mqtt.info(f"Connection lost; Reconnecting in {interval}"