Harmony Activities, Volume Slider, and Lovelace

I have everything running perfectly except the Xbox Live Gamertag and Online status Card that shows when the Xbox activity is enabled. I added the Xbox Live sensor including the API to configuration.yaml but the card doesn’t show underneath the Harmony card when I have my Xbox on. Can you help me?

what is the state of your xbox live sensor, what does it look like in the states page when on/off? I added a template sensor that did a bunch of crap for that information if I recall correctly. I’ve since removed it but I still should be able to help. I just need more information.

I don’t see it on the State page.
This is in my configuration.yaml

sensor:
  - platform: xbox_live
    api_key: *api key*
    xuid:
      - Rivanov

In my ui-lovelace.yaml

          - type: entity-filter
            entities:
              - sensor.xbox_live
              - sensor.xbox_current
            state_filter:
              - 'Online'
              - 'Home'
              - 'Netflix'

there will be a sensor named after your xbox live name

YES! I see it now. I forgot to put in the Profile User ID. No I see my Xbox Live gamertag. How can I show the current state with sensor.xbox_current? I don’t see that one on the State page.

Hi, I wanted to thank you for sharing your setup and explaining it so well.
I just started with home assistant and with the help of your post I also learned other general stuff.
I only had problems at first with the glance picture card because you stated all of this can be removed if not needed:

Turns out the picture glance card with state_image needs
entity: sensor.harmony_activity
to know when to switch pics.
Now this is logical and obvious to me :smiley:
Now I’m off to configuring Tasker Android app with home assistant and create shortcuts on the smartphone homescreen that act as buttons for my activities :slight_smile:

Ah yes, I probably wasn’t thinking when I said that originally.

My switch.yaml is below.

- platform: template
  switches:
    Listen_to_CD:
      friendly_name: "Listen to CD"
      value_template: "{{ is_state_attr('remote.harmony_hub', 'current_activity', 'Listen to CD') }}"
      turn_on:
        service: remote.turn_on
        data:
          entity_id: remote.harmony_hub
          activity: 'Listen to CD'
      turn_off:
        service: remote.turn_on
        data:
          entity_id: remote.harmony_hub
          activity: 'PowerOff'
    Play_Wii:
      friendly_name: "Play Wii"
      value_template: "{{ is_state_attr('remote.harmony_hub', 'current_activity', 'Play Wii') }}"
      turn_on:
        service: remote.turn_on
        data:
          entity_id: remote.harmony_hub
          activity: 'Play Wii'
      turn_off:
        service: remote.turn_on
        data:
          entity_id: remote.harmony_hub
          activity: 'PowerOff'
    Play_Wii_Projector:
      friendly_name: "Play Wii Projector"
      value_template: "{{ is_state_attr('remote.harmony_hub', 'current_activity', 'Play Wii Projector') }}"
      turn_on:
        service: remote.turn_on
        data:
          entity_id: remote.harmony_hub
          activity: 'Play Wii Projector'
      turn_off:
        service: remote.turn_on
        data:
          entity_id: remote.harmony_hub
          activity: 'PowerOff'
    Watch_BD_Movie:
      friendly_name: "Watch BD Movie"
      value_template: "{{ is_state_attr('remote.harmony_hub', 'current_activity', 'Watch BD Movie') }}"
      turn_on:
        service: remote.turn_on
        data:
          entity_id: remote.harmony_hub
          activity: 'Watch BD Movie'
      turn_off:
        service: remote.turn_on
        data:
          entity_id: remote.harmony_hub
          activity: 'PowerOff' 
    Airplay_Music:
      friendly_name: "Airplay Music"
      value_template: "{{ is_state_attr('remote.harmony_hub', 'current_activity', 'Airplay Music') }}"
      turn_on:
        service: remote.turn_on
        data:
          entity_id: remote.harmony_hub
          activity: 'Airplay Music'
      turn_off:
        service: remote.turn_off
        data:
          entity_id: remote.harmony_hub
          activity: 'PowerOff'
    Watch_Movie:
      friendly_name: "Watch Movie"
      value_template: "{{ is_state_attr('remote.harmony_hub', 'current_activity', 'Watch Movie') }}"
      turn_on:
        service: remote.turn_on
        data:
          entity_id: remote.harmony_hub
          activity: 'Watch Movie'
      turn_off:
        service: remote.turn_off
        data:
          entity_id: remote.harmony_hub
          activity: 'PowerOff'
    Watch_Apple_TV:
      friendly_name: "Watch Apple TV"
      value_template: "{{ is_state_attr('remote.harmony_hub', 'current_activity', 'Watch Apple TV') }}"
      turn_on:
        service: remote.turn_on
        data:
          entity_id: remote.harmony_hub
          activity: 'Watch Apple TV'
      turn_off:
        service: remote.turn_off
        data:
          entity_id: remote.harmony_hub
          activity: 'PowerOff'
    Watch_TV:
      friendly_name: "Watch TV"
      value_template: "{{ is_state_attr('remote.harmony_hub', 'current_activity', 'Watch TV') }}"
      turn_on:
        service: remote.turn_on
        data:
          entity_id: remote.harmony_hub
          activity: 'Watch TV'
      turn_off:
        service: remote.turn_off
        data:
          entity_id: remote.harmony_hub
          activity: 'PowerOff'

