server current
This commit is contained in:
@@ -74,6 +74,18 @@ def create_make_coffee():
|
|||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
#temp --------------------------------------------
|
||||||
|
conn = sqlite3.connect(DB_PATH_COFFEE)
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute("""
|
||||||
|
INSERT INTO coffee (user, status)
|
||||||
|
VALUES (?, ?)
|
||||||
|
""", ("admin", "served"))
|
||||||
|
conn.commit()
|
||||||
|
conn.close()
|
||||||
|
#temp --------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
return fullCommand
|
return fullCommand
|
||||||
|
|
||||||
def create_coffee_entry():
|
def create_coffee_entry():
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ def toggle_machine():
|
|||||||
|
|
||||||
return jsonify({"status": json.dumps(fullCommand)})
|
return jsonify({"status": json.dumps(fullCommand)})
|
||||||
|
|
||||||
@esp.route('/make_coffee', methods=['POST'])
|
@esp.route('/make-coffee', methods=['POST'])
|
||||||
def make_coffee():
|
def make_coffee():
|
||||||
"""Endpoint to create a command to make coffee."""
|
"""Endpoint to create a command to make coffee."""
|
||||||
fullCommand = create_make_coffee()
|
fullCommand = create_make_coffee()
|
||||||
@@ -57,5 +57,15 @@ def make_coffee():
|
|||||||
client.connect(MQTT_BROKER, MQTT_PORT, 60)
|
client.connect(MQTT_BROKER, MQTT_PORT, 60)
|
||||||
client.publish(MQTT_TOPIC, json.dumps(fullCommand))
|
client.publish(MQTT_TOPIC, json.dumps(fullCommand))
|
||||||
client.disconnect()
|
client.disconnect()
|
||||||
|
water = load_dict("water")
|
||||||
|
water["fill"] = water["fill"] - 14
|
||||||
|
water["coffeesOnFill"] = water["coffeesOnFill"] + 1
|
||||||
|
save_dict("water", water)
|
||||||
|
beans = load_dict("beans")
|
||||||
|
beans["fill"] = beans["fill"] - 7
|
||||||
|
beans["coffeesOnFill"] = beans["coffeesOnFill"] + 1
|
||||||
|
save_dict("beans", beans)
|
||||||
|
|
||||||
|
resend_static_data()
|
||||||
|
|
||||||
return jsonify({"status": json.dumps(fullCommand)})
|
return jsonify({"status": json.dumps(fullCommand)})
|
||||||
@@ -131,6 +131,7 @@ def monitor_esp_connection():
|
|||||||
esp_conn_infos["connection_valid"] = False
|
esp_conn_infos["connection_valid"] = False
|
||||||
data = load_dict("machine")
|
data = load_dict("machine")
|
||||||
data["state"] = "OFF"
|
data["state"] = "OFF"
|
||||||
|
data["ready"] = False
|
||||||
save_dict("machine", data)
|
save_dict("machine", data)
|
||||||
resend_static_data()
|
resend_static_data()
|
||||||
time.sleep(60) # einmal pro Minute die Verbindung zum ESP prüfen
|
time.sleep(60) # einmal pro Minute die Verbindung zum ESP prüfen
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ gebId("ip_local").innerText = esp_conn_infos.ip_local
|
|||||||
gebId("valid_connection").innerText = esp_conn_infos.connection_valid
|
gebId("valid_connection").innerText = esp_conn_infos.connection_valid
|
||||||
gebId("last_seen").innerText = esp_conn_infos.last_seen
|
gebId("last_seen").innerText = esp_conn_infos.last_seen
|
||||||
machienReady = gebId("machine-ready-butt")
|
machienReady = gebId("machine-ready-butt")
|
||||||
makeCoffee = gebId("make-coffee-butt")
|
makeCoffeeVar = gebId("make-coffee-butt")
|
||||||
if(machine.status == "OFF"){
|
if(machine.status == "OFF"){
|
||||||
gebId("machine-status").innerText = "AUS";
|
gebId("machine-status").innerText = "AUS";
|
||||||
gebId("machine-status-butt").classList.add("initBackRed");
|
gebId("machine-status-butt").classList.add("initBackRed");
|
||||||
@@ -32,7 +32,7 @@ if(machine.berror){
|
|||||||
gebId("machiene-error-text").innerText = machine.error;
|
gebId("machiene-error-text").innerText = machine.error;
|
||||||
}
|
}
|
||||||
if(machine.ready && machine.state == "ON" && !machine.berror && esp_conn_infos.connection_valid){
|
if(machine.ready && machine.state == "ON" && !machine.berror && esp_conn_infos.connection_valid){
|
||||||
makeCoffee.classList.remove("deniePress");
|
makeCoffeeVar.classList.remove("deniePress");
|
||||||
}
|
}
|
||||||
if(machine.ready){
|
if(machine.ready){
|
||||||
machienReady.classList.remove("initBackRed");
|
machienReady.classList.remove("initBackRed");
|
||||||
@@ -100,11 +100,11 @@ function makeCoffee(){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log("makeCoffee")
|
console.log("makeCoffee")
|
||||||
fetch('/unsecure/esp/make_coffee', {method: 'POST'})
|
fetch('/unsecure/esp/make-coffee', {method: 'POST'})
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(data =>{
|
.then(data =>{
|
||||||
console.log(data)
|
console.log(data)
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
function waterRefill(){
|
function waterRefill(){
|
||||||
if (gebId("water-fill").parentElement.classList.contains("deniePress")){
|
if (gebId("water-fill").parentElement.classList.contains("deniePress")){
|
||||||
|
|||||||
@@ -68,11 +68,11 @@ socket.on('static_data', (data) => {
|
|||||||
gebId("machiene-error-text").innerText = "Keiner";
|
gebId("machiene-error-text").innerText = "Keiner";
|
||||||
}
|
}
|
||||||
machienReady = gebId("machine-ready-butt")
|
machienReady = gebId("machine-ready-butt")
|
||||||
makeCoffee = gebId("make-coffee-butt")
|
makeCoffeeVar2 = gebId("make-coffee-butt")
|
||||||
if(data.machine.ready && data.machine.state == "ON" && !data.machine.berror && data.esp_conn_infos.connection_valid){
|
if(data.machine.ready && data.machine.state == "ON" && !data.machine.berror && data.esp_conn_infos.connection_valid){
|
||||||
makeCoffee.classList.remove("deniePress");
|
makeCoffeeVar2.classList.remove("deniePress");
|
||||||
}else {
|
}else {
|
||||||
makeCoffee.classList.add("deniePress");
|
makeCoffeeVar2.classList.add("deniePress");
|
||||||
}
|
}
|
||||||
if(data.machine.ready){
|
if(data.machine.ready){
|
||||||
machienReady.classList.remove("initBackRed");
|
machienReady.classList.remove("initBackRed");
|
||||||
|
|||||||
Reference in New Issue
Block a user