Switch on Raspberry Pi using MQTT

In my ManCave I use my own Android App (AndyMOTE) to control my media setup. Here I have a Raspberry Pi 4 running LibreElec. The idea is that I push a button on the AndyMOTE App and it automatically switches on the devices required; in this case “Watch Kodi” causes the Tv to be switched on with HDMI #1 selected, the AV amp switched on and the correct input selected and Raspberry Pi switched on.

The problem is, you cannot switch a Raspberry Pi on using, for example, Wake on LAN.

One solution is to just leave the Raspberry Pi running, however, as the Pi 4 runs quite hot, I really didn’t want to do this. Also I want to switch off a hard drive, connected to the RPi, when the Kodi system has been shut-down.

Shut down is no problem; I just use a simple Home-Assistant automation thus:

alias: Turn Kodi ManCave OFF
trigger:
  platform: state
  entity_id: sensor.mancave_kodi
  to: "off"
action:
  service: kodi.call_method
  data:
    entity_id: media_player.mancave_kodi
    method: System.Shutdown

My solution: to connect a relay to Pins 5 & 6 on my Pi 4 and control this from another Raspberry Pi using MQTT to signal when to trigger the relay.

I interested, you can see a more detailed Application Note describing this setup here and view my HomeAssistant configuration here.

Wait. How are you saving power if you need another always on pi?

After cleanly shutting down the pi (using Kodi System Shutdown as above) turning the power off using a smart switch (pi plug pack into smart switch) should use less power. Turing the smart switch on will cause the pi to boot. Use whatever method you want on the pi to cause Kodi to run at boot.

Unless you need that other pi always on for other things. Then it’s a smart solution.

@tom_i . agree using a smart switch is an alternative solution. In my case the other pi is always on so the infrastructure was always there. It works for me and was a fun little project to do.

I hope someone finds the post useful. The project is expandable to use more relays (you can buy boards with 8 relays on them) and control other things, of course.

1 Like

A Pi to turn on another Pi. I like it, you could even get away with with turning off things like HDMI and the LED’s if you want to use very little power on the other Pi.

I sonoff basic flashed with tasmota may use a little less power but I also always like to use what I already have.