Determine which Harmony Activity is active

I want to create a conditional card in Lovelace that displays a remote with only the relevant buttons showing based on which activity was selected. However, I seem to only test if the state of remote.harmony_hub is on or off. I would like to test if the current_activity is Watch TV or what ever the current_activity is.

harmony

I installed the Harmony integration from the Integration tab and did not config it in the configuration.yaml.

Checkout state_attr

I think the problem is the condition card is limited to just using the state and not state_attr. Probably need a custom card.

You could break out the attribute into its own sensor using a template sensor:

sensor:
  - platform: template
    sensors:
      harmony_activity:
        friendly_name: "Harmony Activity"
        value_template: "{{ state_attr('remote.harmony_hub', 'current_activity') }}"

You would then be able to adjust your conditional card visibility using this sensor.

An alternative custom card is the states switch card, probably better suited to this application as it supports showing multiple cards for multiple states. You can use the template sensor or put the template directly in this card.

Thanks, I was looking into this as a way to go, your posting convinces me I need to try it out.

Ultimately, I want to create a remote for the TV in Lovelace that only presents button options for what you activity you set. My wife wants something she doesn’t need a training session to use. :slight_smile:

tom_l your sensor suggestion work like a charm. So now I managed to use the Service developer tools to verify the syntax for turning on my TV system to the Watch TV activity; and I can also turn it off.

So I decided to test the code in a simple card but for some reason, I can’t get it to work in a simple button-card just to test my code.

icon: 'mdi:power'
name: Power On
tap_action:
  action:
    service: remote.turn_on
    entity: remote.harmony_hub
    service data:
      entity_id: remote.harmony_hub
      activity: Watch TV
type: 'custom:button-card'

I’ve tried several different variants of the above code and nothing works.

service data:

Should be:

service_data:

I used petro example and created switches to handle my harmony remote

1 Like

I had first used service_data: and when that didn’t work I changed it to what you see which also didn’t work so that is when I posted. I know it is some little thing that I’m missing because it does work when I use the developer tools to call the service.

tap_action:
  action: call-service
  service: remote.turn_on
  service_data:
    entity_id: remote.harmony_hub
    activity: Watch TV

Mar16 impressive and a lot more than I had started out to do. Now you have given me some thoughts on how/what can be implemented. I definitely will be studying your post.

I used some thoughts from the previous link and came up with this.

the buttons/switches are easy to create. I’m still use them in my personal setup. I don’t use the rest of that post anymore though.

Great! Success! Changing the action line to

action: call-service

was what fixed it. BTW, it worked with or without the following line after the service

  entity: remote.harmony_hub

But I took it out because it appeared to work faster that way. Again thanks, I knew it was something miner I wasn’t catching due to still a noob.