- 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]>
22 lines
811 B
Python
22 lines
811 B
Python
import json
|
|
import os
|
|
|
|
class Account:
|
|
def __init__(self):
|
|
# Load from config/device.json if available, else use defaults
|
|
config = self._load_config()
|
|
self.name = config.get("owner_name", "quoije")
|
|
self.avatar_path = config.get("avatar_path", "img/yaris.png")
|
|
self.pp_image = None
|
|
self.car = 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 {} |