Update configuration and health check response structure in POE project. Modified config.py to replace IP addresses for Modbus hosts, ensuring accurate sensor location mapping. Refactored health_check.py to standardize response formatting for sensor data, enhancing clarity in health and sensor status reporting. Updated README.md to reflect changes in MQTT topic structure, aligning with new data point definitions for temperature, humidity, and CO2 sensors.

This commit is contained in:
Naab2k3
2025-06-24 09:03:10 +07:00
parent d171066bbd
commit 7b8934b1d0
3 changed files with 23 additions and 23 deletions

View File

@ -73,26 +73,26 @@ python main.py
The service uses a hierarchical topic structure for better organization: The service uses a hierarchical topic structure for better organization:
``` ```
Location/{location_name}/{sensor_type}/Time Location/{location_name}/{sensor_type}/Time # Timestamp
Location/{location_name}/{sensor_type}/Status Location/{location_name}/{sensor_type}/Status # "online" or "offline"
Location/{location_name}/{sensor_type}/Data/temperature Location/{location_name}/{sensor_type}/Temperature # Temperature value
Location/{location_name}/{sensor_type}/Data/humidity Location/{location_name}/{sensor_type}/Humidity # Humidity value
Location/{location_name}/{sensor_type}/Data/co2 # CO2 sensors only Location/{location_name}/{sensor_type}/CO2 # CO2 sensors only
Location/{location_name}/{sensor_type}/alerts # Alert messages Location/{location_name}/{sensor_type}/alerts # Alert messages
``` ```
### Example Topics ### Example Topics
``` ```
Location/Warehouse-B/temperature-humidity/Time → "2024-01-15 10:30:25" Location/Warehouse-B/temperature-humidity/Time → "2024-01-15 10:30:25"
Location/Warehouse-B/temperature-humidity/Status → "online" Location/Warehouse-B/temperature-humidity/Status → "online"
Location/Warehouse-B/temperature-humidity/Data/temperature → "23.5" Location/Warehouse-B/temperature-humidity/Temperature → "23.5"
Location/Warehouse-B/temperature-humidity/Data/humidity → "65.2" Location/Warehouse-B/temperature-humidity/Humidity → "65.2"
Location/Office/CO2-gas/Time → "2024-01-15 10:30:25" Location/Office/CO2-gas/Time → "2024-01-15 10:30:25"
Location/Office/CO2-gas/Status → "online" Location/Office/CO2-gas/Status → "online"
Location/Office/CO2-gas/Data/temperature → "24.1" Location/Office/CO2-gas/Temperature → "24.1"
Location/Office/CO2-gas/Data/humidity → "58.3" Location/Office/CO2-gas/Humidity → "58.3"
Location/Office/CO2-gas/Data/co2 → "420" Location/Office/CO2-gas/CO2 → "420"
``` ```
### Alert Format ### Alert Format

View File

@ -7,9 +7,9 @@ MODBUS_HOSTS = [
{"ip": "10.84.60.32", "location": "Warehouse-C", "type": "temperature_humidity"}, {"ip": "10.84.60.32", "location": "Warehouse-C", "type": "temperature_humidity"},
{"ip": "10.84.60.33", "location": "Dyeing-Kitchen", "type": "temperature_humidity"}, {"ip": "10.84.60.33", "location": "Dyeing-Kitchen", "type": "temperature_humidity"},
{"ip": "10.84.60.34", "location": "Second-Floor", "type": "temperature_humidity"}, {"ip": "10.84.60.34", "location": "Second-Floor", "type": "temperature_humidity"},
{"ip": "10.84.60.35", "location": "Warehouse-A", "type": "temperature_humidity"}, {"ip": "10.84.48.100", "location": "Warehouse-A", "type": "temperature_humidity"},
{"ip": "10.84.60.36", "location": "Lab-Room", "type": "temperature_humidity"}, {"ip": "10.84.48.101", "location": "Lab-Room", "type": "temperature_humidity"},
{"ip": "10.84.60.37", "location": "Office", "type": "cwt_co2"}, {"ip": "10.84.48.102", "location": "Office", "type": "cwt_co2"},
] ]
MODBUS_PORT = 505 MODBUS_PORT = 505
UNIT_ID = 1 UNIT_ID = 1

View File

@ -87,8 +87,8 @@ def read_and_publish_temperature_humidity(mqtt_client, modbus_client, host_info)
topics_data = [ topics_data = [
(f"{base_topic}/Time", current_time), (f"{base_topic}/Time", current_time),
(f"{base_topic}/Status", "online"), (f"{base_topic}/Status", "online"),
(f"{base_topic}/Data/temperature", round(temperature, 1)), (f"{base_topic}/Temperature", round(temperature, 1)),
(f"{base_topic}/Data/humidity", round(humidity, 1)) (f"{base_topic}/Humidity", round(humidity, 1))
] ]
all_published = True all_published = True
@ -149,9 +149,9 @@ def read_and_publish_cwt_co2(mqtt_client, modbus_client, host_info):
topics_data = [ topics_data = [
(f"{base_topic}/Time", current_time), (f"{base_topic}/Time", current_time),
(f"{base_topic}/Status", "online"), (f"{base_topic}/Status", "online"),
(f"{base_topic}/Data/temperature", round(temperature, 1)), (f"{base_topic}/Temperature", round(temperature, 1)),
(f"{base_topic}/Data/humidity", round(humidity, 1)), (f"{base_topic}/Humidity", round(humidity, 1)),
(f"{base_topic}/Data/co2", co2_ppm) (f"{base_topic}/CO2", co2_ppm)
] ]
all_published = True all_published = True