tutorial-app2/main.py

28 lines
603 B
Python
Raw Normal View History

2024-04-23 02:31:54 +00:00
import sdtcloudpubsub
import time
import uuid
import random
sdtcloud = sdtcloudpubsub.sdtcloudpubsub()
2024-04-29 09:02:33 +00:00
sdtcloud.setClient(f"device-app-{uuid.uuid1()}") # parameter is client ID(string)
2024-04-23 02:31:54 +00:00
def runAction():
while True:
msg = [{
"room_id": "room1",
"sensor": "power",
"value": random.randint(100, 1000)
},
{
"room_id": "room2",
"sensor": "power",
"value": random.randint(100, 1000)
}]
2024-04-29 09:02:33 +00:00
sdtcloud.pubMessage(msg)
2024-04-23 02:31:54 +00:00
time.sleep(2)
if __name__ == "__main__":
runAction()