WebOS (LG) TV, Command payload syntax (service vs node-red)

In the documentation (here) there’s a section for the webostv.command service, where you can send it commands. This refers to a list of endpoints (kind of like commands, here).

Some of these require no parameters, for example volumeUp or volumeDown, and they work fine.

Some require parameters (or I think in the terminology used internally payloads), for example setVolume. I have found no mechanism to pass that in, at least all the variations on syntax I have tried either are not accepted, or do not work (mostly the former).

Now the actual commands can be made to work. In Node-Red for example, there is this set of nodes (here) which use similar commands, though they are wrapped up inside specific nodes. I have not used them extensively yet, but a relatively complicated thing (open the web browser to a page) worked great.

Now I realize I can, in a kludgy way, hook Node-Red up to Home Assistant, e.g. have a script toggle a button which invokes a flow, which does the thing and re-toggles; hope for no race conditions, etc. Yes, I see how that works, can do.

But what I’d really like is some scripts in HA that just call the services with the right payload. Skip all the fake-event flow invocation.

Is there a syntax I’m just missing, or is HA just not as sophisticated in the use of this as Node-Red?

1 Like

The webostv.command service does not currently support passing additional parameters, however much of the specific functionality is accessible through other services. For example media_player.volume_set for the use case you give.

Which functionality are you currently missing?

Opening the web browser to a specific URL was the thing I was trying to do at the moment.

This syntax has been working for me:

open_google_command:
    sequence:
      - service: webostv.command
        data:
          entity_id:  media_player.lg_webos_smart_tv
          command: "system.launcher/open"
          payload:
            target: https://www.google.com

Where would one find the available payload properties/parameters to use?
Would that be on LS2 API Index | webOS Open Source Edition

1 Like

I found pylgtv library to control a WebOS tv. In this file you can find some info on what payload commands need. I just tried to set volume on my device and it worked

service: webostv.command
data:
  entity_id: media_player.lg_webos_tv
  command: audio/setVolume
  payload:
    volume: 8

Hope this can help!

2 Likes

Hi all,
I have this setup running as an Automation in HA.

alias: Test
description: “”
trigger:
  - platform: event
    event_type: ""
condition: []
action:
  - service: webostv.command
    data:
      command: system.launcher/open
      entity_id: media_player.lg_webos_smart_tv
      payload:
        target: >-
          https://myurl/api/frigate/notifications/.../.../clip.mp4
mode: single

witch works great as automation. Now i do want to use this to turn on the TV and past the new .mp4 to in via Node Red. I just can’t find a way to get that done. Has someone been able to that?
Appreciate the Help

This was very helpful to me, thank you!

Sorry to revive this but does anyone know how to use the response from a command? I am trying to duplicate the functionality of the “screen” switch from the homebridge webos tv plugin and so far I can come close but not quite.

I have a switch that calls the command service to turn the screen on & off useing com.webos.service.tvpower/power/turnOffScreen (or turnOnScreen) and that all works fine, I just cannot figure out how to get live status.

I would think I would create an automation that fires every minute or so & calls the LG command com.webos.service.tvpower/power/getPowerState and uses the response to parse the status of the screen (since it is not exposed as an attribute to HA), but I cannot figure out how to view the response to see what I need from it.

Since I cannot get even that far I have not yet had to figure out how to use the response, so I will need to figure that out also, if this is even possible.

Does anyone have any idea?