-
Notifications
You must be signed in to change notification settings - Fork 196
/
Copy pathgetstatus.py
30 lines (24 loc) · 913 Bytes
/
getstatus.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# TinyTuya Example
# -*- coding: utf-8 -*-
"""
TinyTuya - Example to fetch status of Tuya device
Author: Jason A. Cox
For more information see https://github.com/jasonacox/tinytuya
"""
import tinytuya
import time
# Connect to the device - replace with real values
d=tinytuya.OutletDevice(DEVICEID, DEVICEIP, DEVICEKEY)
d.set_version(3.3)
# Alternative connection - for some devices with 22 character IDs they require a special handling
# d=tinytuya.OutletDevice(DEVICEID, DEVICEIP, DEVICEKEY, 'device22')
# d.set_dpsUsed({"1": None})
# d.set_version(3.3)
# Option for Power Monitoring Smart Plugs - Some require UPDATEDPS to update power data points
# payload = d.generate_payload(tinytuya.UPDATEDPS,['18','19','20'])
# d.send(payload)
# sleep(1)
# Get the status of the device
# e.g. {'devId': '0071299988f9376255b', 'dps': {'1': True, '3': 208, '101': False}}
data = d.status()
print(data)