Persist config through backend controller

This commit is contained in:
root
2026-06-03 00:36:08 -06:00
parent fa20478b64
commit e6e74a0b3a
3 changed files with 37 additions and 12 deletions
+10 -2
View File
@@ -35,11 +35,19 @@ class ESP32Simulator:
self.soc = 82.0
self.last_update = time.time()
def config_path(self):
return Path(__file__).parent / "config.json"
def load_config(self):
config_path = Path(__file__).parent / "config.json"
with config_path.open() as f:
with self.config_path().open() as f:
return json.load(f)
def save_config(self, config):
with self.config_path().open("w") as f:
json.dump(config, f, indent=2)
return self.load_config()
def update_battery(self):
now = time.time()
elapsed_hours = (now - self.last_update) / 3600