Wake on Lan for my NAS Qnap in indigo

Posted on
Thu Sep 24, 2015 10:36 pm
artpics offline
Posts: 232
Joined: Feb 24, 2009
Location: Calabasas CA

Wake on Lan for my NAS Qnap in indigo

hi found this and want to add a button schedule that runs a python script in indigo so i can wake my NAS up from anywhere WAN will this script work. My NAS is on Port 100. and using a time capsule.

http://www.sbprojects.com/projects/raspberrypi/wol.php

would be nice if anyone can help me :D

Posted on
Fri Sep 25, 2015 12:32 am
MarcoGT offline
Posts: 1091
Joined: Sep 11, 2014
Location: Germany

Re: Wake on Lan for my NAS Qnap in indigo

I also have an action to wake my NAS (Synology);
it is a simple script which sends a magic packet; I will post my script this evening when at home.
Unfortunately from here I cannot open your link.

Posted on
Fri Sep 25, 2015 1:02 pm
artpics offline
Posts: 232
Joined: Feb 24, 2009
Location: Calabasas CA

Re: Wake on Lan for my NAS Qnap in indigo

Thanks the nas is the best thing since hmmm indigo

Posted on
Sat Sep 26, 2015 11:15 pm
artpics offline
Posts: 232
Joined: Feb 24, 2009
Location: Calabasas CA

Re: Wake on Lan for my NAS Qnap in indigo

i have tried this as an embedded and a external script .py but it does not work, but no errors in the log.
do i need to do any thing else :(

Code: Select all
#!/usr/bin/env python
import socket
s=socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
s.sendto('\xff'*6+'\x00\x0F8\x^B\xF1\xJD\x76'*16, ('255.255.248.0', 9))


Posted on
Sun Sep 27, 2015 7:09 am
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Wake on Lan for my NAS Qnap in indigo

What's the IP address of the NAS? And what is the network range for your LAN? Are you really using a 255.255.248.0 netmask everywhere?

Have you tried port 7 instead of 9?

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Sep 27, 2015 2:53 pm
artpics offline
Posts: 232
Joined: Feb 24, 2009
Location: Calabasas CA

Re: Wake on Lan for my NAS Qnap in indigo

nas.jpg
nas.jpg (21.01 KiB) Viewed 3265 times


the network range is 10.1.1.2 to 10.0.1.200
i can wake it from my LAN iPhone app and browser when i log in but not indigo :(
have tried port 9 and 7 using a time capsule here

10.0.1.100

UDP ports 9
Public Ports 9

---
UDP ports 9
Public Ports 9

Posted on
Sun Sep 27, 2015 4:16 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Wake on Lan for my NAS Qnap in indigo

Your subnet mask probably needs to be 255.255.255.0, but I don't know if that's really going to make a difference.

How are you using a browser to wake it up?

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Sun Sep 27, 2015 9:25 pm
artpics offline
Posts: 232
Joined: Feb 24, 2009
Location: Calabasas CA

Re: Wake on Lan for my NAS Qnap in indigo

YAY :D Fixed. took a bit of fiddling with the 255s. Will trim the code down later :lol:
runs a separate applescript

Code: Select all
set question to display dialog "But it's sleeping! Are you sure you want to wake up the NAS?" buttons {"Yes", "No"} default button 1 with icon caution
set answer to button returned of question

if answer is equal to "Yes" then
   
   do shell script "python -c \"

import socket

data = '\\xff'*6+'\\x00\\x88\\x8B\\x81\\x8C\\x76'*16

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)

s.sendto(data, ('255.255.255.255', 9))\""
   
end if



Source:
https://github.com/mt33/wakeupnas

Or we can i can do it in Python.

Code: Select all
#!/usr/bin/env python
import socket
s=socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
s.sendto('\xff'*6+'\x01\x088\x9B\xD1\xCD\x96'*16, ('255.255.255.255', 9))


Posted on
Thu Oct 01, 2015 1:23 pm
MarcoGT offline
Posts: 1091
Joined: Sep 11, 2014
Location: Germany

Re: Wake on Lan for my NAS Qnap in indigo

This is the script that I am using to WOL my Sinology NAS

Code: Select all
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import socket
import struct

def sendWakeOnLAN(macaddress):
    # Check macaddress format and try to compensate.
    if len(macaddress) == 12:
        pass
    elif len(macaddress) == 12 + 5:
        sep = macaddress[2]
        macaddress = macaddress.replace(sep, '')
    else:
        raise ValueError('Incorrect MAC address format')
 
    # Pad the synchronization stream.
    data = ''.join(['FFFFFFFFFFFF', macaddress * 20])
    send_data = ''

    # Split up the hex values and pack.
    for i in range(0, len(data), 2):
        send_data = ''.join([send_data, struct.pack('B', int(data[i: i + 2], 16))])

    # Broadcast it to the LAN.
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
    sock.sendto(send_data, ('<broadcast>', 7))
   
macAddress = '00:11:32:20:A9:3C'  # Replace with the mac Address of the machine you want to wake up
sendWakeOnLAN(macAddress)

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 9 guests