Controlling a PSU with Kodi on top of OSMC?

Hey guys. So I need some assistance if anyone has the time or energy. I know the basis of what needs to be done, but I’m not to sure about direction of attack for coding. So what I want to do is connect my PSU that is powering my subwoofer for my home theater to my raspberry pi so that I can turn on my subwoofer without having to get up and manually switching the PSU to on.

I’d like to connect a relay to the GPIO pins on the pi, so that I can switch the PS_ON for the PSU to turn on when I press a button or combination button on my pi keyboard. Preferably without involving OSMC so that my input on my receiver doesn’t switch to the pi.

I’m currently using a mac bluetooth keyboard. So I’d like to be able to have some sort of code that allows me to input the button or combination button press to turn the PSU on and off. I’m not sure if that means I need a watchdog script, python script or what. The coding is the part I’m stuck at. Also am I right in needing a 5v DC relay?

Thanks in advanced.

Maybe my setup is inspiring for what you are doing:

I use wireless power sockets to turn things on/off. To control them, a (433MHz) sender is connected to the pi.
With simple bash scripts I can switch each socket independently on/off. For more comfort, I use Mercury (Home · Skarafaz/mercury Wiki · GitHub) to easy trigger the scripts from my mobile phone.

1 Like

The reason why I want to go with a relay is because it will be cheaper. Secondly I don’t have much outlet space. Currently I’ve got two surge protectors back there and they are completely filled out. There just isn’t room for a wireless power socket. Third I don’t ever bring my phone with me when I’m sitting to watch a movie or what have you. As it is I’ve got a keyboard, and two controllers next to me on the couch when we sit down to watch something. So if I can control it without adding to my amount of controllers the better. Which is why I want a single button combination on my keyboard that will turn the relay on or off.

You can get key presses from /dev/input/event*

See also: