37 lines
1.8 KiB
Python
37 lines
1.8 KiB
Python
import time
|
|
import os
|
|
|
|
# Modbus configuration
|
|
MODBUS_HOSTS = [
|
|
{"ip": "10.84.60.31", "location": "Warehouse-B", "type": "temperature_humidity"},
|
|
{"ip": "10.84.60.32", "location": "Warehouse-C", "type": "temperature_humidity"},
|
|
{"ip": "10.84.60.33", "location": "Dyeing-Kitchen", "type": "temperature_humidity"},
|
|
{"ip": "10.84.60.34", "location": "Second-Floor", "type": "temperature_humidity"},
|
|
{"ip": "10.84.60.35", "location": "Warehouse-A", "type": "temperature_humidity"},
|
|
{"ip": "10.84.60.36", "location": "Lab-Room", "type": "temperature_humidity"},
|
|
{"ip": "10.84.60.37", "location": "Office", "type": "cwt_co2"},
|
|
]
|
|
MODBUS_PORT = 505
|
|
UNIT_ID = 1
|
|
|
|
# MQTT configuration
|
|
MQTT_BROKER = os.getenv("MQTT_BROKER", "mqtt.service.mesh")
|
|
MQTT_PORT = int(os.getenv("MQTT_PORT", 1883))
|
|
# Legacy topic - now using dynamic topic structure: {location}/{sensor_type}/data
|
|
MQTT_TOPIC = "Temperature_Humidity" # Keep for backward compatibility
|
|
MQTT_CLIENT_ID = f"modbus-mqtt-client-{int(time.time())}"
|
|
MQTT_USERNAME = os.getenv("MQTT_USERNAME", "relay")
|
|
MQTT_PASSWORD = os.getenv("MQTT_PASSWORD", "Sey@K9c&Q4^")
|
|
|
|
# Read and publish cycle configuration (seconds)
|
|
PUBLISH_INTERVAL = int(os.getenv("PUBLISH_INTERVAL", 10))
|
|
|
|
# Health check and alerting configuration
|
|
HEALTH_CHECK_PORT = int(os.getenv("HEALTH_CHECK_PORT", 8080))
|
|
HEALTH_CHECK_ENABLED = os.getenv("HEALTH_CHECK_ENABLED", "true").lower() in ["true", "1", "yes"]
|
|
|
|
# Alerting configuration
|
|
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
|