Logitech Harmony Integration with @iandday's component

@Jtmoore81 Can you paste your yaml so we can have a look?

Here they are.

Config:

remote:
  platform: harmony
  name: Gameroom
  # host: 192.168.1.26
  # activity: Watch TV

scripts:

gameroom_tv_on:
      sequence:
        - service: remote.turn_on
          entity_id:
            - remote.harmony_hub
          data:
            activity: "32027935"

gameroom_tv_off:
  sequence:
    - service: remote.turn_off
      entity_id:
        - remote.harmony_hub
      data:
        activity: "32027935"

Automations:

- id: TV_turned_off_from_HASS
  alias: 'TV turned off from HASS'
  hide_entity: False
  trigger:
    platform: state
    entity_id: input_select.gameroom_tv
    to: 'Powered Off'
  action:
    service: script.turn_on
    entity_id: script.gameroom_tv_off


- id: TV_turned_on_from_HASS
  alias: 'TV turned on from HASS'
  hide_entity: False
  trigger:
    platform: state
    entity_id: input_select.gameroom_tv
    to: 'Power on'
  action:
    service: script.turn_on
    entity_id: script.gameroom_tv_on

- id: TV_turned_on_from_HASS
  alias: 'TV turned on from HASS'
  hide_entity: False
  trigger:
    platform: state
    entity_id: input_select.gameroom_tv
    to: 'Power on'
  action:
    service: script.turn_on
    entity_id: script.gameroom_tv_on

I see a few issues, first up, if you don’t use initial_state: on there are times automations get disabled. So I just add this in case. Second, there are 2 identical turn on automations. Not sure if you just pasted here twice or that’s what’s in your config. Third, it looks like you’ve named your harmony hub gameroom but then refer to it as remote.harmony_hub. You may want to double check that. Finally, you probably also want to get the current state from the harmony remote as well so your input_select is up to date with the correct activity. I’ve modified my working config for you. It’s also easier if you add more activities. Try this instead…

btw, just rename “Watch TV” in the automation to whatever your actual activity name is, and also update your input_select with the same option. Your scripts can stay the same

Sensor:

  sensor:
   - platform: template
     sensors:
        gameroom_tv:
          value_template: '{{ states.remote.gameroom.attributes.current_activity }}'

Automation:

  - alias: "Game Room Harmony From Input Select"
    id: "Game_Room_Harmony_From_Input_Select"
    initial_state: on
    trigger:
      - platform: state
        entity_id: input_select.gameroom_tv
    action:
      - service: script.turn_on
        data_template:
          entity_id: >-
             {% set gameroom_harmony = states.input_select.gameroom_tv.state %}
             {% if gameroom_harmony == "Watch TV"%}script.gameroom_tv_on
             {% else %}script.gameroom_tv_off
             {% endif %}

  - alias: "Game Room Harmony From Remote"
    id: "Game_Room_Harmony_From_Remote"
    initial_state: on
    trigger:
      - platform: state
        entity_id: sensor.gameroom_tv
      - platform: homeassistant
        event: start
    action:
      - service: input_select.select_option
        entity_id: input_select.gameroom_tv
        data_template:
          option: >-
            {% set gameroom_harmony = states.sensor.gameroom_tv.state %}
            {{gameroom_harmony}}

Hey guys- I’m having some problems with my input select and scripts not working. I have programmed switches to work no problem, and the poweroff script works, but the drop down input_select does not work at all and neither do the rest of the activity switches.

I can manually turn on the remote through the services section and also on the UI. It activates watch apple tv.

I’ve seen some posts on here about people adding information to the groups.yaml file- I have not added anything in there at all. Just this to the config: (it’s the right IP and it works in the UI)

remote:
  - platform: harmony
    name: Living Room
    host: 10.0.0.10
    activity: Watch Apple TV

Here are the various codes in different files/folders of course.

input_select:

living_room_harmony:
  name: Living Room Harmony
  options:
    - PowerOff 
    - Listen to Music Inside
    - Watch Apple TV
    - Watch TV
    - Listen to Music
  initial: PowerOff
  icon: mdi:monitor

