There are generally 2 ways to control TVs:
- IR
- RS-232
Newer TVs might have Ethernet or Wi-Fi connections available, and also some level of support for CEC. You might be able to control them over the network with a manufacturer-specific app, but probably not via a documented protocol. CEC control was very spotty when it came out. I'm not sure if it's gotten more robust in the past couple of years.
There are DIY and commercial options for IR and RS-232. The internet has no shortage of DIY guides for Arduinos and Raspberry PIs over IR.
In the Professional AV field, RS-232 control is what's most often used. Basically, you open a telnet session on a com port, spew some commands, and the TV does stuff. The protocol documents for the 232 ports are usually available on the manufacturers website, or as part of a users manual, and there's usually a section for the command protocol. You may need a physical adapter for the RS-232 port. For example, 3.5mm to DB9, or RS-232c to DB9. Keep in mind that RS-232 and network based control gives your program feedback, while IR does not.
The OP settled on CEC, but anyone else will need to start with the specific make/model of the TV before you can attempt to figure out what its control options are (IR, 232, network, etc). Commercial TVs always have 232 ports, while residential TVs might or might not.
If you want to futz with ProAV stuff, you can usually get it online for pretty cheap. However, the software is harder to come by. Most often, the manufacturer won't give you their free software unless you're in a business relationship with them. Brands to look for: Savant, Crestron, Extron, Control4, or a company that has a booth at Infocomm (AV tradeshow).
I don't feel like I need a disclaimer, but I do work in Professional AV. Not at any of the companies listed.