fix: mqtt subscription format
- Updated subscribe calls to match gmqtt example - Added qos=1 parameter to subscriptions
This commit is contained in:
parent
7a22813d8e
commit
925f612ede
|
|
@ -3,7 +3,6 @@ import json
|
|||
import asyncio
|
||||
from typing import Optional, Callable, Union
|
||||
from gmqtt import Client as MQTTClient
|
||||
from gmqtt.mqtt.subscription import Subscription
|
||||
import logging
|
||||
|
||||
# Get logger
|
||||
|
|
@ -103,9 +102,8 @@ class HomeAssistantMQTT:
|
|||
logger.info("Connected to MQTT broker")
|
||||
self._connected = True
|
||||
try:
|
||||
# Subscribe to command topic using gmqtt's format
|
||||
sub = Subscription(self.command_topic, qos=1)
|
||||
await self.client.subscribe([sub])
|
||||
# Subscribe to command topic
|
||||
await self.client.subscribe(self.command_topic, qos=1)
|
||||
logger.info(f"Subscribed to command topic: {self.command_topic}")
|
||||
|
||||
# Publish discovery config
|
||||
|
|
@ -194,8 +192,7 @@ class HomeAssistantMQTT:
|
|||
"""Subscribe to a topic"""
|
||||
if self.client and self._connected:
|
||||
try:
|
||||
sub = Subscription(topic, qos=1)
|
||||
await self.client.subscribe([sub])
|
||||
await self.client.subscribe(topic, qos=1)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to subscribe to topic: {e}")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue