Harmony doesnt work properly (input_select)

In ui-lovelace.yaml

###Harmony###
      - type: entities
        title: Harmony
        show_header_toggle: false
        entities:
          - entity: input_select.harmony_hub
            name: Aktivitet
            icon: mdi:remote

in configuration.yaml

remote:
  - platform: harmony
    name: Harmony hub
    host: 192.168.1.9

# Input Select
input_select:
  harmony_hub:
    name: Harmony Activity
    options:
      - Velg aktivitet
      - TV
      - Shield
      - PowerOff
    initial: Velg aktivitet

in automations.yaml

- id: Remote Update Harmony Hub
  alias: 'Remote update Harmony Hub'
  trigger:
    platform: state
    entity_id: remote.harmony_hub
  action:
    service: input_select.select_option
    data_template:
      entity_id: input_select.harmony_hub
      option: >
        {%- set activity = state_attr('remote.harmony_hub','current_activity') %}

- id: Start Selected Activity
  alias: 'Remote start activity from input select living room tv'
  trigger:
    platform: state
    entity_id: input_select.harmony_hub
  action:
    service: script.turn_on
    entity_id: script.input_select_harmony
    data_template:
      activity: >
        {% if is_state("input_select.harmony_hub", "TV") %}
          26607850
        {% elif is_state("input_select.harmony_hub", "Shield") %}
          41482977
        {% elif is_state("input_select.harmony_hub", "PowerOff") %}
          -1
        {% else %}
        {% endif %}

Forgot to expalin issue, when using input select, nothing happens, but also no error

From logs:

Error while executing automation automation.remote_start_activity_from_input_select_living_room_tv. Invalid data for call_service at pos 1: extra keys not allowed @ data['activity']

Updaed with this

- alias: 'Set Harmony activity using input_select'
  trigger:
    platform: state
    entity_id: input_select.harmony_hub
  action:
    service: script.turn_on
    entity_id: script.input_select_harmony

- alias: 'Remote update Harmony Hub'  
  trigger:
    platform: state
    entity_id: remote.harmony_hub
  action:
    service: input_select.select_option
    data_template:
      entity_id: input_select.harmony
      option: >
        {{ states.remote.harmony_hub.attributes.current_activity }}

now i get this:

while parsing a block mapping
  in "/config/automations.yaml", line 9, column 3
expected <block end>, but found '<scalar>'
  in "/config/automations.yaml", line 9, column 39

I got it working after some issues :slight_smile:

Your solution doesn’t show an actual solution… better off leaving it unchecked because other users will come and find… no solution.

Here is a solution that would work:

lovelace

      - type: entities
        title: Harmony
        show_header_toggle: false
        entities:
          - entity: input_select.harmony_hub
            name: Aktivitet
            icon: mdi:remote

input select

input_select:
  harmony_hub:
    name: Harmony Activity
    options:
      - Velg aktivitet
      - TV
      - Shield
      - PowerOff
    initial: Velg aktivitet

hub configuration

remote:
  - platform: harmony
    name: Harmony hub
    host: 192.168.1.9

automation

- alias: 'Set Harmony activity using input_select'
  trigger:
    platform: state
    entity_id: input_select.harmony_hub
  action:
    service: remote.turn_on
    data_template:
      entity_id: remote.harmony_hub
      activity: "{{ trigger.to_state.state }}"

- alias: 'Remote update Harmony Hub'  
  trigger:
    platform: state
    entity_id: remote.harmony_hub
  condition:
    condition: template
    value_template: {{ trigger.to_state.attributes.current_activity in state_attr('input_select.harmony_hub','options') }}
  action:
    service: input_select.select_option
    data_template:
      entity_id: input_select.harmony
      option: "{{ trigger.to_state.attributes.current_activity }}"
2 Likes

Any idea with mine why I’m getting “Error while executing automation automation.tv_source_automation_from_input_select. Invalid data for call_service at pos 1: not a valid value for dictionary value @ data[‘entity_id’]” when I’m trying to turn on an activity from the input_select pulldown and it doesn’t work?

automations:

- alias: "TV Source Automation From Input Select"
  initial_state: on
  trigger:
    platform: state
    entity_id: input_select.harmonytvsource
  action:
    - service: remote.turn_on
      data_template:
        entity_id: >
         {% if is_state('input_select.harmonytvsource', 'Watch TV') %}
         script.turn_on_watch_tv_activity
         {% elif is_state('input_select.harmonytvsource', 'Listen To Music') %}
         script.turn_on_listen_to_music_activity
         {% elif is_state('input_select.harmonytvsource', 'PowerOff') %}
         script.turn_off_activity
         {% endif %}

