Deprecated Harmony entity detected in script.theater_mode_off

I am afraid that I still not not quite understand what to do until the mid of 2024. I use the “switch” to retrieve the state of the remote. For example, if I watch TV, use a stick, or play the XBox, I want the Harmony Hub to switch the volume up and down every :05 minutes after the hour, because otherwise the TV automatically switches off (no joke, this is supposed to be a feature).

Therefore, I provided the following automation:

alias: Reactivate TV every hour
description: Shortly sets volume down and up five minutes after every full hour
trigger:
  - platform: time_pattern
    minutes: "5"
condition:
  - condition: or
    conditions:
      - condition: device
        type: is_on
        device_id: 5c592c0bcb78097b0a5e662e5b6763b4
        entity_id: switch.harmony_hub_2_watchtv
        domain: switch
      - condition: device
        type: is_on
        device_id: 5c592c0bcb78097b0a5e662e5b6763b4
        entity_id: switch.harmony_hub_2_xbox_play
        domain: switch
      - condition: device
        type: is_on
        device_id: 5c592c0bcb78097b0a5e662e5b6763b4
        entity_id: switch.harmony_hub_2_fire_tv_watch
        domain: switch
      - condition: device
        type: is_on
        device_id: 5c592c0bcb78097b0a5e662e5b6763b4
        entity_id: switch.harmony_hub_2_television_only_tv
        domain: switch
action:
  - service: remote.send_command
    data:
      delay_secs: 0.6
      device: "68048731"
      command:
        - VolumeDown
        - VolumeUp
mode: single

How would I be supposed to change this? To me, this is not clear from the earlier posts in this thread. Thank you in advance.

Currently I use Google Home and/or HomeKit to turn the various Harmony Hub scenes on for different TV inputs (AppleTV, Chromecast etc). I’ve created the new Template switches, and they seem to work but they don’t have the full functionality of the built-in switches.

If I turn the AppleTV on, it will turn on the TV, AppleTV and Receiver, and set them to the appropriate inputs. If I then turn on the Chromecast, the Harmony Hub will only change the inputs (knowing that I still need the TV and Receiver on), but it will also turn off the AppleTV switch.

With my new Template switches, I can turn on the AppleTV, then the ChromeCast, but if I then try to turn on the AppleTV again, either immediately or after turning off the Chromecast, this won’t work as Home Assistant thinks the AppleTV is already on (or at least it seems inconsistent when it will or won’t work in this situation). Is there a way to mimic the existing switch behaviour?

I also have a Broadlink RM4 device that suffers the same problem so it would be good to have a generic solution that allows only one switch from a group to be on at a time without the off routine of other switch(s) also firing when they’re turned off.

They should be functionally indistinguishable - they certainly are for me.

Post a sample switch code just to double check.

I have 4 switches configured like this.

- platform: template
  switches:
    lounge_room_appletv:
      unique_id: ab137072-e933-4062-b0d5-14eee30a10f7
      friendly_name: Lounge Room AppleTV
      turn_on:
        service: select.select_option
        target:
          entity_id:
            - select.harmony_hub_activities
          device_id: []
          area_id: []
        data:
          option: Lounge Room AppleTV
      turn_off:
        service: select.select_option
        target:
          entity_id:
            - select.harmony_hub_activities
          device_id: []
          area_id: []
        data:
          option: power_off

If I turn one on and then a second, this will leave the first switch on. With the built in Harmony Hub integration switches, the first switch would have been turned off.

There’s also a slight difference in the appearance of the switch in the Home Assistant interface. These switches look like this with two sections.

image

Where as other non-template (?) switches look like this; more of a slider.

image

This seems to only be a visual thing though, not functional, so I’m not particularly concerned, it just seemed strange to have two different ways of presenting a two position switch.

You need to add a value_template key so that the switch reports its state to Home Assistant. Otherwise, the switch state defaults to optimistic, which usually means it stays on after it is switched on, unless directly switched off. The absence of this key also explains why it looks different in the frontend.

- platform: template
  switches:
    lounge_room_appletv:
      unique_id: ab137072-e933-4062-b0d5-14eee30a10f7
      friendly_name: Lounge Room AppleTV
      value_template: >
        {{ is_state('select.harmony_hub_activities', 'Lounge Room AppleTV') }}
      turn_on:
        service: select.select_option
        target:
          entity_id:
            - select.harmony_hub_activities
        data:
          option: Lounge Room AppleTV
      turn_off:
        service: select.select_option
        target:
          entity_id:
            - select.harmony_hub_activities
        data:
          option: power_off

Everyone coming to this thread

This will create all activities as switches

Simply copy/paste the following code chunk into your template editor.

Template Editor:
Open your Home Assistant instance and show your template developer tools.

Code Chunk:

{% set entity = 'remote.living_room' %}
switch:
  - platform: template
    switches:
  {%- for activity in state_attr(entity, 'activity_list') %}
      {%- set name = device_attr(entity, 'name_by_user') or device_attr(entity, 'name') %}
      ### {{ name }} {{ activity }} Harmony Activty ###

      {{ (name ~ ' ' ~ activity) | slugify }}:
        unique_id: harmony-activity-{{ name | slugify }}-{{ activity | slugify }}
        friendly_name: {{ name }} {{ activity }}
        value_template: >
          {% raw %}{{{% endraw %} is_state_attr('{{ entity }}', 'current_activity', '{{ activity }}') {% raw %}}}{% endraw %}
        turn_on:
          service: remote.turn_on
          target:
            entity_id: {{ entity }}
          data:
            activity: {{ activity }}
        turn_off:
          service: remote.turn_on
          target:
            entity_id: {{ entity }}
          data:
            activity: PowerOff
  {% endfor %}

