Deprecated Harmony entity detected in script.theater_mode_off

Hey Petro, you absolutely made my day! Thank you so much for this solution and your effort.

1 Like

Error loading /config/configuration.yaml: while scanning for the next token
found character ‘%’ that cannot start any token
in “/config/configuration/switches/harmony.yaml”, line 3, column 4

I’m using nested include_dir_merge_list files. Is that not compatible with your code?

configuration.yaml:
switch: !include_dir_merge_list configuration/switches/

configuration/switches/harmony.yaml:

- platform: template
  switches:
  {% set entity = 'remote.harmony' %}
  {%- 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 %}

You didn’t follow my directions. Please read them again.

Hi Petro!

Thanks for the script but I can’t understand that the use of select entities should be easier than the switch integration. I had integrated 4 Harmony actions each as a switch in my dashboard and also integrated them into automations - how I should now map this with the select entity is a mystery to me, I completely lack the approach. I have therefore used your script to create the switches as a template, which works in principle, but now the configuration.yaml has to be filled again where the goal is actually to get away from it and every action of the Harmony is now 2x available, example:

switch.harmony_entertain - Integration: Template
switch.harmony_entertain_2 - Integration: Switch

I can customize the switch created as a template via the GUi, but if I make it available for Alexa, it does not appear in the Alexa App and therefore I can no longer use Alexa for all actions of the Harmony. I cannot manage the second switch via the GUi because it lacks the unique_id.

So at the moment I’m stuck and I can’t replace the configuration that has worked so far… Am I making a mistake here or how do I set the select.entity so that the switches can be replaced?

Regards!
Mike

I’m not sure what you’re doing wrong, but you shouldn’t have duplicate switches. You should only have 1 for each activity. And you should be able to manage the entities for them to appear in Alexa.

Ok, I removed the entries from configuration.yaml and restarted HA - I was able to delete the template switches manually but the other switches are still there and cannot be deleted as they do not have a unique ID. I can only speculate that these are now some remnants of the old switches… How do you delete entities that cannot be edited via the GUi? There are no more entries in the configuration.yaml.

However, as they have a different entity ID, they are not relevant for my actual problem. So I added the script back into configuration.yaml and after restarting I have the 4 template switches again. I can also integrate them in the dashboard and make them available in HA for Alexa, everything is fine but none of the template switches are displayed in the Alexa app…

Nope, these are yaml based entities. They are somewhere in your system. Are you sure you haven’t duplicated your efforts in another area?

Was apparently a cache problem in my browser - after I cleared it, only the template switches are now available - but they don’t appear in the Alexa app even though I have enabled them for Alexa in HA as if templates are not supported by Alexa! I really wouldn’t know where else there could be a mistake as I can use various other devices in HA with Alexa without any problems…
If the entity.select function is really supposed to be easier than the switch function, how can you use it to replace a switch 1:1 in the dashboard and automations? That’s totally unclear to me…

You have to run discovery in alexa if you added these switches.

The discovery function is no longer available in the Alexa app. If I enable a device for Alexa in HA, it is automatically added to the Alexa app via the Home Assistant skill; I have just tested this again with a few devices. Only with the template switches nothing happens - in the HA settings they are displayed as enabled for Alexa but in the app there is no display! :frowning:

Just say “alexa find new devices”.

Also, if you click not sure a bunch after trying to add a device, it attempts to find new devices.

2 Likes

Thank you, it worked via the voice control and the templates are now also available in the Alexa app - they are apparently not automatically recognized via the skill…

Nothing is automatically recognized by Alexa, I’m not sure where you got that idea. Whenever you expose new entities to Alexa, you have to discover them.

When I release an entity for Alexa in HA, I immediately get an info on my iPhone from the Alexa app that this entity is connected to HA via the Alexa skill and can be controlled by voice, I don’t have to trigger a manual search - see screenshot! Only with the templates this automatism did not work! But it doesn’t matter now, problem is solved and good!

