One more time - Harmony Switch

Hi,

I have spent the last half day reading through various threads on Harmony Switches and I have followed closely some of the “solution” messages, such as here or here and as much as I am convinced that I am following suggestions, I just don’t get it to work :frowning:

I have a ui-lovelace.yaml which call a switch in the switches.yaml:

ui-lovelace.yaml:

icon: mdi:television-classic
    title: Wohnzimmer
    type: horizontal-stack

    cards:
      - type: glance
        name: Fernsehen
        entities:
          - entity: switch.ard_entertain
            name: 'ARD'
            tap_action:
              action: toggle
              service: switch.ard_entertain
          - entity: switch.zdf_entertain
            name: 'ZDF'
            tap_action:
              action: toggle
              service: switch.zdf_entertain

switches.yaml:

platform: template
switches:
  ard_entertain:
    friendly_name: ARD
    value_template: "{{ is_state('remote.hubwohnzimmer', 'current_actvitiy', 'Entertain ARD') }}"
    turn_on:
      service: remote.turn_on
      data:
        entity_id: remote.hubwohnzimmer
        activity: 'Entertain ARD'
    turn_off:
      service: remote.turn_off
      data:
        entity_id: remote.hubwohnzimmer
        activity: 'PowerOff'

  zdf_entertain:
    friendly_name: ZDF
    value_template: "{{ is_state('remote.hubwohnzimmer', 'current_actvitiy', 'Entertain ZDF') }}"
    turn_on:
      service: remote.turn_on
      data:
        entity_id: remote.hubwohnzimmer
        activity: 'Entertain ZDF'
    turn_off:
      service: remote.turn_off
      data:
        entity_id: remote.hubwohnzimmer
        activity: 'PowerOff'

The activities are turned on, but I cannot turn them off - and I have no idea what I am doing wrong - all help appreciated!

THANKS!

you can’t turn them off because you are using the wrong service. You are turning on an activity. The PowerOff activity. Would you use remote.turn_on or remote.turn_off to turn on an activity? The answer is remote.turn_on.

switches:
  ard_entertain:
    friendly_name: ARD
    value_template: "{{ is_state('remote.hubwohnzimmer', 'current_actvitiy', 'Entertain ARD') }}"
    turn_on:
      service: remote.turn_on
      data:
        entity_id: remote.hubwohnzimmer
        activity: 'Entertain ARD'
    turn_off:
      service: remote.turn_on
      data:
        entity_id: remote.hubwohnzimmer
        activity: 'PowerOff'

  zdf_entertain:
    friendly_name: ZDF
    value_template: "{{ is_state('remote.hubwohnzimmer', 'current_actvitiy', 'Entertain ZDF') }}"
    turn_on:
      service: remote.turn_on
      data:
        entity_id: remote.hubwohnzimmer
        activity: 'Entertain ZDF'
    turn_off:
      service: remote.turn_on
      data:
        entity_id: remote.hubwohnzimmer
        activity: 'PowerOff'
1 Like

Intriguing thought which sounds very logical - but it does not work :frowning:

tat was a thought I had before based on a logical approach, so turning off remote-turn_on makes a lot of sense, but still it doe not do what it is asked for :frowning:

I believe you should use is_state_attr instead of Is_state…
Here is sample code working fine for me:

    tvroomtv:
      friendly_name: "TV Room TV"
      value_template: "{{ is_state_attr('remote.tv_room', 'current_activity', 'Watch TV') }}"
      turn_on:
        service: remote.turn_on
        data:
          entity_id: remote.tv_room
          activity: 'Watch TV'
      turn_off:
        service: remote.turn_on
        data:
         entity_id: remote.tv_room
         activity: 'PowerOff'
1 Like

Maybe a word of explanation; is_stae provides on/off status of switch, not what activity is it harmony currently executing. Checking detailed attribute via is_stae_attr gives more info, like activity name. In your code switching on works because current reported status is on or off, so not activity you want to switch to. Switching off does not work, because switch thinks that this activity is not active, so does not execute turn_off part of code… This is my understanding of how it works. Hope will work for you too :slight_smile:

1 Like

That was a very understandable description and answered a question on my side with regards to the difference of both - unfortunately, it does not change anything, still not working :frowning:

post your harmony.conf that is created in your config folder. Also, are you restarting after making the changes? This isn’t a live reload, you need to restart your config.

And lastly, you have a typo for current_activity.

Try this.

switches:
  ard_entertain:
    friendly_name: ARD
    value_template: "{{ is_state_attr('remote.hubwohnzimmer', 'current_activity', 'Entertain ARD') }}"
    turn_on:
      service: remote.turn_on
      data:
        entity_id: remote.hubwohnzimmer
        activity: 'Entertain ARD'
    turn_off:
      service: remote.turn_on
      data:
        entity_id: remote.hubwohnzimmer
        activity: 'PowerOff'

  zdf_entertain:
    friendly_name: ZDF
    value_template: "{{ is_state_attr('remote.hubwohnzimmer', 'current_activity', 'Entertain ZDF') }}"
    turn_on:
      service: remote.turn_on
      data:
        entity_id: remote.hubwohnzimmer
        activity: 'Entertain ZDF'
    turn_off:
      service: remote.turn_on
      data:
        entity_id: remote.hubwohnzimmer
        activity: 'PowerOff'
1 Like

YEEEES - it was the typo … correcting it solved the problem. I have looked so ling at it, that I did not see it … thank you so much.