I had an old laptop laying around and I decided to install a Nintendo emulator for my kids. My kids are playing WIIU games like Mario 3D, Mario Kart and Yoshi’s Woolly world. Because they are too young to turn on my Ubuntu laptop and start the game I made an automation for them so they can easily start it.
All they have to say is:
“Hey Google, Start [Yoshi/Mario 3D/Mario Kart]”
Google is firing the corresponding script in Home Assistant:
alias: nintendo_start_mario_kart
sequence:
- service: script.turn_on_ubuntu_laptop
data: {}
- service: shell_command.nintendo_start_mario_kart
data: {}
mode: single
icon: mdi:nintendo-wiiu
alias: nintendo_start_mario3d
sequence:
- service: script.turn_on_ubuntu_laptop
data: {}
- service: shell_command.nintendo_start_mario_3d
data: {}
mode: single
icon: mdi:nintendo-wiiu
alias: nintendo_start_yoshi
sequence:
- service: script.turn_on_ubuntu_laptop
data: {}
- service: shell_command.nintendo_start_yoshi # execute shell script on ubuntu to start the corresponding game
data: {}
mode: single
icon: mdi:nintendo-wiiu
The first thing all these 3 scripts do is call another script to boot the computer:
# scripts.yaml
alias: turn_on_ubuntu_laptop
sequence:
- if:
- condition: device
type: is_off
device_id: 660735b84ad21a093a8b77ac58d7c3f8
entity_id: 53d7964c8815b92f1a040da2bbdb98db
domain: switch
then:
- service: switch.turn_on # turn on power switch ubuntu laptop. Laptop will boot because of AC power.
data: {}
target:
device_id: 660735b84ad21a093a8b77ac58d7c3f8
alias: Turn on power switch Nintendo
- service: tts.google_say
data:
cache: false
entity_id: media_player.sonos_beam
message: Nintendo is starting
- service: media_player.volume_set
data:
volume_level: 0.3
target:
device_id: 6627e509a04bd0a56361f455eeb2a77f
- if:
- condition: not
conditions:
- condition: state
entity_id: binary_sensor.nintendo
state: "on"
then:
- service: wake_on_lan.send_magic_packet # when you want to boot your computer using WOL.
data:
broadcast_port: 9
broadcast_address: 192.168.30.102
mac: xx:xx:xx:xx:xx:xx
enabled: true
- delay:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
alias: Wake on Lan Nintendo laptop
mode: single
icon: mdi:nintendo-switch
I configured my bios to boot when AC power is connected. This can be simple done with a power switch off course. Another solution is to boot using WOL (see last part of above script). I configured Ubuntu to autologin.
The script also sets the volume and then waits 1 minute before going further.
Next is executing the corresponding game shell command on my Ubuntu laptop. My Home Assistant can access my Ubuntu laptop using SSH keys.
# shell_command.yaml
nintendo_start_mario_3d: "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /config/.keys_ssh/id_rsa [email protected] '/home/user/Scripts/start_cemu_mario3d.sh' 2> /config/command.log"
nintendo_start_mario_kart: "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /config/.keys_ssh/id_rsa [email protected] '/home/user/Scripts/start_cemu_mario_kart.sh' 2> /config/command.log"
nintendo_start_yoshi: "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /config/.keys_ssh/id_rsa [email protected] '/home/user/Scripts/start_cemu_yoshi.sh' 2> /config/command.log"
Those bash scripts are like this:
#!/bin/bash
# kill any running Cemu appimage
pidof AppRun.wrapped | xargs kill -9
wait 2 # seconds
# choose HDMI as output
export DISPLAY=:0
# start CEMU application with game
/home/user/Applications/Cemu-2.0-37-x86_64.AppImage -g /home/user/Roms/wiiu/games/Yoshis_Woolly_World_USA.wua -f
The only thing my wife or I has to do is turn on the television and set the right HDMI source. This because our television isn’t supported, but if you have a newer television you can also add this.
When my kids are done playing they can tell to shutdown the Ubuntu laptop and turn of the power switch:
“Hey Google, Stop Nintendo”
It’s possible to add some conditions like time slots or confirmations for parental control, but for now I’m keeping it like this.
I’m using CEMU as emulator for the WIIU, but there are many more others. Be sure to check the rules before you are using an emulator and games to play!