-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapi_manager.py
More file actions
31 lines (26 loc) · 929 Bytes
/
Copy pathapi_manager.py
File metadata and controls
31 lines (26 loc) · 929 Bytes
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
import samsungctl
from wakeonlan import send_magic_packet
import time
class API_Manager:
def send(self, device, args):
if device.type == 'SamsungTv':
if args['key'] == 'WOL':
send_magic_packet(device.mac, port=8001)
else:
config = {
"name": "samsungctl",
"description": "PC",
"id": "",
"host": "",
"port": 8001,
"method": "websocket",
"timeout": 1,
}
config['host'] = device.address
try:
with samsungctl.Remote(config) as remote:
remote.control(args['key'])
except :
return
def __init__(self, device_manager):
device_manager.add_api_manager(self)