live reload recipe/actuator changes
This commit is contained in:
parent
645292d5a5
commit
81f2a37aae
13
app.py
13
app.py
|
@ -131,10 +131,21 @@ def run_recipes():
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
|
||||||
def read_sensors():
|
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:
|
while True:
|
||||||
sensors.read()
|
sensors.read()
|
||||||
socketio.emit('sensors', (sensors.get(),))
|
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
|
import threading
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -284,6 +284,10 @@ function dismiss_modal() {
|
||||||
applyState(state);
|
applyState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reload_recipes() {
|
||||||
|
socket.emit('reload recipes');
|
||||||
|
}
|
||||||
|
|
||||||
function render_load_recipe(data) {
|
function render_load_recipe(data) {
|
||||||
let html = document.getElementById("load-recipe");
|
let html = document.getElementById("load-recipe");
|
||||||
if (html === null) return;
|
if (html === null) return;
|
||||||
|
|
Loading…
Reference in New Issue