How kimhamyong/eams-gateway works
Main Components
• End Node (external input from sensors via ZigBee)
• Home Gateway (the core of this project, which you are diagramming)
• ZigBee Receiver (located in zigbee/receiver.py): This component handles serial communication with the ZigBee USB module.
• ZigBee Parser (located in zigbee/parser.py): Processes and validates incoming ZigBee API frames.
• MQTT Publisher (inside mqtt/publisher.py): Converts parsed data into JSON format and publishes it.
• Configuration (in config/settings.py and .env file): Loads the environment variables including allowed MAC addresses and MQTT topics.
• Main Script (main.py): Orchestrates the receiver and publisher components.
• MQTT Broker (script mqtt-broker.sh indicates installation and configuration of a Mosquitto broker)
Out the Data Flow
• In the Gateway, the ZigBee Receiver picks up raw serial data.
• This data is then handed off to the ZigBee Parser for validation and extraction of sensor details.
• Once processed, the MQTT Publisher formats the data into JSON and sends it to the MQTT Broker using the Paho MQTT library.
• The MQTT Broker (Mosquitto) then relays these messages to the Server, which can push updates via WebSocket to a UI.
Architectural Patterns and Key Details
• There is a clear separation of concerns:
• Sensor data acquisition is done by the ZigBee Receiver and Parser.
• Data distribution is managed by the MQTT Publisher.
• The system relies on environment-driven configuration (see the .env example and settings.py) to adjust both sensor filtering (allowed MAC addresses) and MQTT settings.
• The README showcases a layered communication model where communication flows stage-by-stage (ZigBee → MQTT → Server → UI).
• Use of shell scripts (setup.sh, mqtt-broker.sh) for installation and configuration is another important element.
Relevant Technologies and Frameworks
• Python 3.12.7 is being used as the programming language.
• Libraries: python3-paho-mqtt for MQTT communication.
• Mosquitto is the chosen MQTT Broker.