A smart TV is on the wall, connected to the LAN, and the remote is just out of reach. The ads just started. Who would want to move off the couch when there's a laptop on the lap?
There are apps for cellphones that can control such TVs. So there is a way to send such commands.
A manual with remote control to virtual key mappings is here.
There are also various scripts in python and ruby and so on for the control. They often tend to be somewhat convoluted. But they are a good starting point.
A lot of useful documentation about the control (and hacking and firmware updates) is maintained by our brothers Russians at https://github.com/openlgtv (formerly http://openlgtv.org.ru/).
The TV has a LAN socket. (More modern ones have a wifi connection.) And a serial port. And a HDMI-CDC bus. These can be used for controlling the device.
A bash script was written that sends the commands to the TV.
Won't switch the TV on. It is said some TVs have wake-on-LAN functionality that can be enabled from some menu.