Well this must be something new on Amazon side because this behavior is not normal. In the 8+ year’s I’ve been using Alexa with home assistant, it has never automatically discovered devices without being prompted by the user. The above template switches have all the correct home assistant backbone options to make them work with the UI and all UI features, including Alexa.

It’s probably due to the Alexa skill or actually an update that came at some point - I switched from HomeKit and Siri to Home Assistant with Alexa about 14 months ago because I was fed up with the limitations of HomeKit and especially the limitations of Siri and after a few months of work with the setup and dashboard building I released various devices for Alexa which then worked this way… thanks for the input in any case, I wouldn’t have thought of doing a manual search in my life and would have a grumbling wife here why the voice control no longer works… :slight_smile:

You can add your own unique IDs which is what I did so I could then add aliases to them for use with Assist.

Hi,

First of all thanks to Petro for his code!

I have multiple hubs (3) each with their own Harmony_xxx.conf. All my switches made with the template work fine, except the ones for my Shield Pro and Shield TV. Shield Pro in my living room and Shield TV in my bedroom. When I turn them on with the switch they turn on. However, the status does not change to “on”. If I want to disable them (=activity: PowerOff), they do not work. In other words, nothing happens. Switching to another activity such as “Ziggo TV” works fine. Ziggo TV is activated and the switch status changes to ‘on’. Pressing the “Ziggo TV” switch again just turns everything off as it should like all my other switches. I have no idea why my Shield switches don’t do what they’re supposed to do. I never had any problems with the old switches in the integration.

I’ve already tried a few things. Instead of entity_id I used device_id. No result. Additionally, I tried whether codes/numbers (“-1” = “PowerOff”) worked for the activities instead of the activity names. Unfortunately no results for the Shield either.

The only strange thing I discovered in the Harmony_xxx.conf files is that the activities are not called Shield TV, but “SHIELD\u00a0TV” in both config files. Of course I also tried this name in my switch template. Again without any result.

Are there more people who have problems with the Nvidia Shield and use the template switches? Or someone who can help me out?

Part of my switches.yaml:

#############################
##        Switches         ##
#############################


#### Harmony Hub Woonkamer ####
###############################
- platform: template
  switches:    
      ### Harmony Hub Woonkamer SHIELD TV Harmony Activty ###
    harmony_hub_woonkamer_shield_tv:
        unique_id: harmony-activity-harmony_hub_woonkamer-shield_tv
        friendly_name: Harmony Hub Woonkamer SHIELD TV
        value_template: >
          {{ is_state_attr('remote.harmony_hub_woonkamer', 'current_activity', 'SHIELD TV') }}
        turn_on:
          service: remote.turn_on
          target:
            entity_id: remote.harmony_hub_woonkamer
          data:
            activity: SHIELD TV
        turn_off:
          service: remote.turn_on
          target:
            entity_id: remote.harmony_hub_woonkamer
          data:
            activity: PowerOff

- platform: template
  switches:
      ### Harmony Hub Woonkamer Chromecast Denon Harmony Activty ###
    harmony_hub_woonkamer_chromecast_denon:
      unique_id: harmony-activity-harmony_hub_woonkamer-chromecast_denon
      friendly_name: Harmony Hub Woonkamer Chromecast Denon
      value_template: >
        {{ is_state_attr('remote.harmony_hub_woonkamer', 'current_activity', 'Chromecast Denon') }}
      turn_on:
        service: remote.turn_on
        target:
          entity_id: remote.harmony_hub_woonkamer
        data:
          activity: Chromecast Denon
      turn_off:
        service: remote.turn_on
        target:
          entity_id: remote.harmony_hub_woonkamer
        data:
          activity: PowerOff
          
- platform: template
  switches:
      ### Harmony Hub Woonkamer Heos Radio Harmony Activty ###
    harmony_hub_woonkamer_heos_radio:
      unique_id: harmony-activity-harmony_hub_woonkamer-heos_radio
      friendly_name: Harmony Hub Woonkamer Heos Radio
      value_template: >
        {{ is_state_attr('remote.harmony_hub_woonkamer', 'current_activity', 'Heos Radio') }}
      turn_on:
        service: remote.turn_on
        target:
          entity_id: remote.harmony_hub_woonkamer
        data:
          activity: Heos Radio
      turn_off:
        service: remote.turn_on
        target:
          entity_id: remote.harmony_hub_woonkamer
        data:
          activity: PowerOff

- platform: template
  switches:
      ### Harmony Hub Woonkamer Ziggo TV Harmony Activty ###
    harmony_hub_woonkamer_ziggo_tv:
      unique_id: harmony-activity-harmony_hub_woonkamer-ziggo_tv
      friendly_name: Harmony Hub Woonkamer Ziggo TV
      value_template: >
        {{ is_state_attr('remote.harmony_hub_woonkamer', 'current_activity', 'Ziggo TV') }}
      turn_on:
        service: remote.turn_on
        target:
          entity_id: remote.harmony_hub_woonkamer
        data:
          activity: Ziggo TV
      turn_off:
        service: remote.turn_on
        target:
          entity_id: remote.harmony_hub_woonkamer
        data:
          activity: PowerOff

- platform: template
  switches: 
      ### Harmony Hub Woonkamer Netflix Harmony Activty ###
    harmony_hub_woonkamer_netflix:
      unique_id: harmony-activity-harmony_hub_woonkamer-netflix
      friendly_name: Harmony Hub Woonkamer Netflix
      value_template: >
        {{ is_state_attr('remote.harmony_hub_woonkamer', 'current_activity', 'Netflix') }}
      turn_on:
        service: remote.turn_on
        target:
          entity_id: remote.harmony_hub_woonkamer
        data:
          activity: Netflix
      turn_off:
        service: remote.turn_on
        target:
          entity_id: remote.harmony_hub_woonkamer
        data:
          activity: PowerOff


#### Harmony Hub Slaapkamer ####
################################
- platform: template
  switches:
      ### Slaapkamer SHIELD TV Harmony Activty ###
    slaapkamer_shield_tv_sl:
        unique_id: harmony-activity-slaapkamer-shield_tv_sl
        friendly_name: Slaapkamer SHIELD TV SL
        value_template: >
          {{ is_state_attr('remote.slaapkamer', 'current_activity', 'SHIELD TV SL') }}
        turn_on:
          service: remote.turn_on
          target:
            entity_id: remote.slaapkamer
          data:
            activity: SHIELD TV SL
        turn_off:
          service: remote.turn_on
          target:
            entity_id: remote.slaapkamer
          data:
            activity: PowerOff

- platform: template
  switches:
      ### Slaapkamer Tv kijken Harmony Activty ###=
    slaapkamer_tv_kijken:
      unique_id: harmony-activity-slaapkamer-tv_kijken
      friendly_name: Slaapkamer Tv kijken
      value_template: >
        {{ is_state_attr('remote.slaapkamer', 'current_activity', 'Tv kijken') }}
      turn_on:
        service: remote.turn_on
        target:
          entity_id: remote.slaapkamer
        data:
          activity: Tv kijken
      turn_off:
        service: remote.turn_on
        target:
          entity_id: remote.slaapkamer
        data:
          activity: PowerOff

- platform: template
  switches:
      ### Slaapkamer Netfliix Harmony Activty ###
    slaapkamer_netfliix:
      unique_id: harmony-activity-slaapkamer-netfliix
      friendly_name: Slaapkamer Netfliix
      value_template: >
        {{ is_state_attr('remote.slaapkamer', 'current_activity', 'Netfliix') }}
      turn_on:
        service: remote.turn_on
        target:
          entity_id: remote.slaapkamer
        data:
          activity: Netfliix
      turn_off:
        service: remote.turn_on
        target:
          entity_id: remote.slaapkamer
        data:
          activity: PowerOff

the on/off state is controlled by the value_template.

So update that tepmlate to make it work.

Hi Petro,
Thanks for your answer. But unfortunately I don’t understand exactly what you mean. I still lack some knowledge. Can you please tell me what and how to update the template? Thank you in advance!