My experiences - LG Smart-TV with Linux control

Hardware:

Raspberrypi 2 Model B

Smart-TV  LG TV 55LB580V  

Connection Raspberrypi via HDMI cable with Smart-TV HDMI Port 2 established   


Smart-TV Software Version

http://www.pedaltreter.at/jsan/lgtv/LGTV_ver.jpg


Version

Download and install  


RASPBIAN JESSIE WITH PIXEL

Image with PIXEL desktop based on Debian Jessie

Version:January 2017

Release date:2017-01-11

Kernel version:4.4


https://www.raspberrypi.org/downloads/raspbian/



Important for remote ssh login (new since 2016)


For headless setup, SSH can be enabled by placing a file named 'ssh', without any extension, onto the boot partition of the SD card.

https://www.raspberrypi.org/documentation/remote-access/ssh/README.md


default user = pi,  passwd = raspberry


after first  login  ….

$ sudo passwd root,  su root, raspi-config, apt-get update, apt-get upgrade usw.



CEC-Client  Installation,  libcec compile

http://constey.de/2014/10/fernseher-ueber-hdmi-per-raspberry-pi-steuern-cec/


With this guide CEC-client brought to run.

After the Line …

To compile libCEC on a new Raspbian installation, follow these instructions:

commands processed


https://github.com/Pulse-Eight/libcec/blob/master/docs/README.raspberrypi.md


sudo apt-get update

sudo apt-get install cmake libudev-dev libxrandr-dev python-dev swig

cd

git clone https://github.com/Pulse-Eight/platform.git

mkdir platform/build

cd platform/build

cmake ..

make

sudo make install

cd

git clone https://github.com/Pulse-Eight/libcec.git

mkdir libcec/build

cd libcec/build

cmake -DRPI_INCLUDE_DIR=/opt/vc/include -DRPI_LIB_DIR=/opt/vc/lib ..

make -j4

sudo make install

sudo ldconfig

```



CNC-Client Test

root@storeme:/opt/lgcommander# cec-client -i

libCEC version: 4.0.2, git revision: libcec-4.0.2, compiled on Sam Feb 11 19:09:25 UTC 2017 by root@storeme on Linux 4.4.38+ (armv6l), features: P8_USB, DRM, P8_detect, randr, RPi


root@storeme:/opt# cec-client -l

libCEC version: 4.0.2, git revision: libcec-4.0.2, compiled on Sam Feb 11 19:09:25 UTC 2017 by root@storeme on Linux 4.4.38+ (armv6l), features: P8_USB, DRM, P8_detect, randr, RPi

Found devices: 1


device:              1

com port:            RPI

vendor id:           2708

product id:          1001

firmware version:    1

type:                Raspberry Pi



root@storeme:/opt# cec-client -s   - got Error

root@storeme:/opt# echo "on 0" | sudo cec-client -s -d 1  -   got Error too


ERROR:   [              69]     RegisterLogicalAddress - vc_cec_set_logical_address(E) returned invalid arg (8)
ERROR:   [              69]     Open - vc_cec could not be initialised



Solution i have found here ... (Thanks sterling)


https://github.com/Pulse-Eight/libcec/issues/191


sterling commented on 13 Jan

I was able to fix this problem for myself by doing: tvservice --off. This will power down the HDMI and open it up for connections again if something you can't identify has taken over.


root@storeme:/opt#  tvservice --off


After that i could turn the  LG Smart-TV via  HDMI on.


root@storeme:/opt# cec-client -s

opening a connection to the CEC adapter...

DEBUG:   [             102]     Broadcast (F): osd name set to 'Broadcast'

DEBUG:   [             109]     logical address changed to Free use (e)

DEBUG:   [             113]     Open - vc_cec initialised

NOTICE:  [             116]     connection opened



root@storeme:/opt# echo "on 0" | sudo cec-client -s -d 1

opening a connection to the CEC adapter...




 Problems with my LG Smart-TV or cec-client 

It only works with the command "echo" on 0 "| Sudo cec-client -s -d 1 "all other commands do not work. No exact documentation about the possibilities (commands) found. Also several command options tried.

Television with CEC-Client switching off:

echo "standby 0" | sudo cec-client -s -d 1

Get power-Status with CEC-Client:

echo "pow 0" | sudo cec-client -s -d 1

Use  CEC-Client for switching to another HDMI Port:

echo "tx 4F 82 10 00" | cec-client -s




More possibilities to Control an LG-Smart-TV with "lgcommander" 

https://klenzel.de/2658

https://github.com/ypid/lgcommander


Installation performed according to the instructions ...


apt-get install python3 python3-tk unzip


cd /opt/ && wget https://github.com/ypid/lgcommander/archive/master.zip

unzip master.zip && rm master.zip

mv lgcommander-master/ lgcommander

cd lgcommander



On the Smart-TV IP address determined 

(Settings Network status)

http://www.pedaltreter.at/jsan/lgtv/LGTV_ip.jpg


IP



lgcommander and LG-Smart-TV pairing 


root@storeme:/opt/lgcommander# ./lgcommander.py -H IP_DES_FERNSEHERS -P roap


Bottom right on the Television you can see the Pairing-Key

http://www.pedaltreter.at/jsan/lgtv/LGTV_cnc.jpg


cnc



..write down the pairing Key (in this example  398129).


The errors in the Terminal (console) can be ignored

The Smart-TV can now controlled  with the following commands

Switch up one channel 

./lgcommander.py -H 192.168.201.106 -P roap -k 398129 -c 27

Switch Television off

./lgcommander.py -H 192.168.201.106 -P roap -k 398129 -c 1




Problems with LGCommander

The table below is incomplete. Some commands do not work. An exact documentation for my LG 55LB580V I could not find.

Command

Action

  27  Channel up

28

Channel down 

24

Volume up

25

Volume down

26

Sound on/off

34

Pause

33

Play

1

TV Power off

23

Back-Key

20

OK-Key

403

Play Last Channelstop

35

Play stop