LG Magic remote arrow buttons

I’m using the custom mini media player to control LG TV, vizio soundbar, and other associated AV electronics. I have webos connected and working fine. I can turn the tv on and off as well as control volume and source. However, I’d like to go ahead and replace the remote for a good portion of my interactions, but to do that, I have to be able to use the arrow and select keys. I have tried to use the "content-card-remote-control’, but can’t seem to get it to work at all (although I’m not sure it performs the functions I need anyways). I’d tried to emulate the kodi remote control (found here), but also to no avail.

I’ve implmented keys in my code and what I can’t figure out is how to send over the correct commands. As indicated here, I’ve found what I believe to be the codes that should tell the tv to move left, right, up, down and enter (0x25, 0x26, 0x27, 0x28, 0x0D) respectively, but I’m not sure how to send those commands over. I’ve searched, but not found an example where someone did this and I’ve tried my own code, but so far nothing is working.

Here’s my current yaml for the mini remote:

entity: media_player.living_room_lg_oled
hide:
  power_state: false
hide_controls: true
idle_view: true
shortcuts:
  buttons:
    - id: DIRECTV
      name: DirecTV
      type: source
    - icon: 'mdi:netflix'
      id: Netflix
      name: Netflix
      type: source
    - icon: 'mdi:youtube'
      id: YouTube
      name: YouTube
      type: source
    - icon: 'mdi:alpha-r-circle-outline'
      id: 'RightNow Media :: All Kids Episodes'
      name: RightNow
      type: source
    - icon: 'mdi:plex'
      id: Plex
      name: Plex
      type: source
    - icon: 'mdi:google-play'
      id: Google Play Movies & TV
      name: G Play
      type: source
    - icon: 'mdi:hulu'
      id: Hulu
      name: Hulu
      type: source
    - icon: 'mdi:arrow-up-bold'
      id: Up
      type: source
    - icon: 'mdi:youtube-tv'
      id: YouTube TV
      name: YouTube TV
      type: source
    - data:
        entity_id: media_player.living_room_lg_oled
        media_content_id: 1
        media_content_type: channel
      icon: 'mdi:arrow-left-bold'
      id: media_player.play_media
      type: service
    - icon: 'mdi:enter'
      id: Enter
      type: source
    - icon: 'mdi:arrow-right-bold'
      id: Right
      type: source
    - id: ' '
      type: source
    - icon: 'mdi:arrow-down-bold'
      id: Down
      type: source
    - id: ' '
      type: source
  columns: 3
type: 'custom:mini-media-player'
volume_stateless: true

Anybody have any ideas how to control the up, down, left, right, and enter for LG magic remote?

To address support for the missing LG buttons I have created and remote component which extends the existing webostv platform.

Instructions

Place repository files in a web webostv folder in config/custom_components.

Example configuration.yaml

# Example configuration.yaml entry
media_player:
  - platform: webostv
    name: lgtv
    host: 192.168.0.17

remote:
  - platform: webostv
    host: 192.168.0.17
    name: lgr

I used the mini-media player for my UI, to combine the media player and remote functionality

image

Card Configuration

entity: media_player.lgtv
hide:
  power_state: false
hide_controls: true
idle_view: true
shortcuts:
  buttons:
    - icon: 'mdi:netflix'
      id: Netflix
      name: Netflix
      type: source
    - icon: 'mdi:amazon'
      id: AmazonPrime
      name: Amazon
      type: source
    - icon: 'mdi:youtube'
      id: YouTube
      name: YouTube
      type: source
    - data:
        command: HOME
        entity_id: remote.lgr
      domain: remote
      id: remote.send_command
      name: Menu
      type: service
    - data:
        command: UP
        entity_id: remote.lgr
      domain: remote
      icon: 'mdi:arrow-up-bold'
      id: remote.send_command
      type: service
    - id: ' '
      type: source
    - data:
        command: LEFT
        entity_id: remote.lgr
      domain: remote
      icon: 'mdi:arrow-left-bold'
      id: remote.send_command
      type: service
    - data:
        command: ENTER
        entity_id: remote.lgr
      domain: remote
      id: remote.send_command
      name: Enter
      type: service
    - data:
        command: RIGHT
        entity_id: remote.lgr
      domain: remote
      icon: 'mdi:arrow-right-bold'
      id: remote.send_command
      type: service
    - id: ' '
      type: source
    - data:
        command: DOWN
        entity_id: remote.lgr
      domain: remote
      icon: 'mdi:arrow-down-bold'
      id: remote.send_command
      type: service
    - id: ' '
      type: source
  columns: 3
type: 'custom:mini-media-player'
volume_stateless: true

Credit
Credit to poroping for his changes the pylgtv library #18.

There are proposed architectural improvements to HA’s media_player that could make the need for this remote addition unnecessary. Also proposed updates to pylgtv to use async #19 by @bendavid

But until those changes progress, this should do the trick :wink:

Thank you! I had given up hope. I’ll give this a shot.

I’ve had problems installing custom components previously. I downloaded your entire webostv folder, placed all the contents into my own config/custom_components/webostv folder then reloaded the core and restarted hass. Then I added the remote component to configuration.yaml (I already had the media_player configured correctly). Restarted again. Now when I add the component, it won’t let me save the mini-media-player card. The save button disappears and is replaced with a swirling icon as if it’s thinking. This never changes. I can’t even save my previous mini-media-player card which worked previously. I get the same swirling icon in place of the save button when I edit the card. Any thoughts as to what I might have done to cause this? My suspicion is that I’m not loading the custom components correctly somehow.

configuration.yaml:

