This repository has been archived on 2023-06-10. You can view files and clone it, but cannot push or open issues or pull requests.
Kai Wansart 842f703a05 fix wol
2018-02-02 20:48:32 +01:00

42 lines
1.6 KiB
Python

from wakeonlan import wol
##---------------------------------------------------------------------------------------##
class WOL(object):
##---------------------------------------------------------------------------------------##
##-----------------------------------------------------------------------------------##
def __init__(self, devices):
##-----------------------------------------------------------------------------------##
count = 0
self.devices= {}
for device in devices:
self.devices[device] = devices[device]['mac']
##-----------------------------------------------------------------------------------##
def config(self):
##-----------------------------------------------------------------------------------##
config = {
"device" : {
"name" : "",
"mac" : ""
},
"wake" : {
"device" : "name",
"state" : "button"
}
}
return config
##-----------------------------------------------------------------------------------##
def command(self, data):
##-----------------------------------------------------------------------------------##
for device in data:
if device in self.devices:
self.wakeDevice(device)
##-----------------------------------------------------------------------------------##
def wakeDevice(self, device):
##-----------------------------------------------------------------------------------##
mac = self.devices[device]
wol.send_magic_packet(mac)