-
Notifications
You must be signed in to change notification settings - Fork 0
/
Lampka.py
28 lines (22 loc) · 897 Bytes
/
Lampka.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
# ==================================== #
# control-tuya_smarthome #
# Lampka #
# ==================================== #
# ------------ import libs ----------- #
import tinytuya
import constants # file
# --------------- magic -------------- #
device = tinytuya.BulbDevice(constants.Lampka_device_ID, constants.Lampka_device_IP, constants.Lampka_device_key) # device = Lampka
device.set_version(3.3) # Tuya protocol version
data = device.status() # get info about device (on/off, mode, etc.)
# print(data) # debug
# print(data.get('dps',{}).get('20')) # debug
if data.get('dps',{}).get('20') == True: # check device's status to see if it's turned on or off
print('Device is turned ON.')
print('Switching OFF...')
device.turn_off()
else:
print('Device is turned OFF.')
print('Switching ON...')
device.turn_on()
print('Done.')