This commit is contained in:
derlole
2025-04-29 13:07:50 +00:00
parent ac0bbcff90
commit 9721905617
4 changed files with 57 additions and 44 deletions

View File

@@ -7,7 +7,7 @@ esp = Blueprint('eps', __name__, url_prefix='/unsecure/esp')
MQTT_BROKER = "localhost" # oder IP/Domain
MQTT_PORT = 1883
MQTT_TOPIC = "iot/machine"
MQTT_TOPIC = "coffee/command"
@esp.route('/')
def fetch_command():
@@ -17,16 +17,11 @@ def fetch_command():
@esp.route('/toggle-machine', methods=['POST'])
def toggle_machine():
pCd = shared.pending_command
shared.reset_command()
pCd['command'] = 'machineToggle'
pCd['command-URL'] = 'NO_URL'
pCd['command-expected'] = 'machineStatusResponse'
pCd['command-expected-URL'] = 'http://lires.de/unsecure/esp/machine-status'
testData = {'test': 'Live-Daten', 'status': 'OK', 'counter': 0}
client = mqtt.Client()
client.connect(MQTT_BROKER, MQTT_PORT, 60)
client.publish(MQTT_TOPIC, json.dumps(pCd))
client.publish(MQTT_TOPIC, json.dumps(testData))
client.disconnect()
return jsonify({"status": json.dumps(pCd)})
return jsonify({"status": json.dumps(testData)})