nodeq-mqtt-sdt-sdk-template/main.py

22 lines
470 B
Python
Raw Normal View History

2024-03-26 06:23:59 +00:00
import sdtcloudnodeqmqtt
import time
import uuid
import random
sdtcloud = sdtcloudnodeqmqtt.sdtcloudnodeqmqtt()
mqttClient = sdtcloud.setClient(f"device-app-{uuid.uuid1()}") # parameter is client ID(string)
def runAction():
while True:
msg = [{
"house_id": "JJ58",
"device_type": "gas",
"pulse_count": random.randint(0, 1)
}]
sdtcloud.pubMessage(mqttClient, msg)
time.sleep(10)
if __name__ == "__main__":
runAction()