Control LG Tv with FHEM

If you want to integrate your LG TV in the FHEM home automation solution, my 82_LGTV2011.pm and 82_LGTV2012.pm modules can help. Here a short tutorial on how to get it working:

First you have to find out which API your LG TV uses. In principle there are three different APIs (1.0/2.0/3.0) corresponding to the 2011, 2012 and 2013 series. The former should use the LGTV_2011 module whereas the latter should use the LGTV_2012 module. If you are not sure which series you have, you can also try the two LG Remote apps and see which one works (2011 / 2012).

Make sure these perl modules are installed:

LWP::UserAgent
HTTP::Request::Common
XML::SIMPLE

If you are on a linux box:

If you are on another machine with full perl:

Before you install XML::Simple, you must have an XML parser module like XML::Parser or XML::SAX installed. The easiest way then is to install with the CPAN shell:

If you are on an embedded system like the Fritzbox, you probably don’t have CPAN, so you have to download the modules by hand and put them in your perl installation.

Now you can define the TV in fhem for 2011 series :

and for 2012 series and up:

To power on, you can use a cec-client and define a poweroncmd:

And finally an example by Franz Tenbrock how to build a soft remote with the remotecontrol module:

remotecontrol

Furthermore the fhem discussion board members Kuzl & Franz developed an electronic program guide for fhem which can be integrated as follows:

Add the following definitions to your fhem.cfg

Download the channel icons from here and put them into /opt/fhem/www/images/default and do a shutdown restart.

Switching to channels in the EPG currently only works for the lgtv2011 module.
In 99_myUtils.pm add the function:

Make sure channelMap is adjusted to your sender positions.

Now you should be able to see the current and upcoming programs and switch to them by simply clicking on them.

EPG