Add timezone configuration and update health check timestamps in POE project. Introduced LOCAL_TIMEZONE in config.py to support timezone offset configuration. Updated health_check.py, sensor_bridge.py, and sensor_tracker.py to utilize LOCAL_TIMEZONE for accurate timestamping in health responses and sensor data publishing. Enhanced README.md to document the new TIMEZONE_OFFSET environment variable, ensuring clarity for configuration options.
This commit is contained in:
@ -10,7 +10,7 @@ import paho.mqtt.client as mqtt
|
||||
from config import (
|
||||
MODBUS_HOSTS, MODBUS_PORT, UNIT_ID,
|
||||
MQTT_BROKER, MQTT_PORT, MQTT_TOPIC, MQTT_CLIENT_ID,
|
||||
MQTT_USERNAME, MQTT_PASSWORD, PUBLISH_INTERVAL
|
||||
MQTT_USERNAME, MQTT_PASSWORD, PUBLISH_INTERVAL, LOCAL_TIMEZONE
|
||||
)
|
||||
|
||||
def on_connect(client, userdata, flags, rc):
|
||||
@ -80,7 +80,7 @@ def read_and_publish_temperature_humidity(mqtt_client, modbus_client, host_info)
|
||||
# Publish data
|
||||
location = host_info["location"]
|
||||
sensor_type = "temperature-humidity"
|
||||
current_time = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S")
|
||||
current_time = datetime.now(LOCAL_TIMEZONE).strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
base_topic = f"Location/{location}/{sensor_type}"
|
||||
|
||||
@ -142,7 +142,7 @@ def read_and_publish_cwt_co2(mqtt_client, modbus_client, host_info):
|
||||
# Publish data
|
||||
location = host_info["location"]
|
||||
sensor_type = "CO2-gas"
|
||||
current_time = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S")
|
||||
current_time = datetime.now(LOCAL_TIMEZONE).strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
base_topic = f"Location/{location}/{sensor_type}"
|
||||
|
||||
|
Reference in New Issue
Block a user