Have to save when using espnow

This commit is contained in:
jimmy 2025-06-08 13:18:28 +12:00
parent c63e907204
commit a19b1e86f2
3 changed files with 5 additions and 4 deletions

View File

@ -34,7 +34,7 @@ async def main():
data = json.loads(msg)
print(data)
if settings["id"] in data["ids"] or settings["id"] == 0:
settings.set_settings(data["settings"], patterns)
settings.set_settings(data["settings"], patterns, data.get("save", False))
print("should not print")
async def wifi_connect():

View File

@ -49,7 +49,7 @@ class Settings(dict):
self.set_defaults()
self.save()
def set_settings(self, data, patterns):
def set_settings(self, data, patterns, save):
try:
print(data)
for key, value in data.items():
@ -85,7 +85,8 @@ class Settings(dict):
return "Invalid key", 400
self[key] = value
patterns.sync()
self.save()
if save:
self.save()
return "OK", 200
except (KeyError, ValueError):
return "Bad request", 400

View File

@ -35,7 +35,7 @@ def web(settings, patterns):
if data:
# Process the received data
_, status_code = settings.set_settings(json.loads(data), patterns)
_, status_code = settings.set_settings(json.loads(data), patterns, True)
#await ws.send(status_code)
else:
break