# Update input_select for TV Source
- alias: "Update Hub TV Source From Remote"
  initial_state: on
  trigger:
    platform: state
    entity_id: remote.familyroom_hub
  condition:
    condition: template
    value_template: "{{ trigger.to_state.attributes.current_activity in state_attr('input_select.harmonytvsource', 'options') }}"
  action:
    service: input_select.select_option
    data_template:
      entity_id: input_select.harmonytvsource
      option: "{{ trigger.to_state.attributes.current_activity }}"

input_select:

harmonytvsource:
  name: Harmony Activities
  options:
    - Select Activity
    - Watch TV
    - Listen To Music
    - PowerOff
  initial: Select Activity

Lovelace:

entities:
  - entity: input_select.harmonytvsource
    icon: 'mdi:remote'
    name: Harmony Activities
show_header_toggle: false
type: entities

Glad to provide anything additional.

Because you have

as your service but you are calling scripts:

Thanks Petro,

I tried that but still doing it:

- alias: "TV Source Automation From Input Select"
  initial_state: on
  trigger:
    platform: state
    entity_id: input_select.harmonytvsource
  action:
    - service: script.turn_on
      data_template:
        entity_id: >-
         {% if is_state('input_select.harmonytvsource', 'Watch TV') %}
         script.turn_on_watch_tv_activity
         {% elif is_state('input_select.harmonytvsource', 'Listen To Music') %}
         script.turn_on_listen_to_music_activity
         {% elif is_state('input_select.harmonytvsource', 'PowerOff') %}
         script.turn_off_activity
         {% endif %}

Should note when I turn on the TV from the remote I get this also:

Error while executing automation automation.tv_source_automation_from_input_select. Invalid data for call_service at pos 1: not a valid value for dictionary value @ data[‘entity_id’]

what’s the state of input_select.harmonytvsource when the error occurs? Also, why are you not using the trigger objects to_state?

So I just triggered the input_select pulldown. TV was on and it showed Watch TV. I changed to PowerOff and nothing happened. Again error:

Error while executing automation automation.tv_source_automation_from_input_select. Invalid data for call_service at pos 1: not a valid value for dictionary value @ data[‘entity_id’]

Also when you mean trigger state, haven’t tried it other than creating it but something like this?

- alias: "TV Source Automation From Input Select"
  initial_state: on
  trigger:
    platform: state
    entity_id: input_select.harmonytvsource
  action:
    - service: script.turn_on
      data_template:
        entity_id: >
         {% if trigger.to_state.state == 'Watch TV' %}
           script.turn_on_watch_tv_activity
         {%-elif trigger.to_state.state == 'Listen To Music' %}
           script.turn_on_listen_to_music_activity
         {%-elif trigger.to_state.state == 'PowerOff' %}
           script.turn_off_activity
         {% endif %}

Can you post your entire configuration, input_selects, scripts, and your harmony conf

Let me know here or the other thread what you want me to include, just the scripts tied to Harmony or everything as there are a lot. That said, do you know the difference between homeassistant.turn_on vs script.turn_on?

Should mention changing it to this works but is directly calling the hub and running the activity, not the HA script:

- alias: "TV Source Automation From Input Select"
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: input_select.harmonytvsource
  action:
    - service: homeassistant.turn_on
      data_template:
        entity_id: remote.familyroom_hub
        activity: "{{ trigger.to_state.state }}"

Thanks.

JR

homeassistant.turn_on is generic.

Just try this

- alias: "TV Source Automation From Input Select"
  initial_state: on
  trigger:
    platform: state
    entity_id: input_select.harmonytvsource
  condition:
  - condition: template
    value_template: "{{ trigger.to_state.state != 'Select Activity' }}"
  action:
  - service_template: >
     {%- if trigger.to_state.state == 'Watch TV' %}
       script.turn_on_watch_tv_activity
     {%- elif trigger.to_state.state == 'Listen To Music' %}
       script.turn_on_listen_to_music_activity
     {%- elif trigger.to_state.state == 'PowerOff' %}
       script.turn_off_activity
     {%- endif %}

Thanks Petro, so this is weird, Before seeing your post, I copied my automation from a separate input_select for selecting my favorite channels and tweaked it for this one and it is working right now. The weird part I can’t tell apart.

- alias: "TV Source Automation From Input Select"
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: input_select.harmonytvsource
  action:
    - service: homeassistant.turn_on
      data_template:
        entity_id: >
         {% if is_state('input_select.harmonytvsource', 'PowerOff') %}
         script.turn_off_activity
         {% elif is_state('input_select.harmonytvsource', 'Watch TV') %}
         script.turn_on_watch_tv_activity
         {% elif is_state('input_select.harmonytvsource', 'Listen To Music') %}
         script.turn_on_listen_to_music_activity
         {% endif %}

I did try it with the homeassistant.turn_on before and didn’t do anything. Only difference here is the PowerOff was first in my if statement so not entirely sure if there was something from the cut and paste that fixed it or if there was a single quote character that was wrong and couldn’t see it or what.