Logitech Harmony Integration with @iandday's component

Something like this might work I quickly put it together there might be errors in it.

# Declare your input boolean

input_boolean:
  switch_one:
    name: One Switch to Rule them all
    initial: off
    icon: mdi:plug


# Set your Automaion

automation:
  - alias: "one switch to manny - ON"
    trigger:
      - platform: state
        entity_id: input_boolean.switch_one
        from: 'off'
        to: 'on'
    condition: []
    action:
      - service: homeassistant.turn_on
        entity_id: switch.non_zwave_wall_plug
      - service: homeassistant.turn_on
        entity_id: switch.zwave_wall_plug


  - alias: "one switch to manny - OFF"
    trigger:
      - platform: state
        entity_id: input_boolean.switch_one
        from: 'on'
        to: 'off'
    condition: []
    action:
      - service: homeassistant.turn_off
        entity_id: switch.non_zwave_wall_plug
      - service: homeassistant.turn_off
        entity_id: switch.zwave_wall_plug
1 Like

Thank you very much! I will see if this is what i could use :grinning:

@gambit2552 That looks good and could work but i guess its not possible to change the state of this boolean within this automation (instead of sending L003):

  • id: harmony_power_toggle
    alias: harmony_power_toggle
    hide_entity: True
    trigger:
    platform: state
    entity_id: input_select.harmony_powertoggle
    from: ‘Select PowerSwitch’
    action:
    • service: remote.send_command
      entity_id: remote.harmonyhub
      data_template:
      device: 54887591
      command: >-
      {% if is_state(“input_select.harmony_powertoggle”, “AV Devices Power on”) %}L001

Something like that does not seem to work:

{% if is_state("input_select.harmony_powertoggle", "AV Devices Power on") %}- service: input_boolean.turn_on data: entity_id: input_boolean.switch_power_toggle_av

Try this, although not sure about the formatting as a used your non formatted text.

-id: harmony_power_toggle
 alias: harmony_power_toggle
 hide_entity: True
 trigger:
   -platform: state
    entity_id: input_select.harmony_powertoggle
    from: ‘Select PowerSwitch’
  action:
    - service: remote.send_command
      entity_id: remote.harmonyhub
      data_template:
      device: 54887591
      command: >- {% if is_state(“input_select.harmony_powertoggle”, “AV Devices Power on”) %}L001
    - service: homeassistant.turn_on
      entity_id: switch.zwave_wall_plug
1 Like

Thanks …i will check that out :slight_smile:

@gambit2552 That does not seem to work :frowning:

It seems to just ignore:

-service: homeassistant.turn_on
entity_id: switch.zwave_wall_plug

Found the issue… you cant control a zwave device when the template is sends a command…it needs to be entity_id instead of command…at least thats what i think

perhaps put the 2ed one before the first? not sure why its not working

Ive setup the harmony remote and home assistant to react if one or the other is used.

But im from sweden and we use the word “Stäng av” insted of “power off”.

And when i press my remote to turn off the harmony. To make homeassistant react to whats happening. i use this code:¨

Automasation were the problem is:

- alias: "Powered off from Harmony Hub"
  trigger:
    platform: state
    entity_id: remote.vardagsrum
  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: "Stäng av"

But sadly when i use that i get errors in the logg cause the option “Stäng av” is not “PowerOff” in input_select.
Invalid option: PowerOff (possible options: Välj Aktivitet, Tv, Htpc, Apple tv, Raspberry Pi, Stäng av)

Is there anyway to make it understand that i want it to use “Stäng av” when it see that remote is powered off?
Do mind that everything is working besides that i get the error in the logg.

seemed to be this that did it.
- alias: Harmony Set Input Select On Start
hide_entity: true
trigger:
platform: event
event_type: homeassistant_start
action:
- delay:
seconds: 30
- service: input_select.select_option
data_template:
entity_id: input_select.living_room_tv
option: ‘{{ states.remote.vardagsrum.attributes.current_activity }}’