But the Harmony hub activities still didn’t display any switches.It shows below.

 ERROR (MainThread) [homeassistant.config] Invalid config for [switch.template]: invalid slug Listen_to_CD (try listen_to_cd) for dictionary value @ data['switches']. Got OrderedDict([('Listen_to_CD', OrderedDict([('friendly_name', 'Listen to CD'), ('value_template', "{{ is_state_attr('remote.harmony_hub', 'current_activity', 'Listen to CD') }}"), ('turn_on', OrderedDict([('service', 'remote.turn_on'), ('data', OrderedDict([('entity_id', 'remote.harmony_hub'), ('activity', 'Listen to CD')]))])), ('turn_off', OrderedDict([('service', 'remote.turn_on'), ('data', OrderedDict([('entity_id', 'remote.harmony_hub'), ('activity', 'PowerOff')]))]))])), ('Play_Wii', Ord.... (See C:\Users\benny\AppData\Roaming\.homeassistant\switch.yaml, line 0). Please check the docs at https://home-assistant.io/components/switch.template/

I am new in HA.I am stucked for weeks.Please help!TKS!

You can’t have capitals for the name of the switches.

Change all your names to lowercase.

- platform: template
  switches:
    Listen_to_CD: #<------------ CANNOT BE CAPITALS
      friendly_name: "Listen to CD"
      value_template: "{{ is_state_attr('remote.harmony_hub', 'current_activity', 'Listen to CD') }}"
      turn_on:
        service: remote.turn_on
        data:
          entity_id: remote.harmony_hub
          activity: 'Listen to CD'
      turn_off:
        service: remote.turn_on
        data:
          entity_id: remote.harmony_hub
          activity: 'PowerOff'

It works!
You guys are so great!Thank you so much!

First of all, just wanted to say thank you so much for your guide! It’s worked a treat!

Also intergrated Google Assistant so she can enable my harmony activities via HA.

One quick question i’m hoping you might be able to help with! I’ve set up my chromecast using your guide, but i’m about to set another one up upstairs.

Would I change something in your code so that instead of saying “Ok Google, turn on chromecast”, I can say “Ok Google, turn on bottom chromecast”

Bascially looking to see where I would rename the chromecast.

Thanks in advance

1 Like

Add/Change the friendly name in the customize section of the configuration. Either through the ui or yaml. Or change it in whatever integration you are using for the chromecast (if it’s a configuration option).

Thanks Petro. Seem to having a right mare with this! I updated the activity name in Harmony to “Bottom Chromecast”.

My harmony_downstairs.conf updated to reflect this:

 "Activities": {
        "-1": "PowerOff",
        "40793383": "Bottom Chromecast",
        "40793388": "XboxOne",
        "40793395": "Playstation",
        "40793399": "Xbox360"

I then updated my config file to show:

media_player:
  - platform: onkyo
    host: xxx.xxx.x.xx
    name: Pioneer
    sources:
      HDMI1: "XboxOne"
      HDMI2: "Xbox360"
      HDMI3: "Bottom Chromecast"
      HDMI4: "Playstation"

and in the switch.yaml changed the settings to:

# BOTTOM CHROMECAST HARMONY ACTIVITY
        bottom_chromecast:
          friendly_name: Bottom Chromecast
          value_template: "{{ is_state_attr('remote.downstairs', 'current_activity', 'Bottom Chromecast') }}"
          turn_on:
            service: remote.turn_on
            data:
              entity_id: remote.downstairs
              activity: '"Bottom Chromecast"'
          turn_off:
            service: remote.turn_on
            data:
              entity_id: remote.downstairs
              activity: 'PowerOff'

However I seem to have two switches when I try to update the card. When I click on one it lights up and then turns off with this error

Downstairs: Activity “Bottom Chromecast” is invalid

The second switch just stays lit, but nothing happens.

Is there something really obvious I have missed here?!

Why did you change all that? All you need to do is change the name that goes TO google assistant. Keep the switch template and everything else untouched. As I said before, you can rename the devices (the home assistant switches) in the customization section. Or whatever integration you are using to connect to chromecast.

My bad. I just thought in the long run it would have been easier to have everything named the same, so theres no confusion when I have a Chromecast upstairs called “Chromecast”.

I’ve changed everything back, but still getting the switch error: Downstairs: Activity “Chromecast” is invalid

Any idea what this might relate to at all? Failing that, will delete everything and start again. Thanks in advance.

What is the name of the activity in harmony? And when you restart home assistant, what does the harmony.conf say the name of the activity is?

FYI, you seem to have the impression that home assistant uses harmony.conf. It does not, it creates that file for you as a user. It’s so that you can see what harmony names things and what commands you have available for automations. Changing that file does nothing, home assistant will overwrite it every restart.

Petro, many thanks for your help, however by luck I just stumbled across what the error was. Was a school boy error here - activity: '"Bottom Chromecast"' - I had " either side! Removed them and it now works a treat!

If it’s possible to ask you one more quick question if you don’t mind relating to created a volume slider just for the Pioneer Amp. Would love to have on that looks like what dmatik created in the middle of the thread:
image

Once the code you shared has been added to input_number.yaml - How is that called to a card?

Input number will show up as a slider.

If you want volume up/ down buttons, you need to make a script that acts as a volume press. Use harmony.conf to figure out the command/device required to make the volume up/down/mute commands.

EDIT:

This close to what I use assuming you just want to control the receiver and not whatever is going on with harmony.

volume up

            - service: media_player.volume_set
              data_template:
                entity_id: media_player.yamaha
                volume_level: >-
                  {% set level = state_attr('media_player.yamaha','volume_level') %}
                  {% set next = level + 0.01 %}
                  {{ next if next <= 1 else 1.0 }}

volume down

            - service: media_player.volume_set
              data_template:
                entity_id: media_player.yamaha
                volume_level: >-
                  {% set level = state_attr('media_player.yamaha','volume_level') %}
                  {% set next = level - 0.01 %}
                  {{ next if next >= 0 else 0.0 }}

Thanks @petro
So the example code you gave, is that added into a script?

that is a single service call, that can be added to an action of an automation or the sequence of a script.