Refactor sensor data publishing and health check server configuration. Updated MQTT topic structure for individual data points, improved error handling, and added garbage collection to manage memory. Enhanced logging for health check server accessibility and sensor status updates.
This commit is contained in:
43
config.py
43
config.py
@ -33,46 +33,3 @@ HEALTH_CHECK_ENABLED = True
|
||||
ALERTING_ENABLED = True
|
||||
SENSOR_TIMEOUT_THRESHOLD = 3 # Number of consecutive failures before alert
|
||||
RECOVERY_CONFIRMATION_COUNT = 2 # Number of consecutive successes to confirm recovery
|
||||
|
||||
# Sensor status tracking - now integrated into data payload
|
||||
# New topic structure: Location/{location_name}/{sensor_type}/{data_type}
|
||||
# Where sensor_type is: "temperature-humidity" or "CO2-gas"
|
||||
# Where data_type is: "data" or "alerts"
|
||||
# Example topics:
|
||||
# - Location/Warehouse-B/temperature-humidity/data (contains temp, humidity, status)
|
||||
# - Location/Office/CO2-gas/data (contains co2, temp, humidity, status)
|
||||
# - Location/Warehouse-B/temperature-humidity/alerts (contains failure/recovery alerts)
|
||||
|
||||
# New MQTT Topic Structure:
|
||||
# Base: Location/{location_name}/{sensor_type}/{data_type}
|
||||
#
|
||||
# Data topics: Location/{location_name}/{sensor_type}/data
|
||||
# Alert topics: Location/{location_name}/{sensor_type}/alerts
|
||||
#
|
||||
# Payload format for data (JSON):
|
||||
# {
|
||||
# "timestamp": "2024-01-01 12:00:00",
|
||||
# "location": "Warehouse-B",
|
||||
# "sensor_type": "temperature-humidity",
|
||||
# "ip": "10.84.60.31",
|
||||
# "status": "online|offline",
|
||||
# "data": {
|
||||
# "temperature": 25.5,
|
||||
# "humidity": 60.2
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# Payload format for alerts (JSON):
|
||||
# {
|
||||
# "alert_type": "sensor_failure|sensor_recovery",
|
||||
# "timestamp": "2024-01-01T12:00:00.000000+00:00",
|
||||
# "sensor_id": "10.84.60.31_Warehouse-B",
|
||||
# "sensor_ip": "10.84.60.31",
|
||||
# "sensor_location": "Warehouse-B",
|
||||
# "sensor_type": "temperature_humidity",
|
||||
# "consecutive_failures": 3,
|
||||
# "last_error": "Failed to read data",
|
||||
# "severity": "critical|info"
|
||||
# }
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user