Help with "send command" script for Harmony Hub

I am trying to get a switch to activate a script that will send a command to turn on my fan.

Here’s what I have:

- platform: template
  switches:
    fan:
      value_template: "{{ is_state('script.fan_on', 'on')}}"
      turn_on:
        service: script.turn_on
        entity_id: script.fan_on
      turn_off:
        service: script.turn_on
        entity_id: script.fan_off

Script

  fan_on:
    sequence:
    - service: remote.send_command
      entity_id: remote.living_room
      data:
        device: "42546817"
        command: "PowerToggle"

  fan_off:
    sequence:
    - service: remote.send_command
      entity_id: remote.living_room
      data:
        device: "42546817"
        command: "PowerToggle"

The above does not work. I copied the above from this post.

Any help would be greatly appreciated!

It should work. I’d delete the Harmony config file, restart HA and check it again to make sure the device number in case it changed.

1 Like

That did the trick! Thanks!

@junior466 In case you’re interested, here’s a better way of using a fan to control the speed and know the on/off state. It’s not bullet proof but works better imo

@Jer78 That’s great but the thing is I need a switch because I am using it through HADashboard, not the Home Assistant frontend.

Can you help me at this post? Switch that holds its own state