I don’t have this app. Only Mobile Apps anabled and HA paired with my TV.
Thanks a lot, the script works well on my LG CineBeam HU810P projector.
But I have one question: the projector also has an additional picture mode “Brightest”. How can I get the name of the mode to use in the script? hdrBrightest
doesn’t work for that
Sorry, I have no idea and no way to check. The trial and error method remains. I hope you succeed
Sorry if this is a very basic question, as relatively new to HA. Where does the script go, and how can it be triggered - for example in an automation? (I’ve tried adding to scripts.yaml but can’t find a way to trigger it). Thanks.
Edit: Ah I think all this code can be put into the automation itself when formatted correctly.
You can define scipts in scripts.yaml (thank you have to reaload script or restar HA).
Than you will be able to call the script as a service eg:
- service: script.living_room_lg_tv_picture_energy_saving
data:
energy_saving: 'max'
Or include whole script in automation but you won’t be able to reuse it.
I have root telnet enabled. I can connect via Putty, and send commands such as below which successfully changes picture mode.
luna-send -n 1 luna://com.webos.settingsservice/setSystemSettings '{"category": "picture", "settings": {"pictureMode": "expert2"}}' & exit
However I’m unable to get the command_line switches code here to work. The switch simply resets to off. The logs show no error.
Edit:
Finally managed to get it working with below…
switch:
- platform: command_line
switches:
lgtv_picture_bright_cl:
unique_id: "lgtv_pict_bright_cl"
command_on: >
echo "luna-send -n 1 luna://com.webos.settingsservice/setSystemSettings '{\"category\": \"picture\", \"settings\": {\"pictureMode\": \"expert1\"}}' & exit" | curl --raw --max-time 1 telnet://192.168.1.4:23
command_off: >
echo "luna-send -n 1 luna://com.webos.settingsservice/setSystemSettings '{\"category\": \"picture\", \"settings\": {\"pictureMode\": \"expert2\"}}' & exit" | curl --raw --max-time 1 telnet://192.168.1.4:23
command_state: >
echo "luna-send -n 1 luna://com.webos.settingsservice/getSystemSettings '{\"category\": \"picture\", \"keys\": [\"pictureMode\"]}' & exit" | curl --raw --max-time 1 telnet://192.168.1.4:23 | grep -c expert1
friendly_name: "LG Picture Bright"
I still can’t manage to pass the parameter to my TV
Hey did you have any luck in the end? I have an oled b7 and having the same issue as you. I see the pop up but no change in picture mode.
No still no luck…
Dude, I just found your solution, this was so helpful to me, thanks a buch for this!
Here’s the updated version for the latest Home Assistant:
First: sudo apt-get install netcat-traditional
then add to configuration.yaml
:
command_line:
- switch:
name: "LG Picture Mode ECO"
unique_id: "lgtv_pict_eco"
command_on: "echo \"luna-send -n 1 luna://com.webos.settingsservice/setSystemSettings '{\\\"category\\\": \\\"picture\\\", \\\"settings\\\": {\\\"pictureMode\\\": \\\"eco\\\"}}' & exit\" | nc 192.168.0.120 23"
command_off: "echo \"luna-send -n 1 luna://com.webos.settingsservice/setSystemSettings '{\\\"category\\\": \\\"picture\\\", \\\"settings\\\": {\\\"pictureMode\\\": \\\"normal\\\"}}' & exit\" | nc 192.168.0.120 23"
command_state: "echo \"luna-send -n 1 luna://com.webos.settingsservice/getSystemSettings '{\\\"category\\\": \\\"picture\\\", \\\"keys\\\": [\\\"pictureMode\\\"]}' & exit\" | nc 192.168.0.120 23 | grep -c eco"
- switch:
name: "LG Picture Mode Cinema"
unique_id: "lgtv_pict_cinema"
command_on: "echo \"luna-send -n 1 luna://com.webos.settingsservice/setSystemSettings '{\\\"category\\\": \\\"picture\\\", \\\"settings\\\": {\\\"pictureMode\\\": \\\"cinema\\\"}}' & exit\" | nc 192.168.0.120 23"
command_off: "echo \"luna-send -n 1 luna://com.webos.settingsservice/setSystemSettings '{\\\"category\\\": \\\"picture\\\", \\\"settings\\\": {\\\"pictureMode\\\": \\\"normal\\\"}}' & exit\" | nc 192.168.0.120 23"
command_state: "echo \"luna-send -n 1 luna://com.webos.settingsservice/getSystemSettings '{\\\"category\\\": \\\"picture\\\", \\\"keys\\\": [\\\"pictureMode\\\"]}' & exit\" | nc 192.168.0.120 23 | grep -c cinema"
Hi Jacek,
i’m not able to get your script working with my 55C6V but the problem seems to come from HA having problem with calling the script from the automation.
I have also another automation+script for input selection that is working fine.
Automation:
- alias: lg_smart_tv_select_picture_mode_eco
trigger:
- platform: state
entity_id: input_select.lg_smart_tv_picture_mode
to: eco
action:
- service: script.lg_webos_smart_tv_picture_mode
data:
picture_mode: eco
#----------------------------------------
- service: script.turn_on
target:
entity_id: script.script_audio_input
data:
variables:
audiofile: /share/Speech_On.wav
#----------------------------------------
mode: single
and script wich is yours:
lg_webos_smart_tv_picture_mode:
sequence:
#----------------------------------------
- service: script.turn_on
target:
entity_id: script.script_audio_input
data:
variables:
audiofile: /share/Speech_On.wav
#----------------------------------------
- service: webostv.command
data:
entity_id: media_player.lg_webos_smart_tv
command: system.notifications/createAlert
payload:
message: >-
{{ picture_mode }}
modal: false
buttons:
- label: "ok"
focus: true
buttonType: "ok"
onClick: "luna://com.webos.settingsservice/setSystemSettings"
params:
category: "picture"
settings:
pictureMode: >-
{{ picture_mode }}
type: "confirm"
isSysReq: true
- delay: 0.6
- service: webostv.button
data:
entity_id: media_player.lg_webos_smart_tv
button: ENTER
Error message in logs when reloading automations:
** Automation with alias 'lg_smart_tv_select_picture_mode_eco' could not be validated and has been disabled: extra keys not allowed @ data['action'][0]['picture_mode']. Got 'eco' template value is None for dictionary value @ data['action'][0]['data']. Got None*
Thank you for any help
Eddy, Belgium
PS: The audio script is just there temporarily to “ear” if the script runs…
Hi Eddy. I think the problem is about the indentation in you automation code.
it should be:
- service: script.lg_webos_smart_tv_picture_mode
data:
picture_mode: eco
Now HA complains about missing picture_mode
value, it’s caused by wrong formatting
Jacek, you saved me
No more error in logs but i’ll have to wait a few hours to check with my LG TV, i’m still at work
Thanks !
Eddy
The script with command and luna, as above, doesn’t work with my 55C6V.
Instead, i just tried with button and it’s ok. Example below. I usually just switch eco and cinema mode, so with a left or right button.
- alias: lg_smart_tv_select_picture_mode_eco
trigger:
- platform: state
entity_id: input_button.lg_tv_mode_eco
action:
- service: webostv.button
data:
entity_id: media_player.lg_webos_smart_tv
button: MENU
- delay: 0.7
- service: webostv.button
data:
entity_id: media_player.lg_webos_smart_tv
button: DOWN
- delay: 0.9
- service: webostv.button
data:
entity_id: media_player.lg_webos_smart_tv
button: ENTER
- delay: 0.7
- service: webostv.button
data:
entity_id: media_player.lg_webos_smart_tv
button: LEFT
- delay: 0.7
- service: webostv.button
data:
entity_id: media_player.lg_webos_smart_tv
button: BACK
mode: single
Looks like the TV has to be rooted to pass luna commands… ?
Has someone a good tuto to root a LG without to much risk… ?
Ok, no way, my 55C6V is on 3.4.2 firmware so i can’t…
Thanks,
Eddy
I’ve been using this for a while now, and it’s been working really well.
I was wondering, is there an option to ‘get’ the current ‘picture_mode’.
The reason I ask is, I mainly use this to switch the LG C8 to game mode when I’m using the Xbox.
By default it works a treat on the dashboard. However if a game is in HDR or DV, I have to manually change to HDR or DV game mode as well.
My thinking is, if I can monitor the current picture more, I could do something like.
If picture_mode changes & input = xbox
if picture mode like Dolby Vision, call script, set Dolby Vision Game mode (or whatever the command is)
if picture mode like HDR, call script, set dolbyHdrGame
Edit: Looking through the API doc, there’s a batch example that has
{
“method”: “getSystemSettings”,
“params”: {
“category”: “picture”,
“keys”: [
“brightness”
],
“subscribe”:true
}
},
Which returns
{
“method”:“getSystemSettigns”,
“settings”: {
“brightness”: “50”
},
“category”: “picture”,
“dimension”: {
“input”: “comp1”,
“pictureMode”: “normal”,
“_3dStatus”: “2d”
},
Do you think it’s possible to make a call to ‘getSystemSettings’ with something like keys: [pictureMode]?
Hi. I think it isn’t possible using scripts or available services. Maybe when webostv.command
service will be able to return values, so far it doesn’t support this.
Since HA 2023.7 it is possible but i wasn’t implemented so far in webos integration.
Thanks Jacek for responding. Good to know I wasn’t going mad, as I was struggling to get it to work
Speaking of, is there a way to get info if currently playing content is HDR/DV or not? I’d like to control LED strip on the back of my TV depending on it.
Great tips in this post!
Does anyone know if we can turn on/off the “eye comfort mode” using the integration (without using UP, LEFT, RIGHT etc)? I’ve been searching the web but has not seen any mentionings of it.