LG webOS change picture setting mode with scripts

I wrote these scripts to change LG smart tv picture setteing via remote button key presses (i.e Living colors, HDR effect, expert light room)

I did not manage to control the picture settings using luna-send (Please share if you have a solution using the API)

scripts.yaml :

tv_pic_menu_enter:
  sequence:
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: MENU
  - delay: 1
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: UP
  - delay: 1
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: ENTER
  - delay: 2
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: RIGHT
  - delay: 1
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: ENTER
  - delay: 1.5
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: ENTER
  - delay: 1
tv_pic_menu_choose_back:
  sequence:
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: ENTER
  - delay: 1
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: BACK
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: BACK
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: BACK
tv_down_button:
  sequence:
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: DOWN
  - delay: 0.2
tv_light_expert:
  alias: TV Expert Light
  sequence:
  - service: script.tv_pic_menu_enter
    data: {}
  - service: script.tv_down_button
    data: {}
  - service: script.tv_down_button
    data: {}
  - service: script.tv_down_button
    data: {}
  - service: script.tv_down_button
    data: {}
  - service: script.tv_down_button
    data: {}
  - service: script.tv_down_button
    data: {}
  - service: script.tv_down_button
    data: {}
  - service: script.tv_pic_menu_choose_back
    data: {}
  mode: single
  icon: mdi:television-ambient-light
tv_dark_expert:
  alias: TV Expert Dark
  sequence:
  - service: script.tv_pic_menu_enter
    data: {}
  - service: script.tv_down_button
    data: {}
  - service: script.tv_down_button
    data: {}
  - service: script.tv_down_button
    data: {}
  - service: script.tv_down_button
    data: {}
  - service: script.tv_down_button
    data: {}
  - service: script.tv_down_button
    data: {}
  - service: script.tv_down_button
    data: {}
  - service: script.tv_down_button
    data: {}
  - service: script.tv_pic_menu_choose_back
    data: {}
  mode: single
  icon: hass:sleep
tv_living_colors:
  alias: TV Living Colors
  sequence:
  - service: script.tv_pic_menu_enter
    data: {}
  - service: script.tv_pic_menu_choose_back
    data: {}
  mode: single
  icon: hass:flower

if you’d like to add the rest just copy paste tv_light_expert and remove one DOWN(- service: script.tv_down_button) command line
to choose a previous setting(-1 = HDR effect, -2 = Game etc.)

Also if your only using HASS to change the setting you might use the smaller quick menu by using left and right commands (HDR -> Game = tv_smenu_right; HDR <- Game = tv_smenu_left)

tv_smenu_right:
  sequence:
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: MENU
  - delay: 1
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: DOWN
  - delay: 1
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: ENTER
  - delay: 1
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: RIGHT
  - delay: 1
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: BACK
tv_smenu_left:
  sequence:
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: MENU
  - delay: 1
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: DOWN
  - delay: 1
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: ENTER
  - delay: 1
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: LEFT
  - delay: 1
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: BACK

some tv loads the menus faster in that case you can lower the delay to speed up the command:

tv_pic_menu_enter:
  sequence:
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: MENU
  - delay: 0.5
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: UP
  - delay: 0.5
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: ENTER
  - delay: 1.5
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: RIGHT
  - delay: 0.5
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: ENTER
  - delay: 1.5
  - service: webostv.button
    data:
      entity_id: media_player.lg_webos_smart_tv_2
      button: ENTER
  - delay: 0.5

Hi,

since I desperately wanted to find a way to organize scenes in which I can automatically set the Picture Mode and its parameters (e.g. when the shutters also close automatically and I need to reduce brightness) I’ve eventually found a tool which is capable of doing this. Now I can do this from the command line with this tool:

With this tool you can even change OLED brightness setting when your LG OLED TV is set to energy saving mode in Picture Settings.

From what I could understand from the source code I believe also the LGTV Home Assistant interface should be able to integrate picture mode settings and other settings. Also npm tools like LGTV2 should be able to run the necessary commands.

I installed aiopylgtv in MacOS Terminal:
pip install aiopylgtv

Put this code in a text file, e.g. picure_settings.py

import asyncio
from aiopylgtv import WebOsClient

async def runloop():
    client = await WebOsClient.create('192.168.0.60')
    await client.disconnect()    
    await client.connect()
    await client.start_calibration(picMode="game") 
    await client.set_oled_light(picMode="game", value=100)
    await client.set_contrast(picMode="game", value=70)
    await client.set_brightness(picMode="game", value=60)
    await client.end_calibration(picMode="game")
    test = await client.get_picture_settings()
    print(test)
    await client.disconnect()

asyncio.run(runloop())

Then run:
python picure_settings.py

I use Python 3.9.4

Regards
Helge

I also left feedback at Additional endpoint examples · Issue #17685 · home-assistant/home-assistant.io · GitHub regarding the documentation of webostv integration in Home Assistant.