Persist config through backend controller
This commit is contained in:
+10
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user