Files
home-automation/apps/abstraction/README.md

1.5 KiB

Abstraction Layer

The abstraction layer is an asyncio-based worker that manages device communication through MQTT.

Features

  • Configuration Loading: Reads device configuration from config/devices.yaml
  • MQTT Integration: Connects to MQTT broker for real-time device communication
  • Async Design: Built with asyncio for efficient concurrent operations
  • Message Subscription: Listens to home/# topics for device events
  • Logging: Structured logging at INFO level

Running

# Start the abstraction worker
poetry run python -m apps.abstraction.main

The worker will:

  1. Load configuration from config/devices.yaml
  2. Connect to MQTT broker (172.16.2.16:1883)
  3. Subscribe to topic home/#
  4. Log "Abstraction worker started" at INFO level
  5. Keep running and processing MQTT messages until interrupted

Configuration

The worker reads configuration from config/devices.yaml. Example structure:

mqtt:
  broker: "172.16.2.16"
  port: 1883
  client_id: "home-automation-abstraction"
  keepalive: 60

devices:
  - id: "light_living_room"
    type: "light"
    name: "Living Room Light"
    mqtt_topic: "home/living_room/light"

MQTT Broker

The worker connects to a real MQTT broker at:

  • Host: 172.16.2.16
  • Port: 1883
  • Authentication: None required

Topics subscribed:

  • home/# - All home automation topics

Dependencies

  • PyYAML: Configuration file parsing
  • aiomqtt: Modern async MQTT client
  • asyncio: Asynchronous I/O

Stopping

Press Ctrl+C to gracefully stop the worker.