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:
@ -7,7 +7,7 @@ import time
|
||||
import socket
|
||||
import os
|
||||
|
||||
from config import HEALTH_CHECK_PORT, HEALTH_CHECK_ENABLED
|
||||
from config import HEALTH_CHECK_PORT, HEALTH_CHECK_ENABLED, LOCAL_TIMEZONE
|
||||
|
||||
class SimpleHealthHandler(BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
@ -34,7 +34,7 @@ class SimpleHealthHandler(BaseHTTPRequestHandler):
|
||||
try:
|
||||
health_data = {
|
||||
"status": "healthy",
|
||||
"timestamp": datetime.now(timezone.utc).isoformat(),
|
||||
"timestamp": datetime.now(LOCAL_TIMEZONE).isoformat(),
|
||||
"service": "poe-sensor",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
@ -82,7 +82,7 @@ class SimpleHealthHandler(BaseHTTPRequestHandler):
|
||||
error_data = {
|
||||
"error": "Sensor data unavailable",
|
||||
"message": str(e),
|
||||
"timestamp": datetime.now(timezone.utc).isoformat()
|
||||
"timestamp": datetime.now(LOCAL_TIMEZONE).isoformat()
|
||||
}
|
||||
response = json.dumps(error_data, indent=2)
|
||||
self.send_response(500)
|
||||
|
Reference in New Issue
Block a user