I am creating a device that requires a TV to be powered on and off when commanded by the code in my Raspberry Pi 3 B+. The Raspberry Pi also needs some sensing ability to know if the TV is on or off, so it can execute the turn on function when necessary, or turn it off when necessary. I am going to eliminate the IR sensor on the TV so it can't be messed with by remotes. I am going to be controlling two TV's in this fashion, independent of one another. My TV has the generic button circuit board that is typical on TV's and monitors. All in all, I am not sure how I will do this from a hardware perspective.
closed as unclear what you're asking by Dmitry Grigoryev, Sean Houlihane, RoyC, Finbarr, Lior Bilia Sep 14 '18 at 12:44
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
You can use CEC (via HDMI) - I use libcec to turn my TV on and off with a RPi running a media centre. It also allows you to monitor the power state of the TV with the RPi.
Simple method is using an IR Blaster cable, a IR transmitter tapped over the Tv's IR sensor, and a opto sensor over the Tv's power led. This would prevent other remotes from working by physically covering the sensor, and would avoid having to modify the TV internally. Existing RPi tv control code can work. The opto sensor is how you tell of the tv is on.
You did not specify which TV you want to control, so I don't know if it possible for you.
I did same for my TV which has RS232 communication for command interface. So I opened TV and disconnected PCB with IR module (and hardware buttons) and connected to RS232 via level shifter, it worked perfectly.