I’ve been using this automation for a long while and it “works”, but it’s a bit slow and clunky. When I wrote it, the goal was to fix an issue outside of HA between my Harmony Hub and my Sony TV that was IP controlled. Every month or so, the hub would loose it’s IP connection, and then the TV would not start. It I was home, easy enough, to go in and fix with the harmony App, but if the spouse was home, then she’d be stuck digging in drawers to get the sony remote, etc. So I aded the ROKU component to HA and did this kinda hacky trick, since HA could control my TV. I recently realized I could make this a bit faster
- alias: TV Force On for Tivo
trigger:
- platform: event
event_type: roku_command
event_data:
source_name: Home Assistant
type: keypress
key: Fwd
action:
- delay:
seconds: 5
- condition: or
conditions:
- condition: template
value_template: '{{ (states.media_player.living_room_tv.attributes.source) != "HDMI 1" }}'
- condition: state
entity_id: media_player.living_room_tv
state: 'off'
- service: media_player.turn_on
entity_id: media_player.living_room_tv
- delay:
seconds: 5
- service: media_player.select_source
data:
entity_id: media_player.living_room_tv
source: 'HDMI 1'
- service: notify.pushover
data_template:
target: Paul
title: Sony TV lost Key
message: Fix Harmony
Basically the roku FWD command is the last thing in the startup sequence for my activity.
If the TV is off, then turn it on and wait for 5 seconds and then set the input.
Overall there is a 10 second delay. I’d like to skip the 1st 5 second delay if the TV is on.
So something like this
ROKU fwd command
is TV on? and set to input 1. Do nothing
Is TV on , but wrong input? Switch Input
Is TV off? Turn it on, wait 5 seconds, then set input.
I’m struggling a bit with a service template, since there are two services I care about?
I’m sure it’s fairly obvious, but my brain is just not focusing in on the answer