I have a HDMI switch which needs to be turned on when I’m watching TV in the living room or bedroom, I’ve got what i need working perfectly, however I believe it may be an ugly solution as I’ve broke it down into 5 parts.
Right now I’ve got rules for:
Switch on Living Room TV (Switches on The HDMI Switch)
Switch off Living Room TV
Switch on Bedroom TV (Switches on the HDMI Switch)
Switch off Bedroom TV
Switch off HDMI Switch (Delays 5 seconds, checks to make sure both Living Room TV and Bedroom TV is off and then turns off)
For each of these rules I’m using a key press (Its from a Flirc).
I’m about to continue automating a lot of what happens in the house and therefore wanted to run this first bit of configuration by the community to make sure i’m not writing ugly rules going forward!
- id: '1548640452965'
alias: Toggle TV Stack Bedroom On
trigger:
- event_data:
key_code: 59
event_type: keyboard_remote_command_received
platform: event
condition:
- condition: state
entity_id: switch.30384467cc50e315c79d
state: 'off'
action:
- data:
entity_id: switch.30384467cc50e315c79d
service: homeassistant.turn_on
- data:
entity_id: switch.30384467840d8e956996
service: homeassistant.turn_on
- id: '1548640452964'
alias: Toggle TV Stack LivingRoom On
trigger:
- event_data:
key_code: 62
event_type: keyboard_remote_command_received
platform: event
condition:
- condition: state
entity_id: switch.30384467840d8e9578cd
state: 'off'
action:
- data:
entity_id: switch.30384467840d8e9578cd
service: homeassistant.turn_on
- data:
entity_id: switch.30384467840d8e956996
service: homeassistant.turn_on
- id: '1548640452963'
alias: Toggle TV Stack LivingRoom Off
trigger:
- event_data:
key_code: 62
event_type: keyboard_remote_command_received
platform: event
condition:
- condition: state
entity_id: switch.30384467840d8e9578cd
state: 'on'
action:
- data:
entity_id: switch.30384467840d8e9578cd
service: homeassistant.turn_off
- id: '1548640452965'
alias: Toggle TV Stack Bedroom Off
trigger:
- event_data:
key_code: 59
event_type: keyboard_remote_command_received
platform: event
condition:
- condition: state
entity_id: switch.30384467cc50e315c79d
state: 'on'
action:
- data:
entity_id: switch.30384467cc50e315c79d
service: homeassistant.turn_off
- id: '1548651296387'
alias: keyboard log
trigger:
- event_data: {}
event_type: keyboard_remote_command_received
platform: event
condition: []
action:
- data_template:
message: Key Pressed {{ trigger.event.data.key_code }}
service: notify.filenotify
- id: '1548656624166'
alias: Toggle TV Stack HDMI off
trigger:
- event_data:
key_code: 59
event_type: keyboard_remote_command_received
platform: event
- event_data:
key_code: 62
event_type: keyboard_remote_command_received
platform: event
condition: []
action:
- delay: 00:00:05
- condition: state
entity_id: switch.30384467cc50e315c79d
state: 'off'
- condition: state
entity_id: switch.30384467840d8e9578cd
state: 'off'
- data:
entity_id: switch.30384467840d8e956996
service: homeassistant.turn_off