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:
Naab2k3
2025-06-24 09:26:08 +07:00
parent 7b8934b1d0
commit 84e7babf7e
5 changed files with 18 additions and 13 deletions

View File

@ -1,5 +1,6 @@
import time
import os
from datetime import timezone, timedelta
# Modbus configuration
MODBUS_HOSTS = [
@ -34,3 +35,6 @@ HEALTH_CHECK_ENABLED = os.getenv("HEALTH_CHECK_ENABLED", "true").lower() in ["tr
ALERTING_ENABLED = os.getenv("ALERTING_ENABLED", "true").lower() in ["true", "1", "yes"]
SENSOR_TIMEOUT_THRESHOLD = int(os.getenv("SENSOR_TIMEOUT_THRESHOLD", 3)) # Number of consecutive failures before alert
RECOVERY_CONFIRMATION_COUNT = int(os.getenv("RECOVERY_CONFIRMATION_COUNT", 2)) # Number of consecutive successes to confirm recovery
# Timezone configuration - Vietnam timezone (GMT+7)
LOCAL_TIMEZONE = timezone(timedelta(hours=int(os.getenv("TIMEZONE_OFFSET", 7)))) # Default GMT+7 for Vietnam