Logitech Harmony Integration with @iandday's component

Hi guys thanks for your inputs, I was able to get this working with the sync perfectly :slight_smile:

Does anyone have volume control working as well?

Hello and thank you very much for this Intergration.

Everything is working fine for me except that when i turn off activity from harmony remote or app it doesn’t update the input_select to Power Off.

Is it normal or do i miss something?

  harmony_hub:
    name: Harmony Hub
    options:
      - Power Off
      - TV
      - PC TV      
      - SMART TV
      - MOVIES TV
      - SWITCH TV
      - PS4 TV
      - ONE TV
      - WiiU TV
      - PS3 TV
      - 360 TV          
      - PC      
      - MOVIES
      - SWITCH
      - PS4
      - ONE
      - WiiU
      - PS3
      - 360
      - Chromecast audio
    initial: Power Off
    icon: mdi:monitor


'input_select_harmony':
   alias: Start activity from input select
   sequence:
     - service: remote.turn_on
       data_template:
         entity_id: remote.harmony_hub
         activity: >
           {% if is_state("input_select.harmony_hub", "Power Off") %}
               -1
           {% elif is_state("input_select.harmony_hub", "MOVIES") %}
               30471246
           {% elif is_state("input_select.harmony_hub", "PC") %}
               21826792
           {% elif is_state("input_select.harmony_hub", "PS4") %}
               21826901
           {% elif is_state("input_select.harmony_hub", "360 TV") %}
               20137481
           {% elif is_state("input_select.harmony_hub", "SMART TV") %}
               20137433
           {% elif is_state("input_select.harmony_hub", "WiiU TV") %}
               20137504
           {% elif is_state("input_select.harmony_hub", "TV") %}
               25698182
           {% elif is_state("input_select.harmony_hub", "Chromecast audio") %}
               27932527
           {% elif is_state("input_select.harmony_hub", "PS3 TV") %}
               25313252
           {% elif is_state("input_select.harmony_hub", "WiiU") %}
               25094446
           {% elif is_state("input_select.harmony_hub", "ONE") %}
               20492432            
           {% elif is_state("input_select.harmony_hub", "SWITCH TV") %}
               28414227
           {% elif is_state("input_select.harmony_hub", "MOVIES TV") %}
               30471346
           {% elif is_state("input_select.harmony_hub", "PS3") %}
               25313259
           {% elif is_state("input_select.harmony_hub", "360") %}
               25313232
           {% elif is_state("input_select.harmony_hub", "PS4 TV") %}
               20137469
           {% elif is_state("input_select.harmony_hub", "SWITCH") %}
               29197122           
           {% elif is_state("input_select.harmony_hub", "PC TV") %}
               20138144
           {% elif is_state("input_select.harmony_hub", "ONE TV") %}
               25310224
           {% endif %} 


 - alias: Remote start activity from input select Harmony
   initial_state: on
   trigger: 
     - platform: state
       entity_id: input_select.harmony_hub
   action:
     - service: script.turn_on
       entity_id: script.input_select_harmony
       
 - alias: Remote external update Harmony Hub
   initial_state: on
   trigger: 
     - platform: state
       entity_id: remote.harmony_hub
   action:
     - service: input_select.select_option
       data_template:
         entity_id: input_select.harmony_hub
         option: >
           {{ states.remote.harmony_hub.attributes.current_activity }}

I created an automation to reload the external update after every home assistant restart:

 - alias: 'hub trigger'
   initial_state: on
   trigger:
     - platform: homeassistant
       event: start
   action:
     - delay:
         seconds: 10  
     - service: automation.trigger
       entity_id: automation.remote_external_update_harmony_hub

Could i use something similar to update the input_select after the “Power Off” command? Like this:

 - alias: 'PowerOff update harmony hub'
   initial_state: on
   trigger:
     - platform: state
       entity_id: remote.harmony_hub
   condition:  
     - condition: template
       value_template: '{{ trigger.to_state.attributes.current_activity == "PowerOff" }}'
   action:
     - delay:
         seconds: 5    
     - service: input_select.select_option
       data_template:
         entity_id: input_select.harmony_hub
         option: >
           {{ states.remote.harmony_hub.attributes.current_activity }}

Again thank you for the amazing job you have all done :angel:

Well i founded the solution for my issue, it was silmpy the data_template option. Now i 'm using this:

 entity_id: input_select.harmony_hub
 option: 'Power Off'

And it works perfectly. Maybe there is way to make it simple and proper.

First of, thanks for your work with this. I have got my Harmony up and running almost to 100%. But I have troubles getting the dropdown menu for the input_select to work. It shows what acticity is running but I can´t change the activity from HA as I don´t get a dropdown menu. Do you know where it may have gone wrong? The yamls looks fine in yamlint and I get no errors when I check config in HA. I also pasted the parts in hastebin and uploaded if it’s easier to see anything wrong that way as I´m not sure the </> worked correctly
automation.yaml:

  - alias: Harmony
    hide_entity: False
    trigger:
      platform: state
      entity_id: input_select.harmony
      from: 'Select Input'
    action:
      - service: remote.turn_on
        entity_id: remote.harmony
        data_template:
          activity: >
            {% if is_state("input_select.harmony", "TV") %}
            30719637
            {% elif is_state("input_select.harmony", "Netflix") %}
            30720403
            {% elif is_state("input_select.harmony", "Shield TV") %}
            30720334
            {% elif is_state("input_select.harmony", "Playstation 4") %}
            30733821
            {% elif is_state("input_select.harmony", "Musik") %}
            30720761
            {% else %}
            {% endif %}
      - service: input_select.select_option
        entity_id: input_select.harmony
        data_template:
          option: "Select Input"

    - alias: Harmony Off
      hide_entity: False
      trigger:
        platform: state
        entity_id: input_select.harmony
        to: 'Power Off'
      action:
        - service: remote.turn_off
          entity_id: remote.harmony
        - service: input_select.select_option
          entity_id: input_select.harmony
          data_template:
            option: "Select Input"