automation:

- alias: 'Harmony Update Current Status'
  trigger:
    platform: state
    entity_id: remote.living_room
  action:
  - service: input_select.select_option
    entity_id: input_select.living_room_harmony
    data_template:
      option: >
        {{ states.remote.living_room.attributes.current_activity }} 

- alias: 'Remote Start Activity'
  trigger:
    platform: state
    entity_id: input_select.living_room_harmony
  action:
  - service: script.turn_on
    entity_id: script.living_room_harmony

input select script:

living_room_harmony:
  alias: 'Harmony State'
  sequence:
    - service: remote.turn_on
      data_template:  
        entity_id: remote.living_room
        activity: >
          {% if is_state("input_select.living_room_harmony", "PowerOff") %}
            -1
          {% elif is_state("input_select.living_room_harmony", "Watch TV") %}
            13558101
          {% elif is_state("input_select.living_room_harmony", "Watch Apple TV") %}
            13558128
          {% elif is_state("input_select.living_room_harmony", "Listen to Music Inside") %}
            13771248
          {% elif is_state("input_select.living_room_harmony", "Listen to Music") %}
            13558118
          {% endif %}

Scripts that don’t work:

listen_to_music_inside:
  alias : Listen to Music Inside
  sequence:
    - service: remote.turn_on
      entity_id: remote.living_room
      data:
        activity: “13771248”

listen_to_music:
  alias : Listen to Music
  sequence:
    - service: remote.turn_on
      entity_id: remote.living_room
      data:
        activity: “13558118”

watch_apple_tv:
  alias: Watch Apple TV
  sequence:
    - service: remote.turn_on
      entity_id: remote.living_room
      data:
        activity: “13558128”

watch_tv:
  alias: Watch TV
  sequence:
    - service: remote.turn_on
      entity_id: remote.living_room
      data:
        activity: “13558101”

Script that does work:

power_off:
  alias: Power Off
  sequence:
    - service: remote.turn_off
      entity_id: remote.living_room

@Matchmee At first glance I see different quotes which are not going to work. Change all of the ” to "

thanks, @Jer78 - I’m not sure why it copied like that in here, but those quotes are not what is in the script, they are the second option.

aside from those scripts, the input select also does nothing when you select something from the drop down menu

Have you tried just using an automation rather than the automation executing a script? Try this instead…

Also, just verify the activity numbers are correct. Sometimes I delete the harmony.conf file and let it recreate when restarting HA.

- alias: 'living_room_harmony_change_activity'
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_select.living_room_harmony
  condition:
    - condition: template
      value_template: '{% if states.input_select.living_room_harmony.state != states.remote.living_room.attributes.current_activity %}true{%endif%}'
  action:
    - service: remote.turn_on
      data_template:  
        entity_id: remote.living_room
        activity: >-
          {% if is_state("input_select.living_room_harmony", "PowerOff") %}-1
          {% elif is_state("input_select.living_room_harmony", "Watch TV") %}13558101
          {% elif is_state("input_select.living_room_harmony", "Watch Apple TV") %}13558128
          {% elif is_state("input_select.living_room_harmony", "Listen to Music Inside") %}13771248
          {% elif is_state("input_select.living_room_harmony", "Listen to Music") %}13558118
          {% endif %}
1 Like

What is your condition doing? Your code is cleaner than what I came up with, so I decided to use it instead of mine. It works great, but the condition gives me config errors and I’m not sure why… I thought it was a simple, if the current activity doesn’t match your input selection, then return true. But for some reason, this is considered invalid.

@HeffeD

Hmm, what error is it throwing? Is it just on startup because it hasn’t yet got the harmony current activity?
In any event, you don’t absolutely need the condition, but I put it in there if you have another automation that changes the the input_select based on the current activity, and in that case you don’t want it to send the activity request again.

No, I ignore the startup error. I know what’s going on with that.

Testing configuration at /config
Failed config
  automation: 
    - Invalid config for [automation]: [platform] is an invalid option for [automation]. Check: automation->condition->0->platform. (See /config/configuration.yaml, line 147). Please check the docs at https://home-assistant.io/components/automation/

