From 6769ea5b71883dab9cff2eb3bfb5aecb14098fee Mon Sep 17 00:00:00 2001 From: xyj <10908227994@qq.com> Date: Thu, 7 Dec 2023 19:07:47 +0800 Subject: [PATCH] update --- MQTT.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MQTT.py b/MQTT.py index 8d7954c..8f4d49a 100644 --- a/MQTT.py +++ b/MQTT.py @@ -11,19 +11,19 @@ def on_connect(client, userdata, flags, rc): if rc == 0: client.subscribe('lot_mqtt') - def valid(msg, client): p = subprocess.Popen(['cat /home/pi/device_name'], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = p.communicate() device_name = out.decode('utf-8') origin_data = json.loads(msg.payload.decode('utf-8')) + device_name = str(device_name) if 'msg' not in origin_data: client.publish('error', payload='msg must be supplied', qos=0) return False if 'device_name' not in origin_data: client.publish('error', payload='device_name must be supplied', qos=0) return False - if origin_data['device_name'] != device_name: + if str(origin_data['device_name']) != str(device_name): return False return True