Spaces:
Sleeping
Sleeping
alamak
Browse files
app.py
CHANGED
|
@@ -24,7 +24,7 @@ TOPIC_PRED = "sic7/stage4/DI-Binary/prediction"
|
|
| 24 |
MQTT_PORT = 1883
|
| 25 |
|
| 26 |
# Define the client globally so process_loop can use it
|
| 27 |
-
client = mqtt.Client()
|
| 28 |
|
| 29 |
model = joblib.load("rf_model.pkl")
|
| 30 |
print("Model loaded!")
|
|
@@ -33,8 +33,8 @@ logs = []
|
|
| 33 |
message_queue = queue.Queue()
|
| 34 |
|
| 35 |
# ================= MQTT Callbacks =================
|
| 36 |
-
def on_connect(client, userdata, flags, rc):
|
| 37 |
-
print("Connected
|
| 38 |
client.subscribe(TOPIC_SENSOR)
|
| 39 |
|
| 40 |
def on_message(client, userdata, msg):
|
|
|
|
| 24 |
MQTT_PORT = 1883
|
| 25 |
|
| 26 |
# Define the client globally so process_loop can use it
|
| 27 |
+
client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2)
|
| 28 |
|
| 29 |
model = joblib.load("rf_model.pkl")
|
| 30 |
print("Model loaded!")
|
|
|
|
| 33 |
message_queue = queue.Queue()
|
| 34 |
|
| 35 |
# ================= MQTT Callbacks =================
|
| 36 |
+
def on_connect(client, userdata, flags, rc, properties):
|
| 37 |
+
print(f"Connected with result code {rc}", flush=True)
|
| 38 |
client.subscribe(TOPIC_SENSOR)
|
| 39 |
|
| 40 |
def on_message(client, userdata, msg):
|