# -*- coding: utf-8 -*-
# cython: language_level=3
import json
import paho.mqtt.client as mqtt

# 创建MQTT客户端
client = mqtt.Client(protocol=mqtt.MQTTv311)

# 连接服务器
broker_address = "192.168.5.215"
port = 1883
client.connect(broker_address, port)

# 发布消息

cliet_udid = '3d53149e-408f-56c6-99ef-29fae67f8efc'
topic = "/maintain/room/online/" + cliet_udid + "/"
message = {
    "udid": cliet_udid,
    "action": "online",
    "value": 1
}
client.publish(topic, json.dumps(message), qos=0)

# 断开连接
client.disconnect()