media_player:
  - platform: webostv
    host: 192.168.1.116
    name: Living Room LG OLED
    timeout: 5
    turn_on_action: 
      service: switch.turn_on
      entity_id: switch.lg

   
remote:
  - platform: webostv
    host: 192.168.1.116
    name: lgremote

Example of setup that it won’t let me save:

entity: media_player.living_room_lg_oled
hide:
  power_state: false
hide_controls: true
idle_view: true
type: 'custom:mini-media-player'
volume_stateless: true

screen capture of the card above:

PR for long term solution is here btw

1 Like

Please excuse my ignorance here, but how do I tell if your long term solution (above) was implemented in the 0.103 release (or in any release for that matter)? I read the release docs, but didn’t see any mention of your specific PR and I’m guessing where it says open on the top, that means it was not merged yet, but I’m not certain of that.

Presuming it was included, I see the example in github shows an integration w/ the harmony remote that shows to use “service: webostv.button”. I don’t have that available as a service. How do I get that set up?

Thanks for your help!
Matt

Looks like it should be out in the next beta (and then release) with any luck!

Yes it should be in 0.104. The documentation will also be updated when 0.104 is released explaining how to configure things after these updates.
(The updated documentation is already available in the “next” branch as usual: https://github.com/home-assistant/home-assistant.io/blob/cfa0cc21724a16f7b327725bb9167259e6654220/source/_integrations/webostv.markdown)

Does the new integration update replicate all of the functionality of the above setup by @MadmanMonty or would his setup still be better to implement?

I managed creating it without the extension using the code below.

entity: media_player.stue_tv
hide:
  power_state: false
hide_controls: true
idle_view: true
shortcuts:
  buttons:
    - data:
        button: HOME
        entity_id: media_player.stue_tv
      icon: 'mdi:home'
      id: webostv.button
      type: service
    - data:
        button: UP
        entity_id: media_player.stue_tv
      icon: 'mdi:arrow-up-bold'
      id: webostv.button
      type: service
    - id: ' '
      type: source
    - data:
        button: LEFT
        entity_id: media_player.stue_tv
      icon: 'mdi:arrow-left-bold'
      id: webostv.button
      type: service
    - data:
        button: ENTER
        entity_id: media_player.stue_tv
      id: webostv.button
      name: Enter
      type: service
    - data:
        button: RIGHT
        entity_id: media_player.stue_tv
      icon: 'mdi:arrow-right-bold'
      id: webostv.button
      type: service
    - data:
        button: BACK
        entity_id: media_player.stue_tv
      icon: 'mdi:keyboard-return'
      id: webostv.button
      type: service
    - data:
        button: DOWN
        entity_id: media_player.stue_tv
      icon: 'mdi:arrow-down-bold'
      id: webostv.button
      type: service
    - id: ' '
      type: source
  columns: 3
type: 'custom:mini-media-player'
volume_stateless: true

1 Like

Hi, where did you put that code?

I don’t know specifically where he has put his, but mine is very similar. You CAN put it in a custom (manual) card or whatever type of card you might like to use. I have a few devices I want to control, so I made an input select button card that has the devices at the top and allows me to select one at at time to control. The attached pic is the LG part of the card.

I just discovered this thread and made something similar to what’s been done here and thought I’d share:

entity: media_player.living_room_tv
hide:
  power_state: false
hide_controls: true
idle_view: true
shortcuts:
  buttons:
    - icon: 'mdi:netflix'
      id: Netflix
      name: Netflix
      type: source
    - icon: 'mdi:amazon'
      id: AmazonPrime
      name: Amazon
      type: source
    - icon: 'mdi:youtube-tv'
      id: YouTubeTV
      name: YouTube TV
      type: source
    - data:
        button: HOME
        entity_id: media_player.living_room_tv
      id: webostv.button
      name: Menu
      type: service
    - data:
        button: UP
        entity_id: media_player.living_room_tv
      icon: 'mdi:arrow-up-bold'
      id: webostv.button
      type: service
    - data:
        button: CHANNELUP
        entity_id: media_player.living_room_tv
      icon: 'mdi:arrow-up-drop-circle'
      id: webostv.button
      type: service
    - data:
        button: LEFT
        entity_id: media_player.living_room_tv
      icon: 'mdi:arrow-left-bold'
      id: webostv.button
      type: service
    - data:
        button: ENTER
        entity_id: media_player.living_room_tv
      id: webostv.button
      name: Enter
      type: service
    - data:
        button: RIGHT
        entity_id: media_player.living_room_tv
      icon: 'mdi:arrow-right-bold'
      id: webostv.button
      type: service
    - data:
        button: BACK
        entity_id: media_player.living_room_tv
      id: webostv.button
      name: Back
      type: service
    - data:
        button: DOWN
        entity_id: media_player.living_room_tv
      icon: 'mdi:arrow-down-bold'
      id: webostv.button
      type: service
    - data:
        button: CHANNELUP
        entity_id: media_player.living_room_tv
      icon: 'mdi:arrow-down-drop-circle'
      id: webostv.button
      type: service
  columns: 3
type: 'custom:mini-media-player'
volume_stateless: true

I’m curious, is it possible to add the media player above the remote only if its power on for multiple media_player devices?
My use case is that my media_player device changes depending on if we are watching an app on the TV vs casting from our phone.

If I’m understanding the question correctly, it should be possible if you have a sensor that recognizes the states (on vs off) of your devices. Just make the media player card that you were placing above as shown when the power is on and hidden when the power is off.

any idea how to know the name of another app I have on LG to add to the main screen?

image