Logitech Harmony Hub use starting a activity as trigger

Hi,
I am relatively new when it comes to Home assistant.
I have years of experience with openHAB
But Home assistant has come a long way since I last tried it about 3 years ago.
Now I want to use Home assistant as my main system

Now I run into some things that I did well in openHAB but don’t know how to do that in Home assistant.

Below I will explain what I am dealing with.

If this is the wrong caregory/topic or the wrong forum, please let me know.

I am running the “Logitech Harmony” integration for my “Logitech Harmony Hub” and can select and execute the various activities.

Now when I start an activity I want to perform various actions such as close shutter and power switch on for my media player, etc.

I have read the documentation at Logitech Harmony Hub - Home Assistant

I think I’m still missing some specific Home assistant knowledge.
I see YAML examples but don’t know what they do.

YAML is a markup language and not a scripting language if I’m correct!?

I have 2 Entity that may be of interest

  • remote.backroom_harmony_hub
  • select.backroom_harmony_hub_activities

I want something like

trigger
activity: Nvida shield is starting

Actions

  • Switch Entity to ON
  • Shutter down
  • etc.

Not that complicated I guess :wink:

I’ve read a lot of posts but probably not the right one, because I probably won’t be the first to ask this or a similar question

Thanks in advance for all the help and information

Intel NUC
Home Assistant 2022.9.2
Supervisor 2022.08.6
Operating System 8.5
Frontend 20220907.0 - latest

You want to look at automations Automating Home Assistant - Home Assistant (home-assistant.io).

There’s an automation editor in settings => automations and scenes.

Use the state change of the entity for the harmony activity as a trigger and then define what other actions you want to take. It will create yaml, as that’s how automations are defined, but it’s simpler to get started with the gui editor.

1 Like

Thanks for your comment.

If I use the Automation below, the automation is not responding to the trigger.

alias: "Starting Activity Shield TV "
description: "Starting Activity Shield TV "
trigger:
  - platform: state
    entity_id:
      - remote.achterkamer_harmony_hub
    attribute: activity_starting
    to: SHIELD TV
condition: []
action:
  - type: turn_on
    device_id: 926f41c63daff06bd02a80bfc10a71e9
    entity_id: switch.achterkamer_mediaplayer_wall_plug_2
    domain: switch
mode: single

I tried as attribute activity_starting and current_activity, both are not seen as trigger

If i use “Developer Tools” the activity is write like “SHIELD_TV” including the "
" en back slash symbol between D and _ symbol

If I enter this via the GUI, home assistant changes this back to SHIELD TV

Did the integration not also create a switch for each of the Harmony’s activities? Worth checking at Settings > Devices & Services and finding the integration. It will say something like ‘1 device and X entities’.

It’s much easier to use state changes in these switches (“on”/“off”) as automation triggers.

If you can get it working with the switch for your Shield TV activity (which I’m pretty sure should exist), I’d be happy to share a single automation I use.

It combines all my Harmony activities into one state trigger, and then passes the triggered switch as a parameter to a specific script for each activity, effectively doing what you’re after (closing covers turning lights on/off, setting volume level on the receiver and so on).

EDIT: I should add if you can’t find the switches, then you can use state changes in the select entity, as it always updates to reflect the current activity. You would then use a condition at the start of your automation that checks that the value of the trigger.to_state.state variable is SHIELD_TV or whatever.

Out of curiousity, I checked my Harmony Hub integration. There were 2 disabled entries, both switches. I enabled one of them (you have to open the entity, go to advanced, enable it, and wait 30 seconds), and it does look like it is showing as on if the activity is running. So the OP might try:

trigger:
  - platform: state
    entity_id:
      - switch.harmony_hub_watch_appletv
    to: "on"

the attribute is current_activity not activity_starting.

Aslo keep in mind that there’s a 30 second polling rate on harmony. I.e. if you turn on an activity, it’ll take upwards of 30 seconds to react.

As @petro pointed out. The attribute should be current_activity. I have my harmony setup with node red automations to change lights/etc. and am watching this specific topic: data.attributes.current_activity.

Thanks for the useful information, I learned a lot in a short time.
And come to the conclusion that the approach to things is slightly different than in OpenHAB

I found a disabled entity for every activity of my Harmony hub.
I can use the “on” status as a trigger when I start watching a movie.

Now I have to catch the “PowerOff” status.
Because the “switch.harmony_hub_shield_tv” off status doesn’t mean that I’m done watching but or could mean that I’ve started another activity like watching DVD

So “switch.harmony_hub_shield_tv” OFF is not a good trigger.

I still have so much to do to transfer the functionality that I have in OpenHAB to Home Assistant.

But so far I have been very surprised by the user-friendliness that is now available.

Hi Petro,
Thanks for the explanation.
to be clear, tdoes this mean that only after 30 seconds of starting the activity the command to turn off a lamp, for example, is executed?

It means, if you use the remote to change your activity, home assistant will not see the action until the next poll is performed. Polling is executed every 30 seconds. So if you turn on your activity 21 seconds in relation to the polling fequency, then it’ll take 9 seconds for HA to react.

This is a limitation of Harmony as it does not offer a push update style API.

There are ways around it using the emulated roku integration.

2 Likes

I have a switch entity for each activity, and a seperate entity - remote.lounge which is on when any activity is running and off when no activities are running. You should have similar and be able to use that to see when nothing’s on.

Thanks for the clarification Pedro

But if you include all your switches as triggers in the same automation, and set it in parallel mode, then the ‘on’ event for watching DVD will be caught after the ‘off’ event for the Shield TV, and potentially processed by whatever condition or action sequence you’d like to use based on the value of the trigger.to_state.state variable.

For example, I like to turn off my voice activation while watching any media with speech (TV, films) to avoid false positives. I use the ‘off’ event to turn voice activation back on it was off, or vice versa. Sometimes it means it goes through a rapid ‘off → on → off’ sequence if say I switch from watching TV to a video on Chromecast, but I can live with that.

Those are valuable tips Chris,
Thank you.

Why would the integration “poll” the hub? It can maintain either an xmpp (official) or websocket (unofficial) connection and you can get live updates that way without polling.

I’ll have to check out how it now works as a 30 second poll is ridiculous. It’s literally going backwards from what the hardware can do.

(I know it’s possible as I wrote one of the Homeseer harmony plugins and it maintains connectioms for months on end)

Nevermind. I just checked, it can’t be polling. It’s changing values too fast after I press the activity and power off buttons. It also appears to fire the device/entity changes on activity stating not activity complete, which is ok with me. I prefer having both options, but this will do.

It used to be polling only for the state of the activity. This changed sometime in the past few years. Yes it was dumb and yes it could have changed, but no one was willing to make the change at the time.

1 Like

can you share the code? (: