28 lines
620 B
Python
28 lines
620 B
Python
import sdtcloudpubsub
|
|
import time
|
|
import uuid
|
|
import random
|
|
|
|
sdtcloud = sdtcloudpubsub.sdtcloudpubsub()
|
|
mqttClient = sdtcloud.setClient(f"device-app-{uuid.uuid1()}") # parameter is client ID(string)
|
|
|
|
def runAction():
|
|
while True:
|
|
msg = [{
|
|
"room_id": "room1",
|
|
"sensor": "temp",
|
|
"value": random.randint(18, 27)
|
|
},
|
|
{
|
|
"room_id": "room2",
|
|
"sensor": "temp",
|
|
"value": random.randint(18, 27)
|
|
|
|
}]
|
|
sdtcloud.pubMessage(mqttClient, msg)
|
|
time.sleep(2)
|
|
|
|
if __name__ == "__main__":
|
|
runAction()
|
|
|