soem reworks
This commit is contained in:
BIN
aaaSonstiges/prog_proj_sw_struct_full.pdf
Normal file
BIN
aaaSonstiges/prog_proj_sw_struct_full.pdf
Normal file
Binary file not shown.
BIN
db/commands.db
BIN
db/commands.db
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"state": "PENDING",
|
||||
"state": "OFF",
|
||||
"connected": false,
|
||||
"ready": false,
|
||||
"peding_command": false,
|
||||
|
||||
@@ -13,8 +13,6 @@ from modules.db import create_toggle_machine, create_make_coffee
|
||||
|
||||
esp = Blueprint('eps', __name__, url_prefix='/unsecure/esp')
|
||||
|
||||
# DB_PATH = os.path.join(os.path.dirname(__file__), '../db/commands.db')
|
||||
|
||||
MQTT_BROKER = "localhost" # oder IP/Domain
|
||||
MQTT_PORT = 1883
|
||||
MQTT_TOPIC = "coffee/command"
|
||||
@@ -36,25 +34,11 @@ def esp_online():
|
||||
@esp.route('/toggle-machine', methods=['POST'])
|
||||
def toggle_machine():
|
||||
fullCommand = create_toggle_machine()
|
||||
# randID = random.randint(1000, 9999)
|
||||
# fullCommand = {'command': 'toggle_machine', 'status': 'pending', 'command_id': randID}
|
||||
# conn = sqlite3.connect(DB_PATH)
|
||||
# cursor = conn.cursor()
|
||||
|
||||
# cursor.execute("""
|
||||
# INSERT INTO commands (command, status, command_id)
|
||||
# VALUES (?, ?, ?)
|
||||
# """, (fullCommand["command"], fullCommand["status"], fullCommand["command_id"]))
|
||||
|
||||
|
||||
new_status = load_dict("machine")
|
||||
new_status["state"] = "PENDING"
|
||||
save_dict("machine", new_status)
|
||||
|
||||
# resend_static_data()
|
||||
|
||||
# conn.commit()
|
||||
# conn.close()
|
||||
|
||||
client = mqtt.Client()
|
||||
client.connect(MQTT_BROKER, MQTT_PORT, 60)
|
||||
@@ -66,18 +50,7 @@ def toggle_machine():
|
||||
@esp.route('/make_coffee', methods=['POST'])
|
||||
def make_coffee():
|
||||
fullCommand = create_make_coffee()
|
||||
# randID = random.randint(1000, 9999)
|
||||
# fullCommand = {'command': 'make_coffee', 'status': 'pending', 'command_id': randID}
|
||||
# conn = sqlite3.connect(DB_PATH)
|
||||
# cursor = conn.cursor()
|
||||
|
||||
# cursor.execute("""
|
||||
# INSERT INTO commands (command, status, command_id)
|
||||
# VALUES (?, ?, ?)
|
||||
# """, (fullCommand["command"], fullCommand["status"], fullCommand["command_id"]))
|
||||
|
||||
# conn.commit()
|
||||
# conn.close()
|
||||
client = mqtt.Client()
|
||||
client.connect(MQTT_BROKER, MQTT_PORT, 60)
|
||||
client.publish(MQTT_TOPIC, json.dumps(fullCommand))
|
||||
|
||||
@@ -80,22 +80,29 @@ switch (machine.state) {
|
||||
}
|
||||
// All there
|
||||
function toggleMachine() {
|
||||
// if (gebId("machine-status-butt").classList.contains("deniePress")){
|
||||
// return;
|
||||
// }
|
||||
// // console.log("toggleMachine");
|
||||
// const result = confirm("Möchtest du den Vorgang wirklich ausführen?");
|
||||
// if (!result) {
|
||||
// return;
|
||||
// }
|
||||
if (gebId("machine-status-butt").classList.contains("deniePress")){
|
||||
return;
|
||||
}
|
||||
// console.log("toggleMachine");
|
||||
const result = confirm("Möchtest du den Vorgang wirklich ausführen?");
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
console.log("toggleMachine");
|
||||
fetch('/unsecure/esp/toggle-machine', { method: 'POST' })
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
console.log(data);
|
||||
});
|
||||
}
|
||||
|
||||
function makeCoffee(){
|
||||
console.log("makeCoffee")
|
||||
fetch('/unsecure/esp/make_coffee', {method: 'POST'})
|
||||
.then(res => res.json())
|
||||
.then(data =>{
|
||||
console.log(data)
|
||||
})
|
||||
}
|
||||
function waterRefill(){
|
||||
if (gebId("water-fill").parentElement.classList.contains("deniePress")){
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user