input_select.yaml

harmony:
  name: Harmony Kontroll
  options:
    - Select Input
    - Power Off
    - TV
    - Netflix
    - Shield TV
    - Playstation 4
    - Musik
  initial: Select Input
  icon: mdi:monitor  

sensor.yaml

- platform: template
  sensors:
    current_activity:
      friendly_name: 'Current Activity'
      value_template: '{{ states.remote.harmony.attributes.current_activity }}'

group.yaml

harmony:
  name: "Harmony"
  view: false
  icon: mdi:remote
  entities:
    - remote.harmony  
    - sensor.current_activity
    - input_select.harmony

harmoni

Since it looks like you are using separate YAML files, do you have this in your configuration file? Do any other input_selects display, or is this the only one you’re having issues with?

input_select: !include input_select.yaml

It looks like you changed the name of the input select to input_select.harmony_kontrol in it’s configuration, but not in the configuration for the group. In the group config, change input_select.harmony to input_select.harmony_kontrol.

Thank you, this solved it!

1 Like

Hi there,

i am almost new to Home Assistant and found this great thread to implement my harmony hub which works great so far. Now i wanted to integrate the very same input_select and automation to create a menu for changing HDMI inputs on my TV if needed… i wanted to use the remote.send_command but something seems to be wrong here although there is no config error shown. Maybe you could help me get this right. To be honest i am not sure if it could work this way. Please see my “code”:

automation:

- alias: Harmony Input
  hide_entity: True
  trigger:
    platform: state
    entity_id: input_select.tvinput
    from: 'Select HDMI'
  action:
    - service: remote.send_command
      data:
        entity_id: remote.harmonyhub
        data_template:
          activity: >
             {% if is_state("input_select.tvinput", "HDMI1") %}
               command: -InputHdmi1 device: 35857036
             {% elif is_state("input_select.tvinput", "HDMI2") %}
               command: -InputHdmi2 device: 35857036
             {% else %}
             {% endif %}

configuration:

tvinput:
    name: TV HDMI Input
    initial: Select HDMI
    options:
       - Select HDMI
       - HDMI1
       - HDMI2

Maybe you can help :slight_smile:

Thanks in advance!

Haven’t got an answer but just interested why you’d ever want to switch an input outside an activity?

Our is it just one of those ‘why not’ scenarios we all waste multiple hours trying to achieve but will probably never use :slight_smile:

It is as simple as that… the Harmony does not always change my TV input as it should. And i want to have a second option to change things without closing an activity…there will probably be more stuff then just changing the input. I am just wondering if the remote.send_command can be used just like remote.turn_on within this structure and how it could work.

:slight_smile: I just pick the remote up if that ever happens. I’m sure someone who can sort it for you will be along soon.

As @Bobby_Nobble said, you may want to do this with the remote instead. Edit your activity in Harmony and add a delay then the correct input. But if you really want to do it in Home Assistant, I think this is what you need:

- alias: Harmony Input
  initial_state: on
  hide_entity: True
  trigger:
    platform: state
    entity_id: input_select.tvinput
    from: 'Select HDMI'
  action:
    - service: remote.send_command
      entity_id: remote.harmonyhub
      data_template:
        device: 35857036
        command: >-
          {% if is_state("input_select.tvinput", "HDMI1") %}InputHdmi1
          {% elif is_state("input_select.tvinput", "HDMI2") %}InputHdmi2
          {% else %}
          {% endif %}
1 Like

Thanks for your replies! Its not that i cant or don`t do this with the remote but i want to check out what is possible using this command! There are some other things i wanted to do using the remote.send_command as well.

Yeah it’s always a good learning experience playing around with different ideas, so I get it. I do the same. Let me know if the above works, I’m not at home right now to check my yaml files, but basically you either need data or data_template and in this case data_template since you’re using jinja templates to determine the command. Also you can’t have multiple attributes inside a template, but rather you have to template each attribute.

1 Like

Oddly, when remote.turn_on is called from hass to start an activity that is already running, it will actually restart that activity much like the “Fix” option in harmony. We use this a lot when casting to our chromecast. The harmony doesn’t know the inputs have changed and still shows it’s on our directv activity, but when we tell it to switch to the directv activity using hass, it will correct all of the inputs for us.

I have had no time to check the code yet… maybe i ll get to it tonight. I will let you know if its working.
Finally i wanted to send comands without leaving/changing the activity or beeing forced to use the “device” tab on the remote.
For example i am still using older Wallplugs controlled via an older standard not zwave. These can be switched using a small device called lightmanager from JBmedia and if you go to devices on the harmony remote you get commands like: L001 , L002 , L003 and so on
Not very comfortable as you cant rename them so you will always have to remember which command controls which plug :slight_smile:

Using Hassio i could kind of make them “readable” so to say :wink:

Unless you mean something different, you can rename the labels in the Harmony software…

1 Like

Yeah you are right that would be another option as well:yum:

1 Like

@Jer78 your code is working perfect! Thanks very much …now i can use that as a starting point :slight_smile:

1 Like

I was able to get this implemented and working however after a few hours of a system reboot the commands stop working and won’t work until I reboot HASS. Could this be an issue with my scripts\automation, or with my Logitech device or with the component?

Thanks,