Logitech Harmony Integration with @iandday's component

This is a nice solution too.

Hi Bahnburner, i have adpated your implementation and i get the following error:

16-12-26 12:03:13 homeassistant.bootstrap: Invalid config for [automation]: [data template] is an invalid option for [automation]. Check: automation->action->0->data template. (See /home/hass/.homeassistant/automation.yaml:6). Please check the docs at https://home-assistant.io/components/automation/

What am i missing?

- alias: Harmony Set Input Select On Start
  hide_entity: True
  trigger:
    platform: state
    entity_id: input_select.activities
    from: 'Select Activity'
  action:
    - service: remote.turn_on
      entity_id: remote.harmony
      data template:
        activity: >
          {% if is_state("input_select.activities", "Watch Tv") %}
            16944634
          {% elif is_state("input_select.activities", "Listen to Music") %}
            17396725
          {% elif is_state("input_select.activities", "Movie Lights") %}
            19022343
          {% elif is_state("input_select.activities", "Elena Zen") %}
            18733635
          {% elif is_state("input_select.activities", "Tv Off") %}
            -1
          {% else %}
          {% endif %}
    - service: input_select.select_option
      entity_id: input_select.activities
      data:
        option: "Select Activity"

Change data template to data_template. That one’s my fault. I’ll update my OP.

1 Like

Thx, i was killing myself for not seeing that.
Please put also the sign > after activity, that i figured it my self :slight_smile:

Woops. That too.

There’s a fully working version on my GitHub here: https://github.com/Bahnburner/Home-Assistant-Config/blob/master/automation/remote/living_room.yaml

2 Likes

This component is fantastic - finally allows me to interface quickly with my harmony hub when the wife has the remote!

The discussion here is mostly around using input_select to set or mirror activities set on the harmony hub.

I wanted an automation to allow me to send a ‘Pause’ command using the send_command service to whatever relevant device was active - you need to specify the device to sent the command as the component does not seem to know what the ‘Pause’ button is programmed for in each activity scenario. The use case is that my wife walks away and the remote is next to her. I can push a flic button (or do whatever to trigger an automation) and the relevant device will pause until she returns.

I used the template scenarios as mentioned in this discussion and others. Sharing it here as it took a while to get going and I hope it adds to the knowledge base. Also added the example as a PR to the documentation FWIW.

Phil

automation:
  - alias: Harmony Pause contextual for activity
    trigger:
    # trigger happens to be from a flic button - could be any valid event
      platform: event
      event_type: flic_click
      event_data:
        button_name: flic_80e4da70bbb1
        click_type: double
    action:
      service: remote.send_command
      data_template:
      # using a data template to have if brances for relavant device
        # Always the same entity_id - the harmony hub
        entity_id: remote.bedroom 
        # Always the same command - the Pause key
        command: Pause
        # select device based upon the activity being undertaken.
        device: >
          # when in WATCH TV activity, the pause key relates to a TiVo, which is device 22987101 
          {% if is_state("sensor.bedroom", "WATCH TV") %}
            22987101
          # when in WATCH APPLE TV activity, the pause key relates to an Apple TV, which is device 23002316
          {% elif is_state("sensor.bedroom", "WATCH APPLE TV") %}
            23002316
          {% elif is_state("sensor.bedroom", "PLEX") %}
            23048786
          {% elif is_state("sensor.bedroom", "WATCH BLU RAY") %}
            23043122
          {% endif %}
2 Likes

Does anyone have example code of a switch for say controlling just the device power on the tv?

service: remote.send_command
data_template:
  command: PowerOn
  device: 37313947
  entity_id: remote.livingroom

I am getting error - ( homeassistant.bootstrap: Invalid config for [automation]: expected a dictionary. Got OrderedDict([(‘homeassistant’,) …See /home/hass/.homeassistant/automation.yaml:1

My configuration is -
For Sensor.yaml -

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

input_select.yaml -

harmony:
  name: Harmony
  options:
   - Select Input 
   - Watch TV
   - cartoon
   - Aquarium
   - Xbox
   - PowerOff
  icon: mdi:monitor

Automation file : 1living_room.yaml-

- alias: Harmony
  hide_entity: True
  trigger:
    platform: state
    entity_id: input_select.harmony
    from: 'Select Activity'
  action:
    - service: remote.turn_on
      entity_id: remote.living_room
      data_template:
        activity: >
          {% if is_state("input_select.harmony", "Watch Tv") %}
            23029785
          {% elif is_state("input_select.harmony", "cartoon") %}
            23029465
          {% elif is_state("input_select.harmony", "Aquarium") %}
            20252019
          {% elif is_state("input_select.harmony", "Xbox") %}
            20639029
          {% elif is_state("input_select.harmony", "PowerOff") %}
            -1
          {% else %}
          {% endif %}
    - service: input_select.select_option
      entity_id: input_select.harmony
      data:
        option: "Select Activity"

automation.yaml -

####MEDIA BASED####
- !include automation/media_playing_day.yaml
- !include automation/media_stopped_day.yaml
- !include automation/say_weather.yaml
- !include automation/1living_room.yaml

The select activities doesn’t work]

Use preformatted text to post (makes it easier for helpers to repost with corrections).

Your error is in the automation: block - I don’t think we can see the cause from what you’ve posted. Make sure that under “automation:”, you only have groupings that start with “- alias: …” Does the error include a line number?

I have updated the post with original formatting. I don’t get any line number in log file but if i remove the 1living_room.yaml from automation then error goes away but my harmony select input also doesn’t work.

how are your other automations formated? I’m wondering if it’s an indentation issue.

I tried following your github page but stuck at this error.

I definitely think it’s an indentation error then. Are your other automation .yaml files indented at all? The indentation should match across all automations.

I just diabled the rest of it so i am doing something wrong in 1living_room.yaml config .

####MEDIA BASED####
#- !include automation/media_playing_day.yaml
#- !include automation/media_stopped_day.yaml
#- !include automation/say_weather.yaml
- !include automation/1living_room.yaml

since your !include is already an ordereddict, you shouldn’t need the '- ’ at the start of your 1livingroom.yaml file. you should be able to remove it, and remove the indention from the rest of the script.

alias: Harmony
hide_entity: True
trigger:
  platform: state
  entity_id: input_select.harmony
  from: 'Select Activity'
action:
  - service: remote.turn_on
    entity_id: remote.living_room
    data_template:
      activity: >
        {% if is_state("input_select.harmony", "Watch Tv") %}
          23029785
        {% elif is_state("input_select.harmony", "cartoon") %}
          23029465
        {% elif is_state("input_select.harmony", "Aquarium") %}
          20252019
        {% elif is_state("input_select.harmony", "Xbox") %}
          20639029
        {% elif is_state("input_select.harmony", "PowerOff") %}
          -1
        {% else %}
        {% endif %}
  - service: input_select.select_option
    entity_id: input_select.harmony
    data:
      option: "Select Activity"

SIDE NOTE: Instead of including each automation separately, why not just include the whole folder?

automation: !include_dir_merge_list automation

Bahnburner error is gone.Learned something new but stil have to figure out why input select not working.

Glad we could get that portion fixed. What’s wrong with the input_select?

Still checking. Its not changing the inputs when i select them.

Is there any other config also to get the harmony remote working. My input select doesn’t do anything and when i open HA it shows my LIVING ROOM remote Off with current activity Switch Off.