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.

42 lines
1.6 KiB
Python
Raw Normal View History

2018-02-02 00:21:59 +01:00
from wakeonlan import wol
##---------------------------------------------------------------------------------------##
class WOL(object):
##---------------------------------------------------------------------------------------##
##-----------------------------------------------------------------------------------##
def __init__(self, devices):
##-----------------------------------------------------------------------------------##
count = 0
2018-02-02 17:23:44 +01:00
self.devices= {}
2018-02-02 00:21:59 +01:00
for device in devices:
self.devices[device] = devices[device]['mac']
2018-02-02 17:23:44 +01:00
##-----------------------------------------------------------------------------------##
def config(self):
##-----------------------------------------------------------------------------------##
config = {
"device" : {
"name" : "",
"mac" : ""
},
"wake" : {
"device" : "name",
"state" : "button"
}
}
return config
2018-02-02 20:11:26 +01:00
##-----------------------------------------------------------------------------------##
def command(self, data):
##-----------------------------------------------------------------------------------##
for device in data:
if device in self.devices:
2018-02-02 20:48:32 +01:00
self.wakeDevice(device)
2018-02-02 20:11:26 +01:00
2018-02-02 00:21:59 +01:00
##-----------------------------------------------------------------------------------##
def wakeDevice(self, device):
##-----------------------------------------------------------------------------------##
2018-02-02 20:48:32 +01:00
mac = self.devices[device]
wol.send_magic_packet(mac)
2018-02-02 00:21:59 +01:00