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

@@ -1,3 +1,3 @@
aiomqtt==1.2.1 aiomqtt==2.0.0
schema==0.7.5 schema==0.7.5
aiocron==1.8 aiocron==1.8

View File

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