Update README.md and sensor_bridge.py to reflect changes in MQTT topic structure. Transitioned from a hierarchical to a flat topic structure for improved organization, simplifying the topic format for each location. Adjusted sensor publishing methods in sensor_bridge.py to align with the new topic structure, ensuring accurate data representation for temperature, humidity, and CO2 sensors.

This commit is contained in:
Naab2k3
2025-06-24 10:42:24 +07:00
parent 84e7babf7e
commit e83f614182
2 changed files with 20 additions and 24 deletions

View File

@ -70,29 +70,31 @@ python main.py
## 📈 Data Format & Topics
### MQTT Topic Structure
The service uses a hierarchical topic structure for better organization:
The service uses a flat topic structure for each location:
```
Location/{location_name}/{sensor_type}/Time # Timestamp
Location/{location_name}/{sensor_type}/Status # "online" or "offline"
Location/{location_name}/{sensor_type}/Temperature # Temperature value
Location/{location_name}/{sensor_type}/Humidity # Humidity value
Location/{location_name}/{sensor_type}/CO2 # CO2 sensors only
Location/{location_name}/{sensor_type}/alerts # Alert messages
Location/{location}/Time # Timestamp
Location/{location}/Status # "online" or "offline"
Location/{location}/Temperature # Temperature value
Location/{location}/Humidity # Humidity value
Location/{location}/CO2 # CO2 sensors only
Location/{location}/alerts # Alert messages
```
> **Note:** The `CO2` topic is only published for sensors that support CO2 measurement.
### Example Topics
```
Location/Warehouse-B/temperature-humidity/Time → "2024-01-15 10:30:25"
Location/Warehouse-B/temperature-humidity/Status → "online"
Location/Warehouse-B/temperature-humidity/Temperature → "23.5"
Location/Warehouse-B/temperature-humidity/Humidity → "65.2"
Location/Warehouse-B/Time → "2024-01-15 10:30:25"
Location/Warehouse-B/Status → "online"
Location/Warehouse-B/Temperature → "23.5"
Location/Warehouse-B/Humidity → "65.2"
Location/Office/CO2-gas/Time → "2024-01-15 10:30:25"
Location/Office/CO2-gas/Status → "online"
Location/Office/CO2-gas/Temperature → "24.1"
Location/Office/CO2-gas/Humidity → "58.3"
Location/Office/CO2-gas/CO2 → "420"
Location/Office/Time → "2024-01-15 10:30:25"
Location/Office/Status → "online"
Location/Office/Temperature → "24.1"
Location/Office/Humidity → "58.3"
Location/Office/CO2 → "420"
```
### Alert Format