Logitech Harmony Integration with @iandday's component

strange, it’s working for others. Can you enable debug logging for the remote component and copy the output? your credentials will be logged in the output to make sure they’re getting pullled correctly from the config.yaml

Oh huh, I remember an offhand comment I saw somewhere and tried without using !secret for my username and password and it seems to have not thrown that error anymore. Any idea about that?

not really sure, I’m using secrets in my config

remote:
  - platform: harmony
    name: Bedroom
    username: !secret username
    password: !secret password
    host: 10.168.1.13
    port: 5222
    activity: BedroomTV
  - platform: harmony
    name: Family Room
    username: !secret username
    password: !secret password
    host: 10.168.1.16
    port: 5222
    activity: Kodi

Strange its only failing when i use secret. I’ll look into it more. Im running hass version 0.33.1.

does your password have any special characters in it?

my username is [email protected] Do i have to use an escape character?

Also thank you for your help.

you’re welcome.

nope, my account is registered with a gmail address too. I dont have to escape anything

I’m using secret’s in mine as well. No issues here.

I was just reading on the OpenHAB forum that Logitech may have changed something in their API and it’s causing all sort of issues on install that’s not communicating with the hub directly (locally) My installation in OpenHab is not working either. I am considering doing an installation of Home Assistant to test and was just noticing some similar issues here.

They broke the authentication routine earlier this week, Wednesday or Thursday I think? I was able to get it working again with the remote component and harmony platform I wrote. The pull request is still outstanding so for the time being you’ll have to manually install it

I configured everything and it works pretty well except for the fact that when i trigger an activity through harmony it wont update the input select although i have set it up as an automation.

- alias: "Powered off from Harmony Hub"
  trigger:
    platform: state
    entity_id: remote.harmony
  condition:
    condition: template
    value_template: '{{ trigger.to_state.attributes.current_activity == "Tv Off" }}'
  action:
    service: input_select.select_option
    entity_id: input_select.activities
    data:
      option: "Tv Off"

Does it have to do with the condition not being met? Syntax error?

It most likely should be PowerOff, my hub’s current_activity attribute is listed as PowerOff when there are no active activities from the hub

1 Like

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
4 Likes

Great guide(s). Thanks!
I’m relatively new to HASS and am having some difficulties with this setup.

I have the input select configured, and its displaying on my HASS homescreen.
Switching the activity on the Harmony remote is updating HASS, but I’m unable to change the activity via HASS.
I can see in the logs that the state has been changed, but my hub doesn’t initiate the change

Any assistance is greatly appreciated.

I have three separate config files for this setup:
configuration.yaml
harmony_script.yaml
harmony_automation.yaml

I’m including harmony_script and harmony_automation using directory merging. They’re being loaded, because any config errors stop HASS from starting.

from config…

group: !include group.yaml
script: !include_dir_merge_list script
automation: !include_dir_merge_list automation

remote:
- platform: harmony
name: Living Room TV
host: harmonyhub.
port: 5222

input_select:
living_room_tv:
name: Living Room TV
options:
- PowerOff
- Watch TV
- Watch a Movie
- Play a Game
- Listen to Radio
- Listen to iPod
initial: PowerOff
icon: mdi:monitor

automation:

  • 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

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", "Watch TV") %}
            9815799
        {% elif is_state("input_select.living_room_tv", "Watch a Movie") %}
            9816132
        {% elif is_state("input_select.living_room_tv", "Play a Game") %}
            9825015
        {% elif is_state("input_select.living_room_tv", "Listen to Radio") %}
            9816180         
        {% elif is_state("input_select.living_room_tv", "Listen to iPod") %}
            9816227             
        {% endif %}

can you post your configs properly formatted? It’ll make it much easier to assist

Can do. Thanks for the assistance.

Here are the three files. I’ve removed my local IPs and GPS co-ordinates.

try this, it looks like your spacing was off

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", "Watch TV") %}
              9815799
          {% elif is_state("input_select.living_room_tv", "Watch a Movie") %}
              9816132
          {% elif is_state("input_select.living_room_tv", "Play a Game") %}
              9825015
          {% elif is_state("input_select.living_room_tv", "Listen to Radio") %}
              9816180        
          {% elif is_state("input_select.living_room_tv", "Listen to iPod") %}
              9816227             
          {% endif %}

I have some additional remote automations in my repository that may be helpful.

Huge thanks to @iandday and the testers.
With the introduction of the new component I can finally be rid of one of my biggest frustrations with the Harmony Hub; it’s activities not being synced up with everything else.

I am using the below automation for my Xbox One activity on my Harmony Hub that makes use of the Xbox Live component and the status of my TV. It will trigger when either of the TV turns on/off and if my Xbox Profile is online/offline; then check to make sure that both the TV and Xbox Profile are (on/online)/(off/offline); then will activate/deactivate the ‘Play Xbox One’ activity on the harmony hub.

Note: After playing around a bit I realised I had to add the multiple triggers along with the AND conditions due to timings of devices being registered as on/off within Home Assistant, whilst also making sure that the devices associated with the Activity are both in the correct state.

## Activate Xbox One Activity on Harmony if Xbox is Online and TV is on

- alias: Activate Xbox One Activity on Harmony
  trigger:
    - platform: state
      entity_id: sensor.pawnynz
      state: 'Online'
    - platform: state
      entity_id: media_player.loungetv
      state: 'on'

  condition:
    condition: and
    conditions: 
    - condition: state
      entity_id: media_player.loungetv
      state: 'on'
    - condition: state
      entity_id: sensor.pawnynz
      state: 'Online'

  action:
    service: remote.turn_on
    data:
      activity: 21515412
      entity_id: remote.lounge_harmony

## Deactivate Xbox One Activity on Harmony if Xbox is Offline and TV is off

- alias: Deactivate Xbox One Activity on Harmony
  trigger:
    - platform: state
      entity_id: sensor.pawnynz
      state: 'Offline'
    - platform: state
      entity_id: media_player.loungetv
      state: 'off'

  condition:
    condition: and
    conditions: 
    - condition: state
      entity_id: media_player.loungetv
      state: 'off'
    - condition: state
      entity_id: sensor.pawnynz
      state: 'Offline'

  action:
    service: remote.turn_off
    data:
      entity_id: remote.lounge_harmony
1 Like

That’s really clever! I hadn’t actually thought of using an Xbox Live component to track the power state of an Xbox to control my Harmony hub. You could conceivably do the same with the NMAP tracker component as well.