fix: mqtt subscription format

- Updated MQTT subscription to use dict format with topic and qos
- Added better logging for MQTT connection status
This commit is contained in:
Josh Finlay 2025-01-08 09:50:09 +10:00
parent c8a48e8e7a
commit 2474253efa
1 changed files with 5 additions and 3 deletions

View File

@ -98,11 +98,13 @@ class HomeAssistantMQTT:
self._reconnect_task = asyncio.create_task(self._reconnect_loop()) self._reconnect_task = asyncio.create_task(self._reconnect_loop())
async def _post_connect(self): async def _post_connect(self):
"""Tasks to perform after connection is established""" """Post connection setup - subscribe to topics"""
logger.info("Connected to MQTT broker")
self._connected = True
try: try:
# Subscribe to command topic # Subscribe to command topic
await self.client.subscribe([(self.command_topic, 1)]) await self.client.subscribe([{'topic': self.command_topic, 'qos': 1}])
logger.info(f"Subscribed to command topic: {self.command_topic}") logger.info(f"Subscribed to {self.command_topic}")
# Publish discovery config # Publish discovery config
config = { config = {