Next, change

{% set entity = 'remote.living_room' %}

to whatever your remote entity is. for example, if it’s remote.lounge_room

{% set entity = 'remote.lounge_room' %}

If you don’t have a switch section in configuration.yaml, copy the entire response from the template editor and paste it into your configuration.yaml.


If you do have a switch section in configuration.yaml, only copy everything after the switch: line.

11 Likes

Fantastic, that got it working as expected. Thank you so much!

Thanks @petro for the custom switches.
The turn-on switch works great, but the turn-off doesn’t work.
What’s the best way to troubleshoot this?

Cheers,
Geoff.

Sorry for my lack of knowledge, I have this same issue and really can not figure out what I am supposed to do.
In my 2 scripts that have this issue, I have the script toggle the switch. I do a toggle because I have a button on a dashboard that serves as a remote. So hit the button once, turns on. Hit it a second time, turns off.

alias: livingroom_roku_power
sequence:

  • service: switch.toggle
    target:
    entity_id: switch.living_room_watch_roku
    data: {}
    mode: single
    icon: mdi:cast

I tried updating the script using Call Service Input Select, but really dont know which to choose. I tired a few of them and then when I click on the Choose Entity, nothing shows as an option.
Do I have to do anything within the Logitech Integration? When I go there, they still show as switches.

Sorry, I am not the most proficient at YAML so I use the visual editor nearly 100% of the time.

This is comical… “We’re removing the switch platform from the Harmony Hub integration”… and the solution is to use a template to CREATE VIRTUAL SWITCHES. This is beyond annoying. So you’re going to remove something that I can select and configure from the UI to something that requires configuration/script manipulation before it can be configured as an entity from the UI?

The solutions provided, other than the one that suggests creating template switches, are not sufficient for using activities as entities. Using the Entity card, Picture Glance card, or any card that allows using an entity as a toggle/switch to create an interaction in the UI is now going to be locked behind script/configuration file changes… Either that or we need to rebuild parts of our setups to use alternate cards and/or methods… brilliant.

I understand this is open source and free software, and I appreciate all of the effort of everyone involved in building such an awesome, central, smart home application. But this is a poor decision on someone’s part, and I haven’t seen any real justification other than “it’s redundant”… does that mean you don’t use RAID in your data backup solution because “it’s redundant”? No… I should hope not.

4 Likes

Thank you.

1 Like

Why are we being advised to use the select entity over the remote entity?

I think I figured out how to use the Select:Select option. But with the Switch option, I had 1 script to toggle the switch on and off. This was the easy way for me to turn the movie on and off. Now with the Select how do I know to Power On vs Power Off? I thought about using an If then and checking the condition of the state of the entity, but that is still the switch entity. So I keep getting the error.

I saw Petro option of the Remote command. But with mine (which might be setup wrong) there is only one option when I choose Remote: Toggle and its just the living room remote. How do I specify the Movie vs Roku that are two activities that I have configured?

Only because it’s easier to use. The remote entity doesn’t have auto completion for commands, where the select has a known list and you can use it pretty much everywhere in the UI.

If your comfortable using the remote vs the select, there’s no reason to swap to the select. I’m still using the remote and I have no plans to change that.

With the Remote option, how do you select the specific activity? I looked at the Remote: Toggle, but I only see the option for the device and/or entity living room remote.
How do I specify the activity Watch Movie vs Watch Roku? I would like 1 script to toggle the power of 1 activity. If I have to break it into multiple, how do I tell if the movie is On or Off? Checking the state only lets me see the switch state, which is again the same original error.

Use the select entity if you don’t know how to call activities from the remote.turn_on service.

The select entity answers all your questions and solves all your problems.

Only 1 activity can be on at a time. It’s the main state of the select entity. If that’s not set to Watch Movie, then the Watch Movie activity is not on.

I guess I missed the updates on this topic.

In my case there are still 15 entries that need to be fixed. Yes it is a simple change…but it take time, and it still takes time…mostly to make sure you don’t break something during the change.

I will have to look at that plugin…

Mic

1 Like

I still do not see the answer to my question:

Read what I wrote a number of days ago

Here is the type of error message I received.

switch.hub_receiver_power is being used in script.theater_mode_off. adjust script.theater_mode_off to fix this issue.

Here is what my script looked like before repair…

theater_mode_off:
  alias: Everything Off
  sequence:
  - service: switch.turn_off
    target:
      entity_id: switch.hub_receiver_power

Here is the fix I did…

theater_mode_off:
  alias: Everything Off
  sequence:
  - service: remote.send_command
    target:
      entity_id: remote.hub
    data:
      num_repeats: 1
      delay_secs: 0.4
      hold_secs: 0
      command: PowerOff
      device: 40278468	

The command and device were found in the harmony_xxx.conf file.

The good news is as I transition away from Harmony…It is easier to understand where and how to put in the commands. (for example IR over IP devices)

Mic