Logitech Harmony and HomeKit

Hi All,

Im trying to present things to home kit, which so far has gone quite ok but im kinda stuck with “input select” type operations. The home app only really seems to see things as on/off types of buttons no matter what I do and with the harmony i’ve just got the activities listed in an an input select. Is there some way to do that on the homekit? Or alternatively, i’ve been trying to have 1 button for each of the activities and have it reflected on both controls in HA at once. I thought this would be the easy path, but its proven more difficult than I thought because one of the activities is “poweroff” and so I cant quite figure out how i handle a situation where on homekit i can say have both a power off button and a button for an activity (which can also power off as well when you click the activity a second time - hope that makes sense?)

Hi @takigama :grin:,

I’ve been successful in exposing both switches and scripts to HomeKit with both being accessible via Siri. below are some examples:

homekit:

remote:
  - platform: harmony
    hide_entity: true
    name: HarmonyHub
    host: 192.168.69.100

switch:
  - platform: template
    switches:
        foxtel:
            friendly_name: "Watch Foxtel"
            value_template: "{{ is_state('Watch Foxtel', 'on') }}"
            turn_on:
                service: script.turn_on
                entity_id: script.watch_foxtel
            turn_off:
                service: script.turn_on
                entity_id: script.turn_off_tv
        apple:
            friendly_name: "Watch Apple TV"
            value_template: "{{ is_state('Watch Apple TV', 'on') }}"
            turn_on:
                service: script.turn_on
                entity_id: script.watch_appletv
            turn_off:
                service: script.turn_on
                entity_id: script.turn_off_tv        
        tv:
            friendly_name: "Watch TV"
            value_template: "{{ is_state('Watch TV', 'on') }}"
            turn_on:
                service: script.turn_on
                entity_id: script.watch_tv
            turn_off:
                service: script.turn_on
                entity_id: script.turn_off_tv 
        aircon:
            friendly_name: "Turn on Aircon"
            value_template: "{{ is_state('Aircon', 'On') }}"
            turn_on:
                service: script.turn_on
                entity_id: script.aircon
            turn_off:
                service: script.turn_on
                entity_id: script.aircon_off

These switches correspond to the following scripts:

script:
  watch_foxtel:
    alias: Watch Foxtel
    sequence:
      - service: remote.turn_on
        data_template:
            activity: 34559345
  turn_off_tv:
    alias: Turn Off TV
    sequence:
      - service: remote.turn_on
        data_template:
            activity: -1
  watch_appletv:
    alias: Watch Apple TV
    sequence:
      - service: remote.turn_on
        data_template:
            activity: 34559340
  watch_tv:
    alias: Watch TV
    sequence:
      - service: remote.turn_on
        data_template:
            activity: 34559334
  aircon:
    alias: Turn on Aircon
    sequence:
      - service: remote.send_command
        data_template:
            entity_id: remote.harmonyhub
            device: "55989482"
            command: "On"
  aircon_off:
    alias: Turn off Aircon
    sequence:
      - service: remote.send_command
        data_template:
            entity_id: remote.harmonyhub
            device: "55989482"
            command: "Off"

Good luck

you can import scripts into HomeKit. It works very good!

Yes but if I just expose the scripts, then Homekit seem to be missing the state?
Spinning wheel, I think it laks the above switch state

switches:
foxtel:
friendly_name: “Watch Foxtel”
value_template: “{{ is_state(‘Watch Foxtel’, ‘on’) }}”
turn_on:
service: script.turn_on
entity_id: script.watch_foxtel

At least my experience with exposing the script directly doesent work so reliable with Homekit since it sees it as a switch and wants know the state of it

You can use is_state_attr to have the actual state as the value:

switch:
        watchtv:
            friendly_name: "Watch TV"
            value_template: "{{ is_state_attr('remote.yourharmonyhub', 'current_activity', 'WatchTVActivityName') }}"
            ....

the “WatchTVActivityName” is the name as it appears on the Harmony, check your states if in doubt :slight_smile: