Update tracker for status offline dont publish string or number
This commit is contained in:
@ -101,13 +101,10 @@ class SensorTracker:
|
||||
|
||||
alert_message = {
|
||||
"alert_type": "sensor_failure",
|
||||
"timestamp": datetime.now(LOCAL_TIMEZONE).isoformat(),
|
||||
"sensor_id": sensor_id,
|
||||
"sensor_ip": sensor["ip"],
|
||||
"sensor_location": sensor["location"],
|
||||
"sensor_type": sensor["type"],
|
||||
"consecutive_failures": sensor["consecutive_failures"],
|
||||
"last_error": sensor.get("last_error", "Unknown error"),
|
||||
"last_error": sensor.get("last_error"),
|
||||
"severity": "critical"
|
||||
}
|
||||
|
||||
@ -128,9 +125,6 @@ class SensorTracker:
|
||||
|
||||
alert_message = {
|
||||
"alert_type": "sensor_recovery",
|
||||
"timestamp": datetime.now(LOCAL_TIMEZONE).isoformat(),
|
||||
"sensor_id": sensor_id,
|
||||
"sensor_ip": sensor["ip"],
|
||||
"sensor_location": sensor["location"],
|
||||
"sensor_type": sensor["type"],
|
||||
"consecutive_successes": sensor["consecutive_successes"],
|
||||
@ -156,14 +150,14 @@ class SensorTracker:
|
||||
# Publish offline status to match online sensor structure
|
||||
topics_data = [
|
||||
(f"{base_topic}/Time", current_time),
|
||||
(f"{base_topic}/Status", "offline"),
|
||||
(f"{base_topic}/Temperature/temperature", "offline"),
|
||||
(f"{base_topic}/Humidity/humidity", "offline")
|
||||
(f"{base_topic}/Status"),
|
||||
(f"{base_topic}/Temperature/temperature"),
|
||||
(f"{base_topic}/Humidity/humidity")
|
||||
]
|
||||
|
||||
# Add CO2 topic for CO2 sensors
|
||||
if host_info["type"] == "cwt_co2":
|
||||
topics_data.append((f"{base_topic}/CO2/CO2", "offline"))
|
||||
topics_data.append((f"{base_topic}/CO2/CO2"))
|
||||
|
||||
# Publish offline status
|
||||
for topic, value in topics_data:
|
||||
|
Reference in New Issue
Block a user