HA Wake on LAN not sending packet

Hey guys,
I want to wake my PC with WOL packet via HA. From android app or another pc it works fine. (Using also Wireshark to capture incoming packets). Homeassistant is running on raspos within docker as a container

Current config:

switch:
  - platform: wake_on_lan
    name: "NzXT"
    mac: aa:bb:cc:dd:ee:ff
    broadcast_address: 192.168.0.255

Also tried broadcast_port: 9 and tried to enclose mac address with quotes or double quotes - did not help. I can ping PC from raspi. I’ve also tried Developer tools → Services → Wake on LAN: send magic packet

service: wake_on_lan.send_magic_packet
data:
  mac: aa:bb:cc:dd:ee:ff
  broadcast_address: 192.168.0.255
  broadcast_port: 9

and it also does not send any packet (maybe it sends but I don’t catch packet in wireshark)

I’ve tested also python script and PC successfully received magic packet

from wakeonlan import send_magic_packet
send_magic_packet('aa:bb:cc:dd:ee:ff', port=9)

Are you using host networking for your container? It won’t work if you don’t.

Yes, it came to my mind but I hadn’t time to try it and yes, that was the issue. I’ve been using container with exposed ports so I could not use host network but I did workaround. Thanks

Out of curiosity, what is you workaround?
Did you find a way around the host networking with WOL, or are you using some other way?

Sorry for late reply.

I had to change the network where container had been connected to. I’ve followed this solution with small changes

Can you paste your docker compose / config?

docker-compose.yaml

version: '3'
services:
  homeassistant:
    container_name: homeassistant
    image: "homeassistant/home-assistant:latest"
    volumes:
      - /localpath/homeassistant/config:/config
      - /localpath/homeassistant/tmp:/tmp
      - /etc/localtime:/etc/localtime:ro
    network_mode: "host"
    restart: always
    privileged: true

config in configuration.yaml

switch:
  - platform: wake_on_lan
    name: "PC Name"
    mac: ff:bb:dd:cc:bb:aa
    host: 192.168.0.240
    broadcast_address: 192.168.0.255
    broadcast_port: 9

and this is script in HA to call the service

alias: wake up PC
sequence:
  - service: wake_on_lan.send_magic_packet
    data:
      broadcast_port: 9
      broadcast_address: 255.255.255.255
      mac: ff:bb:dd:cc:bb:aa
mode: single

I would suggest you to install WireShark on your PC you want to wake up and check if you are receiving this magic packet. Plus be sure to have wake up on lan function enabled in windows & bios