After searching for a week for a simple and easy way to turn On/Off a Raspberry Pi via the TV, and not finding a good solution, I found a simple, clean easy inexpensive non-intrusive way via a $8.00 relay switch. If you can do simple splicing and know very basic wiring you can do this with LibreELEC running Kodi.
Preface: I have all my movies on a Western Digital 4TB portable hard drive that is connected to a Raspberry Pi 4B via USB 3.0, any version of a Pi would work. The Pi's video out goes to the TV's HDMI in. I am using LebreELEC/Kodi only. Turning Kodi off is easy via the Kodi ‘s O/S, but the issue was that the Pi can’t be turned back on although power remains plugged in? To me this is useless as you can’t turn it back on! The biggest grip is that although it’s being powered, you can’t turn it back on so being powered has no real purpose (except the clock) other than wasting power even though it's very low and people say just leave it on. I also prefer to have it completely off as I don't care about the clock. The popular method everyone seems to use, plug/unplug or put a switch on the power USB cable causes the time to be lost also so apparently many are accepting of this method.
I found many other ways how to make the Pi be able to be turned On or Off; a manual On/Off switch on the power supply, a remote controlled powered On/Off switch on the power outlet, plug/unplug the power supply (the lamest), add on boards, IR diodes, add on boards that you have to install software or some add on boards to the GPO which take up space inside the Pi case which is already very limited. I rather leave all that open and available for other things if needed inside the case as there is not a lot of room. I wanted no additional remotes, or deal with software or drilling the case (I have a FLIRC case) for IR’s or have any wires coming out the case. This method also does not interfere with the board itself, gives the box a clan appearance, does not need to use any additional power off the board or cause heat or amp loading issues and is very easy to do.
So cutting the power gave me an idea to use the TV's 5V USB port as a trigger/power supply. Someone may ask why not run the hard drive directly through the TV? I can, but the media center the TV has built in is awful, a far cry from being able to manage anything or be useful as a media center, no artwork, or movie info, etc. I can run the Pi off the TV USB port, but only by itself as the TV’s USB port does not have enough amps to drive both devices at once.
The solution was this relay switch: DZS Elec 5V-30V I channel Wilde Voltage Adjustable Relay Switch
1. All that is needed to be modified on the relay switch itself is to remove/unsolder the momentary button trigger and solder a wire across the switch to have a continuous closed contact across the switch. This will keep the relay switch on as long as there is power via the 5V input of the Micro USB 5V input.
2. Connect a USB cable from the switch's Micro USB input 5V to the TV's USB port. As long as when the TV is off and it turns off the power on the USB port this will work perfectly. I can confirm this works on a Hisense 65” TV.
3. The third part is to take the power cable you are using to power your Pi and tap or cut it to get to one line, either Red or Black. Tapping is best so you can leave all the other wires intact as they will not be used. You only need to tap or cut/use ONE line, either the Red or Black, but not both! All other wires may be left alone or taped off. Take ONE of the cut lines (ie: Red), and connect one side of that cut line to the COM (Public COM) terminal on the relay switch terminal and the OTHER side of that cut Red wire to the NO (Normally Open NO) terminal. If you cut the Red, do not cut the Black wire, leave the back wire alone as all the other wires in the power cable as they are not to be used. If you look at the diagram, you would simply take both ends of the ONE cut wire’s two ends (Red for example) and connect one side of the cut wire to the terminal named Public COM and the other cut side of the wire to the Normally Open NO terminal.
Note: You will NOT use the Normally Closed terminal (NC). You do not need to worry about the relay time setting of 0~24 either as it will be bypassed due to closing of the button trigger switch. You also Do Not need to connect anything else to power the relay ie: trigger (TRIG) low level trigger or the terminals labeled Input + or Input - as they are not used when you connect a Micro SUB 5V input cable as they are just an alternative power input.
Running/Using: Plug the power cable into the power supply that was powering the Pi (on both ends) and connect the relay switch's 5V USB input power supply to the TV's USB port. When you turn on the TV, the USB port of the TV will energize the relay switch and power it on via the Micro USB input 5V. The light on the relay will turn on and stay on, this will power up the Pi.
After you are done for the day/night and ready to power off Kodi, use the O/S to power off and then when you turn off the TV, it will turn off the TV's USB port removing power to the relay switch which will power off the Pi.
I hope this helps someone who is looking for a simple inexpensive reliable solid way to turn on and off their Pi.