feat: add MQTT integration for real-time entity updates

- aiomqtt async client with auto-reconnect and topic store
- MQTT router: GET /api/mqtt, GET /api/mqtt/topic/{path}, POST /api/mqtt/publish
- MQTT entities included in /api/all + WebSocket broadcast
- MqttCard frontend component with category filters, entity list
- Configurable via ENV: MQTT_HOST, MQTT_PORT, MQTT_USERNAME,
  MQTT_PASSWORD, MQTT_TOPICS (comma-separated or JSON array)
- Gracefully disabled when MQTT_HOST is not set

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Sam 2026-03-02 10:13:50 +01:00
parent 9f7330e217
commit 89ed0c6d0a
11 changed files with 542 additions and 1 deletions

View file

@ -15,6 +15,7 @@ from server.routers.news import get_news_articles
from server.routers.servers import get_servers
from server.routers.tasks import get_tasks
from server.routers.weather import get_weather
from server.services.mqtt_service import mqtt_service
logger = logging.getLogger(__name__)
@ -58,6 +59,10 @@ async def get_all() -> Dict[str, Any]:
"servers": servers_data,
"ha": ha_data,
"tasks": tasks_data,
"mqtt": {
"connected": mqtt_service.connected,
"entities": mqtt_service.get_entities(),
},
"timestamp": datetime.now(timezone.utc).isoformat(),
}