Harmony Activities, Volume Slider, and Lovelace

well, can you just post exactly what you have written in your configuration?

The whole thing, or just the Harmony parts? And is it OK to PM it to you?

Just the harmony parts

Sensors:

sensor:
#Harmony hubs
  - platform: template
    sensors:
      tv_room:
        value_template: >
          {% if is_state("remote.tv_room", 'on') %}
            {{ states.remote.tv_room.attributes.current_activity }}
          {% else %}
            PowerOff
          {% endif %}
        friendly_name: 'TV Room'

#Track TV Stats
  - platform: history_stats
    name: TV Time
    entity_id: sensor.tv_room
    state: 'Watch Roku'
    type: time
    start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'

Switches:

switch:
#Harmony Activity Switches
  - platform: template
    switches:
# Power on/off
        tv_room_power:
          friendly_name: "Harmony Power"
          value_template: "{{ is_state('remote.tv_room', 'on') }}"
          turn_on:
            service: remote.turn_on
            entity_id: remote.tv_room
          turn_off:
            service: remote.turn_off
            entity_id: remote.tv_room
          icon_template: >-
            {% if is_state('remote.tv_room', 'on') %}
              mdi:power
            {% else %}
              mdi:power
            {% endif %}
#Watch TV
        watch_tv:
          friendly_name: "TV"
          value_template: "{{ is_state_attr('remote.tv_room', 'current_activity', 'Watch TV') }}"
          turn_on:
            service: remote.turn_on
            data:
              entity_id: remote.tv_room
              activity: 'Watch TV'
          turn_off:
            service: remote.turn_on
            data:
              entity_id: remote.tv_room
              activity: 'PowerOff'
          icon_template: >-
            {% if is_state_attr('remote.tv_room', 'current_activity', 'Watch TV') %}
              mdi:television-classic
            {% else %}
              mdi:television-classic
            {% endif %}
#Watch Roku
        watch_roku:
          friendly_name: "Roku"
          value_template: "{{ is_state_attr('remote.tv_room', 'current_activity', 'Watch Roku') }}"
          turn_on:
            service: remote.turn_on
            data:
              entity_id: remote.tv_room
              activity: 'Watch Roku'
          turn_off:
            service: remote.turn_on
            data:
              entity_id: remote.tv_room
              activity: 'PowerOff'
          icon_template: >-
            {% if is_state_attr('remote.tv_room', 'current_activity', 'Watch Roku') %}
              mdi:alpha-r-circle
            {% else %}
              mdi:alpha-r-circle-outline
            {% endif %}
#Watch A Movie
        watch_a_movie:
          friendly_name: "Blu-Ray"
          value_template: "{{ is_state_attr('remote.tv_room', 'current_activity', 'Watch a Movie') }}"
          turn_on:
            service: remote.turn_on
            data:
              entity_id: remote.tv_room
              activity: 'Watch a movie'
          turn_off:
            service: remote.turn_on
            data:
              entity_id: remote.tv_room
              activity: 'PowerOff'
          icon_template: >-
            {% if is_state_attr('remote.tv_room', 'current_activity', 'Watch a Movie') %}
              mdi:disc-player
            {% else %}
              mdi:disc-player
            {% endif %}
#Listen to Music
        listen_to_music:
          friendly_name: "Net Music"
          value_template: "{{ is_state_attr('remote.tv_room', 'current_activity', 'Listen to Music') }}"
          turn_on:
            service: remote.turn_on
            data:
              entity_id: remote.tv_room
              activity: 'Listen to Music'
          turn_off:
            service: remote.turn_on
            data:
              entity_id: remote.tv_room
              activity: 'PowerOff'
          icon_template: >-
            {% if is_state_attr('remote.tv_room', 'current_activity', 'Listen to Music') %}
              mdi:music-note-bluetooth
            {% else %}
              mdi:music-note-bluetooth-off
            {% endif %}
#Listen to Volumio
        listen_to_volumio:
          friendly_name: "Volumio"
          value_template: "{{ is_state_attr('remote.tv_room', 'current_activity', 'Listen to Volumio') }}"
          turn_on:
            service: remote.turn_on
            data:
              entity_id: remote.tv_room
              activity: 'Listen to Volumio'
          turn_off:
            service: remote.turn_on
            data:
              entity_id: remote.tv_room
              activity: 'PowerOff'
          icon_template: >-
            {% if is_state_attr('remote.tv_room', 'current_activity', 'Listen to Volumio') %}
              mdi:playlist-music
            {% else %}
              mdi:playlist-music-outline
            {% endif %}
