kbr / fritzconnection

Python-Tool to communicate with the AVM Fritz!Box by the TR-064 protocol and the AHA-HTTP-Interface
MIT License
304 stars 59 forks source link

Wake on LAN support #29

Closed marianheinsen closed 4 years ago

marianheinsen commented 4 years ago

Does the API already have WOL support? I couldn't find it in the FritzHosts class

kbr commented 4 years ago

In general fritzconnection can access every service and action provided by AVM. In case of WOL this can be done like (with fc as a FritzConnection instance):

# get info:
addr = '00:17:F2:04:XX:XX'  # device MAC address
info = fc.call_action('Hosts1', 
                      'X_AVM-DE_GetAutoWakeOnLANByMACAddress',
                       NewMACAddress=addr)
print(info)

# set state:
args = {
    'NewMACAddress': addr,
    'NewAutoWOLEnabled': 0,  # 1  [off|on]
}
fc.call_action('Hosts1', 
               'X_AVM-DE_SetAutoWakeOnLANByMACAddress', 
                arguments=args)

Classes like FritzHosts are just wrappers for calling (a subset of) actions and mainly serve as examples how to use FritzConnection. However, the library modules can evolve with time. So it's possible to include the code above in one of the next releases.

kbr commented 4 years ago

FritzHosts include WOL support with version 1.3.0