Is this still working?

- alias: Harmony Set Input Select On Start
  hide_entity: true
  trigger:
    platform: event
    event_type: homeassistant_start
  action:
    - delay:
        seconds: 40
    - service: input_select.select_option
      data_template:
        entity_id: input_select.living_room_tv
        option: '{{ states.remote.vardagsrum.attributes.current_activity }}'

Asking cause nothing is happening on my setup that im using with the correct info filled.

I have solved it using scripts now… thats perfect and “looks” much cleaner than before :slight_smile:

are you doing it completely in scrip’s or calling a scrip from an automation?

no i call the scripts from an automation. Like:

  action:
- service: script.turn_on
  data_template: 
    entity_id: >-
      {% if is_state("input_select.harmony_powertoggle", "AV Devices Power on") %}script.av_devices_power_on_script

I did not know that i can use sequences and therefore can call different services in one script. Thats exactly what i need :slight_smile:

Hey guys.

I’m really interested in utilizing this component but I have no clue how to start the installation process. I’ve downloaded the zip file on my desktop but I have no clue how to upload/install this on my Hass.io.

Please advice. I am an absolutely clueless about python tbh.

Thanks!

It’s a standard component, no installing to do, try reading the docs :slight_smile:

Specifically referring to Step 1: Installation. What does this mean? Or should I just follow from “Add the Remote Component…” instead?

If you have the Discovery Component active, Home Assistant will automatically find your Harmony hubs. You can check out the Harmony Hub Remote component page to find some information to get you started.

Discovery Component is active. And there is a harmony_harmony_hub.conf file in my Config folder, however there is no way to select the activities or execute individual commands through Hass.io. I’d like to be able to select, for example, my tv (device) then power on/off toggle and input (actions) and my A/C (device) then Power On/Off Toggle and Timer (Action). Will this component enable me to do so with some modifications?

Yes, but you’ll need to supply all of the information manually. The config files mention the device ID’s you’ll need to control your devices, then you need to set up automations or scripts to send the individual commands to your hubs.

A popular method for control is using Input Select to select your activities. Variations of something like this.

- alias: 'TV Room Controls'
  initial_state: true
  hide_entity: true
  trigger:
    - platform: state
      entity_id: input_select.tv_room
  action:
    - service: remote.turn_on
      data_template:  
        entity_id: remote.tv_room
        activity: >-
          {% if is_state("input_select.tv_room", "PowerOff") %}-1
          {% elif is_state("input_select.tv_room", "Watch TV") %}18609512
          {% elif is_state("input_select.tv_room", "Watch Fire TV") %}18744923
          {% elif is_state("input_select.tv_room", "Watch a Movie") %}18609955
          {% elif is_state("input_select.tv_room", "Listen to Music") %}18609893
          {% elif is_state("input_select.tv_room", "Play Xbox") %}30907506
          {% endif %}
    - service: input_select.select_option
      entity_id: input_select.tv_room
      data_template:
        option: "Select Activity"

This gives you a drop down menu in your front end to select your activities. To send individual commands to your devices, you’ll also need to set up automations that will issue the commands to your hub. I’ve seen automations that use input sliders for volume adjustments, toggle switches, data input boxes, etc…

Edit: I forgot to add that you’ll need to add your Input Select info in your config file. Something like this.

input_select:
#Harmony
  tv_room:
    name: TV Room
    options:
     - Select Activity
     - Watch TV
     - Watch Fire TV
     - Watch a Movie
     - Listen to Music
     - Play Xbox
     - PowerOff
    initial: Select Activity
1 Like

Thanks for heading me in the right direction, after reading the instructions a few times over and analyzing the code you quoted, I’ll try to figure out some way to make it work. Thanks everyone for your help. I really appreciate it!

Thank you for posting your HA project. I was able to work out many of the problems I was having with my Harmony Hub after carefully reviewing your config/automation/script files.

You might want to investigate emulated_roku now too, allows you to easily control HA with Harmony rather than the other way around.