#Play Xbox
        play_xbox:
          friendly_name: "Xbox One"
          value_template: "{{ is_state_attr('remote.tv_room', 'current_activity', 'Play Xbox') }}"
          turn_on:
            service: remote.turn_on
            data:
              entity_id: remote.tv_room
              activity: 'Play Xbox'
          turn_off:
            service: remote.turn_on
            data:
              entity_id: remote.tv_room
              activity: 'PowerOff'
          icon_template: >-
            {% if is_state_attr('remote.tv_room', 'current_activity', 'Play Xbox') %}
              mdi:xbox
            {% else %}
              mdi:xbox-controller-off
            {% endif %}
#Watch Fire TV
        watch_fire_tv:
          friendly_name: "Fire TV"
          value_template: "{{ is_state_attr('remote.tv_room', 'current_activity', 'Watch Fire TV') }}"
          turn_on:
            service: remote.turn_on
            data:
              entity_id: remote.tv_room
              activity: 'Watch Fire TV'
          turn_off:
            service: remote.turn_on
            data:
              entity_id: remote.tv_room
              activity: 'PowerOff'
          icon_template: >-
            {% if is_state_attr('remote.tv_room', 'current_activity', 'Watch Fire TV') %}
              mdi:amazon
            {% else %}
              mdi:amazon
            {% endif %}

Media player:

media_player:
# Onkyo AV Receiver
  - platform: onkyo
    host: 192.168.1.13
    name: Onkyo TX-NR626
    max_volume: 75
    sources:
      dvd: 'Blu-Ray'
      video2: 'Roku'
      game: 'Xbox'
      pc: 'Volumio'
      net: 'Network Music'
      fm: 'Radio'
      aux: 'Fire TV'

Remote:

# Harmony Hubs
remote:
  - platform: harmony
    name: TV Room
    activity: Watch Roku

Input number/select:

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

input_number:
#TV Room Harmony
  harmony_my_volume:
    icon: mdi:volume-high
    name: Volume
    initial: 15
    min: 0
    max: 75
    step: 1

Lovelace button card setup:

      - color: black
        color_type: icon
        entity: media_player.onkyo_tx_nr626
        icon: 'mdi:volume-mute'
        show_name: false
        show_state: false
        state:
          - color: '#FF3333'
            operator: template
            value: >
              return
              states['media_player.onkyo_tx_nr626'].attributes.is_volume_muted
              === true
        tap_action:
          action: call-service
          service: remote.send_command
          service_data:
            command: Mute
            device: 26677735
            entity_id: remote.tv_room
        type: 'custom:button-card'
      - color: black
        color_type: icon
        icon: 'mdi:volume-plus'
        tap_action:
          action: call-service
          service: remote.send_command
          service_data:
            command: VolumeUp
            delay_secs: 0.25
            device: 26677735
            entity_id: remote.tv_room
            num_repeats: 5
        type: 'custom:button-card'
      - color: black
        color_type: icon
        icon: 'mdi:volume-minus'
        tap_action:
          action: call-service
          service: remote.send_command
          service_data:
            command: VolumeDown
            delay_secs: 0.25
            device: 26677735
            entity_id: remote.tv_room
            num_repeats: 5
        type: 'custom:button-card'
      - color: black
        color_type: icon
        entity: input_number.harmony_my_volume
        icon: 'mdi:volume-low'
        label_template: |
          return states['input_number.harmony_my_volume'].state;
        layout: name_state
        show_icon: false
        show_label: true
        show_name: true
        show_state: false
        size: 95%
        styles:
          label:
            - color: blue
            - font-size: 90%
          name:
            - color: black
            - font-size: 90%
        tap_action:
          action: more-info
          service: null
          service_data:
            entity_id: input_number.harmony_my_volume
        type: 'custom:button-card'

Where’s the automations?

Sorry about that! The only automations I have regarding the Harmony are the ones you provided, and an input select automation. I didn’t think the input select one was relevant because it doesn’t do anything with volume, but here it is.

(I apologize for the difficult readability in the activity section, but the built in automation editor reforms them… :frowning:)

- alias: TV Room Controls
  initial_state: 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 Roku")
        %}37059432 {% 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", "Listen to Volumio") %}38322749 {% elif
        is_state("input_select.tv_room", "Play Xbox") %}30907506 {% elif is_state("input_select.tv_room",
        "Watch Fire TV") %}39223935 {% endif %}'
  - service: input_select.select_option
    entity_id: input_select.tv_room
    data_template:
      option: Select Activity
  id: d3a393ca359c48b9ab037fe4cab929f8

Wait, so what are you using to change the volume with the slider? That’s what I’m talking about, that’s the automation I want to see.

The ones you provided? (I apologize if I’ve given you all of the stuff you didn’t need, instead of the stuff you did need… :flushed:)

