# ============================================================================= # config.py - Temperature/Humidity (SHT30) monitoring module (Pi 4 Model B) config — non-secret defaults # # Operational/secret values such as server URL / API_KEY / device identifiers (DEVICE_ID/LOCATION) # are loaded from config_local.py. config_local.py is excluded from commits via .gitignore. # Setup: cp config_local.example.py config_local.py → fill in the real values # # This module is "Module 2" (temperature/humidity). The server (php/) dashboard shows sensor_id=2 as the # default temperature/humidity sensor, so the SENSOR_ID default is set to 2. # ============================================================================= # ───────────────────────────────────────────── # Sensor identity (for server dashboard display; not secret) # SENSOR_ID is the key in the server's leak_sensor_metric / leak_sensor_status. Dashboard default chart=2. # ───────────────────────────────────────────── SENSOR_ID = 2 SENSOR_NAME = "Sensor 2 (SHT30)" # ───────────────────────────────────────────── # I2C bus config (Pi 4 40-pin header) # SDA = GPIO2 (physical pin 3), SCL = GPIO3 (physical pin 5) → I2C bus 1 # ADDR pin: GND=0x44, VDD=0x45 # ───────────────────────────────────────────── I2C_BUS = 1 I2C_ADDR = 0x44 # Force simulation. If True, runs with dummy measurements without hardware (for server integration checks). # Even if False, the driver auto-falls back to simulation when smbus2 is not installed / I2C is disabled. FORCE_SIMULATION = False # ───────────────────────────────────────────── # Measurement/report intervals (same defaults as firmware app_config.h) # ───────────────────────────────────────────── REPORT_INTERVAL = 300 # Normal measure/report interval (seconds) = 5 minutes MEASURE_RETRY_DELAY = 5 # Wait before retry after a failed measurement (seconds) # ───────────────────────────────────────────── # Physical plausibility range for temp/humidity (same as firmware classify_metric_status) # Values outside this range are reported as metric_status="out_of_range". # * Operational threshold judgments (high/low temp, high/low humidity) and SMS are all handled # by the server (config.php METRIC_*). This module only faithfully reports measurements. # ───────────────────────────────────────────── TEMP_LOW_C = -40.0 TEMP_HIGH_C = 125.0 RH_LOW = 0.0 RH_HIGH = 100.0 # Module identity version (server app_version field; the server only records it, does not validate) APP_VERSION = "v2606-sht30-rpi4" # ───────────────────────────────────────────── # Logging config # ───────────────────────────────────────────── LOG_FILE = "/var/log/sht30_sensor.log" LOG_MAX_BYTES = 5 * 1024 * 1024 # 5MB LOG_BACKUP_COUNT = 3 # ───────────────────────────────────────────── # HTTP retry config (same defaults as firmware APP_HTTP_*) # ───────────────────────────────────────────── HTTP_TIMEOUT = 10 # Single request timeout (seconds) HTTP_RETRY_COUNT = 3 # Number of retries HTTP_RETRY_DELAY = 5 # Wait between retries (seconds) # ───────────────────────────────────────────── # Load operational/secret values (fail closed) # If config_local.py is missing, abort immediately with a clear error instead of # starting incorrectly with placeholder/hardcoded secrets. # ───────────────────────────────────────────── try: from config_local import ( # noqa: F401 (sht30_sensor.py re-imports from config) API_URL, API_KEY, DEVICE_ID, DEVICE_LOCATION, ) except ImportError as e: raise RuntimeError( "config_local.py not found. " "Run `cp config_local.example.py config_local.py`, then fill in the real server URL / API_KEY / " "device info. (Never commit secret values.)" ) from e