live reload recipe/actuator changes

This commit is contained in:
Nicolò Balzarotti 2023-02-21 14:02:07 +01:00
parent 645292d5a5
commit 81f2a37aae
2 changed files with 16 additions and 1 deletions

13
app.py
View File

@ -131,10 +131,21 @@ def run_recipes():
sleep(1)
def read_sensors():
periodi_counter = 0
scantime = 0.5
periodic_state_every_s = 5
periodic_state_every_loop = int(periodic_state_every_s/scantime)
while True:
sensors.read()
socketio.emit('sensors', (sensors.get(),))
sleep(0.5)
if periodic_counter % periodic_state_every == 0:
## peridoic refresh other data, too, like:
# - current phase (time in this phase)
# - actuators (consumption)
# Issuing a full state update is easiest
updateState()
periodi_counter += 1
sleep(scantime)
import threading
if __name__ == '__main__':

4
dist/server.js vendored
View File

@ -284,6 +284,10 @@ function dismiss_modal() {
applyState(state);
}
function reload_recipes() {
socket.emit('reload recipes');
}
function render_load_recipe(data) {
let html = document.getElementById("load-recipe");
if (html === null) return;