Now that the Harmony code has been merged into the HASS code for the next release I wanted to add an alternative to @BTallack 's great instruction on how to incorporate the Harmony hub into your HASS setup that involves the template feature. It results in less lines of code but isnt as extensible as BTallack’s method
the following script can replace the section of scripts to activate each activity
script:
input_select_harmony
alias: "Start activity from input select"
sequence:
- service: remote.turn_on
data_template:
entity_id: remote.living_room_tv
activity: >
{% if is_state("input_select.living_room_tv", "PowerOff") %}
-1
{% elif is_state("input_select.living_room_tv", "Xbox") %}
20195208
{% elif is_state("input_select.living_room_tv", "Playstation 3") %}
19954855
{% elif is_state("input_select.living_room_tv", "Steam Link") %}
16602559
{% elif is_state("input_select.living_room_tv", "Plex Media Player") %}
19575995
{% elif is_state("input_select.living_room_tv", "Airplay") %}
19292022
{% elif is_state("input_select.living_room_tv", "Wii U") %}
13677570
{% endif %}
The following automation will update the input select when the activity is changed using the harmony remote or other device
- alias: 'Remote external update living room'
trigger:
platform: state
entity_id: remote.living_room_tv
action:
service: input_select.select_option
data_template:
entity_id: input_select.living_room_tv
option: >
{{ states.remote.living_room_tv.attributes.current_activity }}
The last automation will start an activity once it’s selected from the input select in the frontend
- alias: 'Remote start activity from input select living room tv'
trigger:
platform: state
entity_id: input_select.living_room_tv
action:
service: script.turn_on
entity_id: script.input_select_harmony