- alias: Onkyo Volume (Media to Slider)
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: media_player.onkyo_tx_nr626
  condition:
    - condition: template
      value_template: >
        {% set converted = trigger.to_state.state | float / 0.00925 %}
        {{ converted != states('input_number.harmony_my_volume') | float }}
  action:
     service: input_number.set_value
     data_template:
       entity_id: input_number.harmony_my_volume
       value: >
          {{ trigger.to_state.state | float / 0.00925 }}
- alias: Onkyo Volume (Slider to Media)
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: input_number.harmony_my_volume
  condition:
    - condition: template
      value_template: >
        {% set converted = trigger.to_state.state | float * 0.00925 %}
        {{ converted != state_attr('media_player.onkyo_tx_nr626','volume_level') | float }}
  action:
    - service: media_player.volume_set
      data_template:
        entity_id: media_player.onkyo_tx_nr626
        volume_level: >
          {{ trigger.to_state.state | float * 0.00925 }}

I was trying to use not mentioned here service remote.toggle to minimalize conditional if/else code. This service works but not 100% as expected.

With a code:

...
        tap_action:
          action: call-service
          entity: remote.logitech_harmony
          service: remote.toggle
          service_data:
            activity: TV
[...]
        tap_action:
          action: call-service
          entity: remote.logitech_harmony
          service: remote.toggle
          service_data:
            activity: Audio

I do expect remote will toggle indicated in service_data activity. Instead, it does toggle active activity. If no one is activated, it toggle correctly.

Any idea where is the error?

Could it be somehow connected with error?:

Not passing an entity ID to a service to target all entities is deprecated. Update your call to remote.toggle to be instead: entity_id: all

Not sure, never used the remote.toggle service.

Untill remote.toggle will come back to work properly is there workaround less complicated than scripts as. e.g.

        tap_action:
          action: call-service
          entity: remote.logitech_harmony
          service: |
            {% if is_state('sensor.harmony_current_activity', 'Audio') %}
              remote.turn_off
            {% elseif %}
              remote.turn_on
            {% endif %}
          service_data:
            activity: Audio

(that one is not working for me)

You can’t template in lovelace without a custom card, so the answer to your question is No.

i’m trying to set this up too, but cant get it to work

i entered “discovery” in my configuration.yaml file

then i have a yaml (which is included offcourse) containing:

remote:
  - platform: harmony
    name: Harmony_Hub
    activity: Tv kijken

switch:
  - platform: template
    switches:
      film_kijken:
        value_template: "{{ is_state('sensor.film_kijken', 'on') }}"
        turn_on:
          service: remote.turn_on
          data:
            entity_id: remote.harmony_hub
            activity: 'Film kijken'
        turn_off:
          service: remote.turn_on
          data:
            entity_id: remote.harmony_hub
            activity: 'PowerOff'

then i have a view for lovelace containing

title: Entertainment
icon: mdi:video-vintage
path: entertainment
theme: ios-dark-mode
cards:
  - type: entities
    entities:
      - switch.film_kijken

However, its not working.
in my lovelace gui, i see a switch but it doesnt do anything
next to it is also a lightning icon

im not sure about my harmony name either
when i open my harmony android app
it says connecting to “Harmony Hub”

I want a switch which starts for ex the activity Film Kijken
What am i doing wrong?

Also i do have a harmony_living.conf file which contains my activities
thx for the help

your switch template is incorrect. Take a look at mine again, specifically the value_template and try to replicate that with the correct entity_ids.

  1. You’re using the wrong command.
  2. You’re using the wrong entity.
  3. You’re looking at the wrong attribute.

I believe you are looking at the wrong switch template in the examples I provided. You need to look at the ones labeled XXX HARMONY ACTIVITY

i see

so i changed to

remote:
  - platform: harmony
    name: Harmony_Hub
    activity: Tv kijken

switch:
  - platform: template
    switches:
      film_kijken:
        value_template: "{{ is_state_attr('remote.harmony_hub', 'current_activity', 'Film kijken') }}"
        turn_on:
          service: remote.turn_on
          data:
            entity_id: remote.harmony_hub
            activity: 'Film kijken'
        turn_off:
          service: remote.turn_on
          data:
            entity_id: remote.harmony_hub
            activity: 'PowerOff'

gonna restart and see if its ok
not sure about the entity though

when i look at my list of entitites, i see nothing like a remote

you should have a remote in your states list. If you don’t, none of these switches will work. Why are you omitting the IP address of your harmony hub?

where can i find my states list?
i only have entitites, integrations, devices, zones

what do you mean, omitting the ip address?
i’m using the “discovery:” in my configuration, so no need to have the ipadress in it

Developer Tools -> States

ok i dont have the remote in it
not sure why not
cause i added it and restarted HA