Hello!
I made a simple script for my WebOS TV:
Turn the TV ON, change the source and set the channel.
Initially it was simple:
- Turn TV ON
- Delay for 30 seconds (while TV boots up)
- Change Source
- Delay for 10 seconds (while app loads)
- Change channel.
But when the TV is already ON or in the correct source, it makes no sense to wait for 30~40 seconds for a channel change. So I wanted to reduce the delay and I tried this:
alias: LG - Channel two
sequence:
- data: {}
entity_id: media_player.lg_sala
service: media_player.turn_on
- delay: '{% if is_state(''media_player.lg_sala'', ''on'') -%} ''00:00:01'' {%-
else -%} ''00:00:30'' {%- endif %}'
- data:
source: Smart IPTV
entity_id: media_player.lg_sala
service: media_player.select_source
- delay: '{% if is_state_attr(''media_player.lg_sala'', ''source'', ''Smart IPTV'')
-%} ''00:00:01'' {%- else -%} ''00:00:10'' {%- endif %}'
- data:
button: '2'
entity_id: media_player.lg_sala
service: webostv.button
mode: single
But the problem is that with this logic the TV will report as ON imediatelly after my command to turn it ON and the delay template won’t ever return 30 seconds. I’m looking for a script that should be like this:
- If TV is ON
-Wait 1 second
Else
-Turn ON
-Wait 30 seconds- If TV is on correct source
-Wait 1 second
Else
-Change source
-Wait 10 seconds- Change channel
My main motivation for this is having only a single command exposed to Google Assistant that can be used to either turn the TV on or just change channels.
Can I do this via script, should I try multiple scripts or? Is there a way to set a delay time, do an action and then delay?