Skip to content

Instantly share code, notes, and snippets.

@cvroque
Last active April 1, 2024 09:13
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save cvroque/6780ca0869ef781e9de3b506fd501f78 to your computer and use it in GitHub Desktop.
Save cvroque/6780ca0869ef781e9de3b506fd501f78 to your computer and use it in GitHub Desktop.
LG webOS Smart TV - Turn On
blueprint:
name: LG webOS Smart TV - Turn On Action
description: |
## LG webOS Smart TV - Turn On Action for 2022.2+
This blueprint will run anytime the user turns the media player on through Home Assistant (UI or service).
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][1].
The default action is to send a Wake On Lan magic packet in order to turn the TV on. Aditionally you can also setup custom actions for alternate solutions such as: using an IR remote, sending a magic packet with IP and MAC, 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.
Actions to run after the TV is turned on is useful for switching the HDMI source, setting the default volume or even activating other devices such as a sounbar.
### Requirements:
- [LG webOS Smart TV][2] integration
- [Wake On Lan][3] added to configuration.yaml
### Changelog:
- 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
[1]: https://www.home-assistant.io/integrations/webostv/#turn-on-action
[2]: https://www.home-assistant.io/integrations/webostv/
[3]: https://www.home-assistant.io/integrations/wake_on_lan/
domain: automation
author: "@cvroque"
homeassistant:
min_version: 2023.3.0
source_url: https://gist.github.com/cvroque/6780ca0869ef781e9de3b506fd501f78#file-webostv_turn_on-yaml
input:
webostv:
name: LG webOS TV
description: Select your TV
selector:
device:
filter:
integration: webostv
webostv_mac:
name: LG webOS TV MAC address
description: The MAC address of the selected TV. You can get this information on your TV network settings or through your router.
default: AA-BB-CC-DD-EE-FF
on_action:
name: Actions to run after TV is turned On (Optional)
description: Select actions to run after the TV is turned on. Useful for setting a default volume or changing source automatically.
default: []
selector:
action: {}
select_action:
name: Enable Custom Actions?
description: When Off the default action is to send a magic packet, when On the custom actions will replace the magic packet.
default: false
selector:
boolean: {}
custom_action:
name: Custom Actions (Optional)
description: When custom actions are enabled the actions added here will replace the magic packet. Useful for TVs being turned on through an IR remote, script or similar.
default: []
selector:
action: {}
variables:
select_action: !input 'select_action'
select_device: !input webostv
select_entity: "{{device_entities(select_device) | first }}"
trigger:
- platform: device
device_id: !input webostv
domain: webostv
type: webostv.turn_on
action:
- choose:
- conditions:
- '{{ select_action }}'
sequence: !input 'custom_action'
default:
- service: wake_on_lan.send_magic_packet
data:
mac: !input webostv_mac
- wait_template: "{{ is_state(select_entity, 'on') }}"
continue_on_timeout: true
timeout: "30"
- choose: []
default: !input 'on_action'
mode: queued
max_exceeded: silent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment