implement: Phase 25.5 device config from JSON file
- Create config/device.json with owner_name, car_model, device_name, avatar_path - Update app_account.py to load owner_name and avatar_path from config - Update app_car.py to load car_model and device_name from config - Update base.html template to use avatar_path from config instead of hardcoded - Add graceful fallback to hardcoded defaults if config file missing - Document in deploy/readme.md and readme.md how to customize device identity - Update PLAN.md Phase 25.5 to reflect current implementation and future server sync Benefits: - No code edits needed to customize Pi (edit JSON file only) - Offline-first: all values loaded from local file at startup - Connection-driven sync planned for Phase 25.5a (sync when internet available, not on timer) - Server becomes source of truth after Phase 25.5a implementation All 63 tests passing. Database filename still based on owner_name, with migration warning in docs. Co-authored-by: Copilot <[email protected]>
This commit is contained in:
+19
-2
@@ -1,4 +1,21 @@
|
||||
import json
|
||||
import os
|
||||
|
||||
class Car:
|
||||
def __init__(self):
|
||||
self.model = "Yaris 2013"
|
||||
self.obd = None
|
||||
# Load from config/device.json if available, else use defaults
|
||||
config = self._load_config()
|
||||
self.model = config.get("car_model", "Yaris 2013")
|
||||
self.device_name = config.get("device_name", "Yaris OBD")
|
||||
self.obd = None
|
||||
|
||||
def _load_config(self):
|
||||
"""Load device config from JSON file, return dict with defaults."""
|
||||
config_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "config", "device.json")
|
||||
try:
|
||||
if os.path.exists(config_path):
|
||||
with open(config_path, 'r') as f:
|
||||
return json.load(f)
|
||||
except (IOError, json.JSONDecodeError):
|
||||
pass
|
||||
return {}
|
||||
Reference in New Issue
Block a user