I don't understand the Harmony docs

I have mine setup using scripts, but it could be possible to use the same entity in a switch as well. It just looks like you are missing some info from your remote.turn_on command. You will need to use the codes in the harmony_living_room_conf file to choose the activity for the remote.turn_on data section.

scripts/scripts_harmony_living_room_watch_tv

alias: "LR-Watch TV"
sequence:
  - service: remote.turn_on
    entity_id: remote.living_room_harmony
    data:
      activity: "12345678"

scripts/scripts_harmony_living_room_power_off

alias: "LR-Power Off"
sequence:
  - service: remote.turn_off
    entity_id: remote.living_room_harmony
1 Like

And if you want to do it the way that I do, here’s my code for that too:

automations/automations_harmony_input_select.yaml

alias: "harmony_input_select"
trigger:
  platform: state
  entity_id: input_select.harmony
action:
  service: script.turn_on
  data_template:
    entity_id: >
        {% if is_state("input_select.harmony", "Watch TV") %}
          script.harmony_living_room_watch_tv
        {%-elif is_state("input_select.harmony", "Watch a Blu-Ray") %}
          script.harmony_living_room_watch_a_blu_ray
        {%-elif is_state("input_select.harmony", "Watch Apple TV") %}
          script.harmony_living_room_watch_apple_tv
        {%-elif is_state("input_select.harmony", "Play Nintendo") %}
          script.harmony_living_room_play_nintendo
        {%-elif is_state("input_select.harmony", "Play Xbox One") %}
          script.harmony_living_room_play_xbox_one
        {%-elif is_state("input_select.harmony", "Use HDMI Cable") %}
          script.harmony_living_room_use_hdmi_cable
        {%-elif is_state("input_select.harmony", "PowerOff") %}
          script.harmony_living_room_poweroff
        {% else %}
          none
        {% endif %}

automations/automations_harmony_update_current_status.yaml

alias: "harmony_update_current_status"
trigger:
  - platform: state
    entity_id: remote.living_room_harmony
  - platform: homeassistant
    event: start
action:
  service: input_select.select_option
  data_template:
    entity_id: input_select.harmony
    option: >
      {{ states.remote.living_room_harmony.attributes.current_activity }}

Use the scripts above as templates for each of you activities. There should be one script for each activity, including power off. Then, load all the files in your HASS configuration files. In the web GUI, you should see a dropdown box in the Remotes section. You select an activity, it fires that activity. It’s also nice in that it updates shortly after you use the remote to switch activities too.

2 Likes

I do it similar as jeremy but instead of running scripts I directly use the commands. Don’t know whether this makes a difference though…
Just change the commands and names off your devices accordingly.
Enjoy your Harmony remote :wink: I don’t want to miss it :wink:

# Harmony input select Automatisierung
- alias: Harmony
  hide_entity: True
  trigger:
    platform: state
    entity_id: input_select.harmony
    from: 'Select Input'
  action:
    - service: remote.turn_on
      entity_id: remote.wohnzimmer
      data_template:  
        activity: >
          {% if is_state("input_select.harmony", "KODI") %}
            25238833
          {% elif is_state("input_select.harmony", "Fernsehen mit AVR") %}
            25238564
          {% elif is_state("input_select.harmony", "Radio") %}
            25544204
          {% elif is_state("input_select.harmony", "Musik") %}
            25239196
          {% elif is_state("input_select.harmony", "Echo") %}
            25483585
          {% elif is_state("input_select.harmony", "Fernsehen") %}
            25300734
          {% else %}
          {% endif %}
    - service: input_select.select_option
      entity_id: input_select.harmony
      data_template:
        option: "Select Input"
- alias: Harmony Off  
  hide_entity: True
  trigger:
    platform: state
    entity_id: input_select.harmony
    to: 'Power Off'
  action:
    - service: remote.turn_off
      entity_id: remote.wohnzimmer
    - service: input_select.select_option
      entity_id: input_select.harmony
      data_template:
        option: "Select Input"

Further I use an Input select for the controlling the automation

input_select:
  harmony:
    name: Harmony
    options:
      - Select Input
      - KODI
      - Fernsehen mit AVR
      - Fernsehen
      - Musik
      - Echo
      - Radio
      - Power Off
    icon: mdi:monitor

sensor:
  - platform: template
    sensors:
      current_activity:
        friendly_name: 'Aktuell'
        value_template: '{{ states.remote.Wohnzimmer.attributes.current_activity }}'
