Files
yaris-obd/modules/app_account.py
Mathieu MoranandCopilot 585da18225 feat: add remote device settings portal and Pi hot reload
- add /settings/device portal page and portal device-config GET endpoint
- add portal navigation and client-side device settings editor UI
- hot-reload Account/Car display config after local saves and server syncs
- document portal workflow and Phase 25.5b completion
- add runtime reload tests for account, car, and sync callback

Co-authored-by: Copilot <[email protected]>
2026-08-10 17:34:22 -04:00

30 lines
1.1 KiB
Python

import json
import os
class Account:
def __init__(self):
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 reload_runtime_config(self):
"""Refresh display-facing fields from the live device config store."""
from . import app_device_config
config = app_device_config.get_device_config()
self.name = config.get("owner_name", "quoije")
self.avatar_path = config.get("avatar_path", "img/yaris.png")
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 {}