Then it goes on to list my entire config file.

Oddly, this is line 147 from my config:
group: !include groups.yaml

@HeffeD My bad. It should be condition and not platform. I edited my post above. Thanks for catching that

Yeah, that makes more sense. I should have spotted that myself, especially after reading the error message, but I’ve just recently started getting into templates, so I was paying too much attention to them looking for the problem… :blush: Thanks!

1 Like

Been trying to get the input select to change back to powered off. It picks up the other changes from the Harmony remote. Any ideas? I am at a loss.

Here’s my automation config.

  • alias: “Power Off from Harmony Hub”
    trigger:
    platform: state
    entity_id: remote.living_room_tv
    condition:
    condition: template
    value_template: ‘{{ trigger.to_state.attributes.current_activity == “PowerOff” }}’
    action:
    service: input_select.select_option
    entity_id: input_select.living_room_tv
    data:
    option: “Power Off”

  • alias: “TV started from Harmony Hub”
    trigger:
    platform: state
    entity_id: remote.living_room_tv
    condition:
    condition: template
    value_template: ‘{{ trigger.to_state.attributes.current_activity == “Watch TV” }}’
    action:
    service: input_select.select_option
    entity_id: input_select.living_room_tv
    data:
    option: “Watch TV”

  • alias: “Kodi started from Harmony Hub”
    trigger:
    platform: state
    entity_id: remote.living_room_tv
    condition:
    condition: template
    value_template: ‘{{ trigger.to_state.attributes.current_activity == “Watch Kodi” }}’
    action:
    service: input_select.select_option
    entity_id: input_select.living_room_tv
    data:
    option: “Watch Kodi”

  • alias: “Movie started from Harmony Hub”
    trigger:
    platform: state
    entity_id: remote.living_room_tv
    condition:
    condition: template
    value_template: ‘{{ trigger.to_state.attributes.current_activity == “Watch a Movie” }}’
    action:
    service: input_select.select_option
    entity_id: input_select.living_room_tv
    data:
    option: “Watch a Movie”

  • alias: “Music started from Harmony Hub”
    trigger:
    platform: state
    entity_id: remote.living_room_tv
    condition:
    condition: template
    value_template: ‘{{ trigger.to_state.attributes.current_activity == “Listen to Music” }}’
    action:
    service: input_select.select_option
    entity_id: input_select.living_room_tv
    data:
    option: “Listen to Music”

  • alias: “Chromecast started from Harmony Hub”
    trigger:
    platform: state
    entity_id: remote.living_room_tv
    condition:
    condition: template
    value_template: ‘{{ trigger.to_state.attributes.current_activity == “Watch Chromecast” }}’
    action:
    service: input_select.select_option
    entity_id: input_select.living_room_tv
    data:
    option: “Watch Chromecast”

is there a simple way to get a volume slider and mute button directly in the group view?

this is what it looks like now:

and this is what my receiver can do:

image

Here’s how mine looks:

My entire config is here. Basically, I use the Harmony to set the volume on my Sonos and also use the Sonos volume level to update the HA UI. Take a look at the repo and let me know if you are still not clear.

1 Like

Hi

i am wondering if there is a possibility to send additional commands to a z-wave device within the following part of an automation for the harmony:

          {% if is_state("input_select.harmony_powertoggle", "Devices On/Off") %}L001

For example additionally to sending L001 through the harmony switching on a zwaveplug when “devices on” is chosen ?

@roninfr Are you talking about the “Harmony Home Hub Extender”?

1 Like

@gambit2552 no i am talking about a normal zwave plug to be switched on/off along with a device controlled by the harmony. Sorry i might have been kind of unclear :slight_smile:

So one device turned on by the harmony (older non zwave wall plug) and another device (zwave plug) turned on by the zwave stick. So to say 2 different devices within in that one line something like “L001 and switch.turn_on” when devices on/off is chosen :slight_smile:

I’d just do an input Boolean as the trigger then have both switches respond to it in a automation, I know probably not what your looking for though.

Thats sounds like it could be what i need :wink: Could you show how your “code” looks like?