Enabling Wake-on-Lan with the N34 Mini PC
There is a room at the top of my house which was originally earmarked for storage (the loft is full of insulation rather than being a useful option). Then I remembered I still had my pico projector and it ended up as a cinema room as well. The pico projector needs really low light conditions with a long throw, so the fact the room only has a single small window is a plus.
I bought an “N34” mini PC to act as a media player - I already had a spare DVB-T2 stick to Freeview enable things, and the Kodi box downstairs has all my DVDs stored on it for easy streaming. It’s a Celeron N3450 based box with 4G RAM and a 32GB internal eMMC (though I’m currently running off an SD card because that’s what I initially used to set it up and I haven’t bothered to copy it onto the internal device yet). My device came from Amazon and is branded “Kodlix” (whose website no longer works) but it appears to be the same thing as the Beelink AP34.
Getting Linux onto it turned out to be a hassle. GRUB does not want to play with the EFI BIOS; it can be operated sometimes if manually called from the EFI Shell, but it does not work as the default EFI image to load. Various forum posts recommended the use of rEFInd, which mostly works fine.
Other than that Debian Stretch worked without problems. I had to pull in a backports kernel in order to make the DVB-T2 stick work properly, but the hardware on the N34 itself was all supported out of the box.
The other issue was trying to get Wake-on-Lan to work. The room isn’t used day to day so I want to be able to tie various pieces together with home automation such that I can have everything off by default and a scene configured to set things up ready for use. The BIOS has an entry for Wake-on-Lan, ethtool
reported Supports Wake-on: g
which should mean MagicPacket wakeup was enabled, but no joy. Looking at /proc/acpi/wakeup
gave:
/proc/acpi/wakeup contents
Device S-state Status Sysfs node
HDAS S3 *disabled pci:0000:00:0e.0
XHC S3 *enabled pci:0000:00:15.0
XDCI S4 *disabled
BRCM S0 *disabled
RP01 S4 *disabled
PXSX S4 *disabled
RP02 S4 *disabled
PXSX S4 *disabled
RP03 S4 *disabled pci:0000:00:13.0
PXSX S4 *disabled pci:0000:01:00.0
RP04 S4 *disabled
PXSX S4 *disabled
RP05 S4 *disabled
PXSX S4 *disabled
RP06 S4 *disabled pci:0000:00:13.3
PXSX S4 *disabled pci:0000:02:00.0
PWRK S4 *enabled platform:PNP0C0C:00
pci:0000:01:00.0
is the network card:
01:00.0 Ethernet controller [0200]: Realtek […] Ethernet Controller [10ec:8168] (rev 0c)
I need this configured to allow wakeups which apparently is done via sysfs these days:
echo enabled > /sys/bus/pci/devices/0000\:01\:00.0/power/wakeup
This has to be done every boot so I just tied it into /etc/network/interfaces
.
All of this then enables Home Assistant to control the Kodi box:
Home Assistant Kodi WoL configuration
wake_on_lan:
media_player:
- platform: kodi
name: Kodi (Cinema)
host: kodi-cinema.here
port: 8000
username: kodi
password: !secret kodi_cinema_pass
enable_websocket: false
turn_on_action:
service: wake_on_lan.send_magic_packet
data:
mac: 84:39:be:11:22:33
broadcast_address: 192.168.0.2
turn_off_action:
service: media_player.kodi_call_method
data:
entity_id: media_player.kodi_cinema
method: System.Shutdown
My Home Assistant container sits on a different subnet to the media box, and I found that the N34 wouldn’t respond to a Wake-on-Lan packet to the broadcast MAC address. So I’ve configured the broadcast_address
for Home Assistant to be the actual IP of the media box, allowed UDP port 9 (discard) through on the firewall and statically nailed the ARP address of the media box on the router, so it transmits the packet with the correct destination MAC:
ip neigh change 192.168.0.2 lladdr 84:39:be:11:22:33 nud permanent dev eth0
I’ve still got some other bits to glue together (like putting the pico projector on a SonOff), but this gets me started on that process.
(And yes, the room is a bit cosier these days than when that photograph was taken.)