-
Notifications
You must be signed in to change notification settings - Fork 2
/
MP1.py
37 lines (30 loc) · 870 Bytes
/
MP1.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
31
32
33
34
35
36
#!/usr/bin/python
import broadlink
import sys
device_ip="10.0.0.198"
device_port=80
device_mac="abcdefghijkl"
device_type="broadlink.mp1"
socket = str(sys.argv[1])
action = str(sys.argv[2])
device = broadlink.mp1(host=(device_ip,device_port), mac=bytearray.fromhex(device_mac))
device.auth()
device.host
if action == "on":
if socket == "s1":
device.set_power(1,True)
elif socket == "s2":
device.set_power(2,True)
elif socket == "s3":
device.set_power(3,True)
elif socket == "s4":
device.set_power(4,True)
elif action == "off":
if socket == "s1":
device.set_power(1,False)
elif socket == "s2":
device.set_power(2,False)
elif socket == "s3":
device.set_power(3,False)
elif socket == "s4":
device.set_power(4,False)