Skip to content

Instantly share code, notes, and snippets.

@cvroque
Last active March 31, 2023 20:31
Show Gist options
  • Save cvroque/7422bcd6b038cd55250cd6f5c9158ddb to your computer and use it in GitHub Desktop.
Save cvroque/7422bcd6b038cd55250cd6f5c9158ddb to your computer and use it in GitHub Desktop.
Samsung Smart TV - Turn On
blueprint:
name: Samsung Smart TV - Turn On Action
description: |
## Samsung Smart TV - Turn On Action for 2023.4+
This blueprint will run anytime the user turns the media player on through Home Assistant (UI or service).
If the integration knows the MAC address of the TV from discovery this blueprint is not necessary. Wake on LAN must be enabled on the TV for this to work. If the TV is connected to a smart strip or requires a more complex turn-on process, this blueprint 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 soundbar.
### Requirements:
- [Samsung Smart TV][2] integration
- [Wake On Lan][3] added to configuration.yaml
### Changelog:
- 2023.03.15 - First release - Based on existing [LG webOS][4] blueprint
[1]: https://www.home-assistant.io/integrations/samsungtv/#turn-on-action
[2]: https://www.home-assistant.io/integrations/samsungtv/
[3]: https://www.home-assistant.io/integrations/wake_on_lan/
[4]: https://community.home-assistant.io/t/lg-webos-smart-tv-enable-turn-on-action-for-ha-2022-2/388153
domain: automation
author: "@cvroque"
homeassistant:
min_version: 2023.4.0
source_url: https://gist.github.com/cvroque/7422bcd6b038cd55250cd6f5c9158ddb#file-samsungtv_turn_on-yaml
input:
samsungtv:
name: Samsung TV
description: Select your media player entity
selector:
entity:
domain: media_player
integration: samsungtv
samsungtv_mac:
name: Samsung 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'
trigger:
- platform: samsungtv.turn_on
entity_id: !input samsungtv
action:
- choose:
- conditions:
- '{{ select_action }}'
sequence: !input 'custom_action'
default:
- service: wake_on_lan.send_magic_packet
data:
mac: !input samsungtv_mac
- wait_for_trigger:
- platform: state
entity_id: !input samsungtv
to: 'on'
timeout: '00:00: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