5 Likes

@jeremyowens, @derdude1893, I got this working exactly how I wanted. Thanks a lot for sharing your configs!

Thanks! This one helped me a lot. It’s working like a charm :grinning:

Do you think it’s possible to skip the “current_activity” sensor and let the input_select display the current activity, instead of reverting back to “Select Input”?

Thanks in advance.
Br Qxlkdr

In case you have not yet gotten this working…

The method that @jeremyowens posted eariler in this thread actually accomplishes what you are hoping to achieve.

However, for the purposes of teaching myself (as I’m quite new to HA), I wanted to have that same result but using @derdude1893’s method of directly using commands instead of using scripts. Here is what I have.

In my configuration.yaml,

input_select:
  harmony:
    name: Harmony
    options:
      - PowerOff
      - Watch Cable TV
      - Play Xbox One
      - Watch a Blu-ray
      - Give me Chromecast!
      - Watch PC
    icon: mdi:monitor

And in my automations.yaml,

  - alias: Set Harmony activity using input_select
    hide_entity: True
    trigger:
      platform: state
      entity_id: input_select.harmony
    action:
      service: remote.turn_on
      entity_id: remote.harmony_hub
      data_template:
        activity: >
          {% if is_state("input_select.harmony", "Watch Cable TV") %}
            17794266
          {% elif is_state("input_select.harmony", "Play Xbox One") %}
            17949443
          {% elif is_state("input_select.harmony", "Watch a Blu-ray") %}
            17718609
          {% elif is_state("input_select.harmony", "Give me Chromecast!") %}
            17718610
          {% elif is_state("input_select.harmony", "Watch PC") %}
            17759190
          {% else %}
            -1
          {% endif %}
        
# This next automation is to update the input_select when the Harmony's
# activity was changed from somewhere else, e.g. using its physical remote.
  - alias: Update Harmony input_select
    hide_entity: True
    trigger:
      platform: state
      entity_id: remote.harmony_hub
    action:
      service: input_select.select_option
      data_template:
        entity_id: input_select.harmony
        option: "{{ states.remote.harmony_hub.attributes.current_activity }}"

I hope that helps. That took me way longer to figure out than I expected.

4 Likes

@RiseUp Thanks for this! Saved me a lot of time.

@joolz You’re welcome! Glad I could help.

@RiseUp Thanks for your info, it really helped me set up my Harmony with HA.

One thing I’m struggling with now is how to turn the item off. For example, I can turn my lights on no problem with the Harmony dropdown that appears in the UI, but I just can’t figure out how to turn the lights off from the UI. I tried adding an action | service: remote.turn_off tied to a “Lights Off” item in the dropdown but that didn’t work.

Any ideas?

Thanks in advance!

How are you turning your lights on? Do you have a “Lights On” activity programmed in your Harmony Hub? If so, do you also have a separate “Lights Off” activity programmed, as well?

Thanks for the reply @RiseUp. My lights are controlled from the Harmony remote itself with a dedicated hard button.

You’re response leads me to believe that I need to create an actual “lights off” activity for my Harmony and then call that activity for the lights off. I was thinking this would work as a toggle, but I guess that’s not the case?

I have the emulated hue component configured and this exports lights.
In the harmony hub you can add the emulated hue bridge.
This allows you to export groups of lights in home assistant and map that to one of the buttons on your harmony hub.
I have a group of 3 lights in the living room as well as the hall.
When i click the button on my remote this turns on the lights in home assistant.

As far as I know, Home Assistant can only tell the Harmony Hub to fire off a command that exists in the harmony.conf file. While I, too, have lights mapped to hard buttons on the Harmony Elite remote, those commands do not appear in that .conf file.

Can’t you use HA to control your lights directly and avoid having to figure out a way to go through the Harmony?

Yes, I’m now controlling them directly through the Lutron Caseta component in HA. I needed this workaround while Caseta was no longer working.

You can never stop learning about how HA works, so was using this as another learning experience :wink:

Hi when a put this in the automation.yaml hass.io not load anymore, i change the names and codes What else should i change?

Did you also change your configuration.yaml file as shown in my post?

yes, the input appear, but when i changed the automation.yaml is when i get trouble,

Can you post your automation.yaml code here so we can see if we notice any errors?

sorry i dont know how to post code

Highlight it and click the </> icon above the type window, simples :slight_smile: