import json import os class Car: def __init__(self): # Load from config/device.json at startup # Database values are updated via Settings UI, but Car object reflects startup state 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 {}