Network Binding Help WOL on different subnet

Hello again, I’m here with another problem.
I’m running OH3 on docker, (migrating from 2.5) with network set up as a bridge.
Previously I had a simple item to turn my pc on like this

Switch   My_PC    "My PC"    { wol="192.168.1.123#AF:2F:0F:CF:0F:2F", autoupdate="false" }

The openhab server was (and still is) on 192.168.4.10 and my pc on 192.168.1.238
So I had a static ARP mapping for the IP 192.168.1.123 → mac-address = ff:ff:ff:ff:ff:ff setup on my router
which worked fine.

With the new binding the broadcast is sent to 127.20.0.255 (docker network)…
Setting the docker network to host would still not help since it would then sent it to 192.168.4.255 which would not be of any help and besides, it’s set up as bridge for other reasons…

i’m currently following the example bellow which doesn’t help…

val actions = getActions("network", "network:pingdevice:devicename")
if (actions === null) {
    logInfo("actions", "Actions not found, check thing ID")
    return
} else {
    actions.sendWakeOnLanPacket()
}

Any ideas or solutions or workarounds?

PS. sending a magic packet to 192.168.1.123 from another docker container, on the same docker network works like a charm

AFAIK, the WOL packet has to be send to the subnets broadcast address with the target MAC address.
Don‘t use the target IP address.

I know, but I don’t see a way to configure the network binding to do anything like that. As far as I can tell it simply sends the packet to the brodcast address of the network openhab is running on.
On the old WOL binding I cound actualy set the destination IP

OK, so I found a workaround.
Still not sure how to send a WOL to a different subnet with the Network Binding BUT I did it with a script.
I found a python script that does it from a user called rschuetzler on github.
With some minor modification it works like a charm :slight_smile:
Of course you need to install the Jython-Scripting Automation

import socket, struct

class Waker():
    def makeMagicPacket(self, macAddress):
        # Take the entered MAC address and format it to be sent via socket
        splitMac = str.split(str(macAddress),':')
    
        # Pack together the sections of the MAC address as binary hex
        hexMac = struct.pack('BBBBBB', int(splitMac[0], 16),
                             int(splitMac[1], 16),
                             int(splitMac[2], 16),
                             int(splitMac[3], 16),
                             int(splitMac[4], 16),
                             int(splitMac[5], 16))
    
        self.packet = '\xff' * 6 + hexMac * 16 #create the magic packet from MAC address
    
    def sendPacket(self, packet, destIP, destPort = 7):
        # Create the socket connection and send the packet
        s=socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.sendto(packet,(destIP,destPort))
        s.close()
        
    def wake(self, macAddress, destIP, destPort=7):
        self.makeMagicPacket(macAddress)
        self.sendPacket(self.packet, destIP, destPort)
        print 'Packet successfully sent to', macAddress
        
if __name__ == '__main__':
    #This is all the information that needs to be changed to make this work for you
    mac = 'AF:2F:0F:CF:0F:2F' #The MAC address of the device you want to wake
    ip = '192.168.1.123' #The IP address where the packet should be sent
    port = 9 #The port the packet will be sent on
    
    wol = Waker()
    wol.makeMagicPacket(mac)
    wol.sendPacket(wol.packet, ip, port)