This script will turn off LG TV (> 2011) when you turn off the TV box (via KODI power menu, remote controller or button on the box).
LG smart TVs are very known for their very bad implementation of HDMI CEC protocol, at least old TV models <2015 (does not support power off via CEC command)
Copy service file shutdown_with_net.service to folder /storage/.config/system.d/
Put your shutdown script shutdown_with_net.sh to folder /storage/.config/
Put your python script lg_tv_control_lan.py to folder /storage/.config/
Edit python script lg_tv_control_lan.py and set TV ip address and paring key
Pairing key could be found also by running script sh shutdown_with_net.sh with TV IP address and pairing random key, once executed in the shell, TV displays pairing your key
Set permissions for the service and scripts chmod 755 shutdown_with_net.sh and chmod 755 lg_tv_control_lan.py and chmod 755 shutdown_with_net.service
Start the service, systemctl enable shutdown_with_net.service
Restart the box
Reference readings which lead to functional script:
Does this mean I can press the power off button on the remote control, while in kodi, and it will also power off my LG TV? If so, will it also power on my LG TV when I press the power key on my remote control to power on my CE box?
@Habibie, as Poida said, script is just for powering OFF LG TV. It has no influence to power on sequence.
For power ON LG TV via TV BOX, this does not work now for me in CoreELEC but it does work with Android stock 7.1.1 firmware KIII PRO. So I am expecting either wrong config of CEC driver for LibreELEC / CoreELEC or wrong system setup on my side (I was not able to power on the TV even by using cec client commands). I am planning to make a test to go back to Android image again and re-run clean CoreELEC and LibreELEC from SD card in order to verify if it works or not.
Integrate what? A script that was designed for a subset of LG TVs?
With that said, our CEC support has been improved a lot since this post was originally made, and CEC is pretty much spot-on on SBCs with our custom u-boot.
There is a lot of these TVs, I have the 2nd LG with not working TV Off. My parents have one too. LG 3D TVs are simply the best. I’m pretty sure it would be easily possible. But I understand it’s your decision like codec improvements for LG TVs you have done. Just tried to help more people, I’ve already implemented that
Ive got this on my 2nd TV and dont know what to do, so please:
CoreELEC:~/.config # sh shutdown_with_net.sh
Traceback (most recent call last):
File "/storage/.config/lg_tv_control_lan.py", line 42, in <module>
theSessionid = getSessionid()
File "/storage/.config/lg_tv_control_lan.py", line 25, in getSessionid
conn.request("POST", "/roap/api/auth", pairCmd, headers=headers)
File "/usr/lib/python3.7/client.py", line 1229, in request
File "/usr/lib/python3.7/client.py", line 1275, in _send_request
File "/usr/lib/python3.7/client.py", line 1224, in endheaders
File "/usr/lib/python3.7/client.py", line 1016, in _send_output
File "/usr/lib/python3.7/client.py", line 956, in send
File "/usr/lib/python3.7/client.py", line 928, in connect
File "/usr/lib/python3.7/socket.py", line 727, in create_connection
File "/usr/lib/python3.7/socket.py", line 716, in create_connection
ConnectionRefusedError: [Errno 111] Connection refused
Simplink is ON, LAN connected but still not showing the pairing code on my LG.
Hi msider, have you followed integration process i.e. set your IP ? Are you able to ping your TV ? What pythion version you have ? Script requires python3…