LG webOS Smart TV - Enable Turn On Action for HA 2022.2+

LG webOS Smart TV - Turn On for HA 2024.8+

This blueprint will run anytime the user turns the selected webOS media player on through Home Assistant (UI or actions).

Adding this blueprint will allow the user to turn on the LG webOS TV through the UI after updating to HA 2022.2, without this blueprint or similar automation the Turn On button won’t be displayed due to a breaking change. This is basically a shortcut to manually adding the automation described in the official documentation.

The default action is to send a Wake On Lan magic packet in order to turn the TV on. Additionally you can also setup custom actions for alternate solutions such as: using an IR remote, turning a smart socket on or calling an script. This is also useful for TV models connected through Wireless that have issues with Wake on Lan.

Requirements:

Changelog:

  • 2024.08.12 - (Breaking change) Support for updated Wake on LAN integration. Thanks @metbril for the heads up!
  • 2024.02.16 - (Breaking change) Updated device trigger
  • 2022.04.27 - Added actions to run after TV is turned On
  • 2022.02.06 - Added custom actions
  • 2022.02.03 - First release

Blueprint

Click the badge to import this Blueprint: (needs Home Assistant Core 2021.3 or higher)

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

FAQ:

How to edit configuration.yaml?

Follow the steps described here: Next steps - Home Assistant

Can you add a field for IP address?

Enable Custom Actions and then add the service wake_on_lan.send_magic_packet manually.

I have two TVs, how do I use this?

Once you’ve added the blueprint to HA, you’ll have to create one automation for each TV.

I added this blueprint and the Power Button won't show!

You might need to disable and enable your automation, if this keeps happening it’s recommended to open an issue.

Why is this necessary?

There was a breaking change documented in HA 2022.2 release notes:

The LG webOS Smart TV integration migrated to configuration via the UI. Configuring LG webOS Smart TV via YAML configuration has been deprecated and will be removed in a future Home Assistant release.

Your existing YAML configuration is automatically imported on upgrade to this release; and thus can be safely removed from your YAML configuration after upgrading.

The turn on action for turning on the TV via WakeOnLan or HDMI-CEC was using a service call via YAML, and the turn on action is changed to use a custom automation trigger webostv.turn_on or a device trigger automation that can be setup from the UI.

Example trigger automation:

automation:
  trigger:
    - platform: webostv.turn_on
      entity_id: media_player.lg_webos_smart_tv
  action:
    - service: wake_on_lan.send_magic_packet
      data:
        mac: AA-BB-CC-DD-EE-FF

(@thecode - #64117 ) (webostv docs )

39 Likes

Hi,
I can’t seem to get it to work got the following error.

Blueprint LG webOS Smart TV - Turn On generated invalid automation with inputs OrderedDict([(‘webostv’, ‘tv’), (‘webostv_mac’, ‘XX-XX-XX-XX-XX-XX’)]): Entity ID tv is an invalid entity ID for dictionary value @ data[‘entity_id’]. Got None

The entity is correct.

To be fair I can’t get the automation to work either. The magic packet (by manually triggering it) works on its own, just not the trigger webostv.turn_on… all my buttons and automations use media_player.turn_on service call.

This might help you… i was using media_player.turn_on too and i modified my template to the below…

 - platform: template
   switches:
     front_room_television_template:
       value_template: "{{ is_state('media_player.lg_tv_2', 'on') }}"
       turn_on:
         - service: wake_on_lan.send_magic_packet
           data:
               broadcast_address: 192.168.2.255
               mac: 78:5D:C8:7D:23:71
       turn_off:
         service: media_player.turn_off
         entity_id: media_player.lg_tv_2
3 Likes

Hello! Unfortunately I don’t get this kind of error on my system, mind to take a print of your blueprint configuration like the one below?

By default the blueprint will only allow you to select media players from the webOS integration, if you have to type it manually it may be wrong.

1 Like

The webostv.turn_on automation trigger also does not appear to be ffiring for me as of Home Assistant 2022.2.1. Prior to this I was using the YAML configuration for WebOS and turn_on_action: was defined in my configuration.yaml with the same web_on_lan.send_magic_packet defined in the blueprint provided in the OP.

I am able to configure a switch template and all works fine as defined in LG webOS Smart TV - Enable Turn On Action for HA 2022.2+ - #3 by danmed so I am left to believe that the webostv.turn_on trigger is what is broken.

Update: Fixed it! I use a custom card named mini-media-player and needed to add toggle_power: false to allow the power button to use media_player.turn_on. Additionally adding this blueprint caused the power button to appear on the webos tv entity where previously no power button was visible when the TV was off.

Thanks!

2 Likes

Wow…I just happened to come across this thread in a search for something unrelated, but glad I found it.

Seems archaic to make a user setup an automation so that the power on button shows up in the media player card in the UI.
Why is this not in the setup of the integration?
Does this seems strange to anyone else? Or am I just getting old enough to start yelling at kids on my lawn now?

12 Likes

Great work, thanks!

1 Like

I agree. I’m definitely confused why the burden was shifted to the user here.

finally got it working after a lot of buggering around - spent the whole weekend debugging corporate code to fix an incident, haven’t the energy to work this one out…

the new integration doesn’t allow you to specify certain sources like the old one did either… seems like a step backwards to me

When the TV is on, you can go to the integrations page, find WebOS and click on configure, then you’ll be able to select sources like this:

1 Like

I think HA has stricter rules for what an UI based integration can have.
Since the WebOS API doesn’t have a direct way to turn the TV on, they settled on this compromise where you can use Wake On Lan for wired TVs or an IR remote for wireless connected TVs. I plan to update this blueprint for IR commands as well.

It’s still weird and I believe it won’t stay like this, but for now I went ahead and made this blueprint to help out. :+1:t2:

1 Like

Thank you for doing so.

Well…I may not understand it, but I’m glad it can still be done since I do use it.

Trying to do this without a blueprint

I have a script containing this sequence snippet:

sequence:
            - service: media_player.turn_on
              entity_id: media_player.living_tv

WIll i have to add something like this instead of the turn on?
[/code]

  • service: wake_on_lan.send_magic_packet
    data:
    mac: AA-BB-CC-DD-EE-FF
    [/code]

Then it will work again?

Do i need something like that to turn off too?

Thank you, sir!

1 Like

thanks mate - had missed that, because it’s not in the doco…

your automation has restored domestic harmony too, btw :ok_hand:t4:

1 Like

Hello! You’ve got two options:

1 - Add this blueprint and keep using your script as is, no change nedded.
2 - Manually replace the turn_on with the service wake_on_lan.send_magic_packet.

Turn off works normally without any extra steps.

It just started randomly working after a couple updates / reboots then reloading the integration.
I’m guessing renaming the device caused the issue I was having.
Thanks for putting this together.

1 Like

Working method 2

Everything is ok with the blueprint, works perfectly, thanks.

But I have a real strange problem. I have to TV’s and for one of them the power button on the media player doesn’t appear. It appears only one time after restart of the HA.

I tried with:

hide:
  controls: false
  power: false

The same! Do you have any idea? Thanks!

Hello! Since you have two TVs make sure you use the blueprint twice and create one automation for each TV.

If you’re still having problem after that, it might be an issue similar to this and the fix will be coming soon.