Please help with a dummy switch!

I have read through the forums, and I see that many similar requests have resulted in suggestions of a boolean rather than a switch. However, I think I really do need a switch template here…

I am trying to create a switch that really does nothing in HA, but allows me to turn it on. If possible, I’d like it to turn off by itself. The goal is to have it appear as a switch in HomeKit so I can use it to trigger a HomeKit scene. Can anyone help this dummy with the code for a dummy switch? Thanks in advance!!

1 Like

Not sure I’m fully following that, but how about something like:

input_boolean:
  dummy_switch:
switch:
  - platform: template
    switches:
      dummy:
        value_template: "{{ is_state('input_boolean.dummy_switch', 'on') }}"
        turn_on:
          - service: input_boolean.turn_on
            entity_id: input_boolean.dummy_switch
          - service: input_boolean.turn_off
            entity_id: input_boolean.dummy_switch
        turn_off:
          - service: input_boolean.turn_off
            entity_id: input_boolean.dummy_switch

I tried it and it seems to work. When I turn on the switch in the frontend it goes on and goes right back off.

1 Like

@pnbruckner - Thanks so much for responding! Sorry if my request was confusing. I think maybe I just don’t really understand how input_boolean works. I didn’t realize I would need that combined with a switch.

I tried this out, and it works most of the time. But I am wondering if the instant switch turn-off is happening before HomeKit even realizes it needs to fire a trigger. Is there an easy way to set a timer so that the switch stays on for a second or two before turning off?

If you’re trying to understand the bigger picture, here is what I am trying to do. It is very convoluted, but my proof of concept does work. I have a Harmony universal remote, which has dedicated Home Control buttons on it. My goal is to configure the Home Control buttons on the Harmony remote to start HomeKit scenes, such as “Movie Night.” The Home Control buttons can be used to turn on smart lights such as Hue bulbs or Lutron Caseta switches. However, it cannot natively be used to trigger HomeKit scenes.

There is a Home Assistant Emulated Hue component that the Harmony can see. If I create a dummy switch and expose it to both HomeKit and Emulated Hue, I can assign one of the Harmony Home Control buttons to turn on that switch. Then within HomeKit, I can create a trigger that fires when that switch is turned on.

Wowsers, that is a huge road for such a simple task :stuck_out_tongue:. Trying to think with you on this, wouldn’t it be easier to create scenes in HA and use that instead as harmony is supported within HA right?

For example you could make the scene similar (if not exactly) the same as the homekit variant. You wouldn’t notice the difference but it will work guaranteed without having to worry about entities loaded before homekit starts. You could even expose the HA scenes to homekit (though they will appear as buttons if I’m correct). The upside of this is it will be stable and if Homekit would hang for whatever reason, your Harmony could still activate the scenes (because they aren’t the Homekit scenes). However the downside is that if you change a scene in Homekit, you would have to do this to the HA scene as well.

Probably not ideal but it is an option that I have used in the past (as I had too much trouble with Homekit due to not loaded entities after updates etc. which messes up Homekit. And that isn’t cool if you got over 75 devices/switches/lights/sensors etc).

Just add a delay (which is in seconds):

        turn_on:
          - service: input_boolean.turn_on
            entity_id: input_boolean.dummy_switch
          - delay: 5
          - service: input_boolean.turn_off
            entity_id: input_boolean.dummy_switch

I don’t have any of those types of devices, so I’m not following. But if you’re happy, I’m happy. :wink:

try this

@jimz011 - Yes, you are 100% correct! This is probably too much unneeded hackery! But I really have an Apple/HomeKit house, and I want to try my hardest to get this to work. Your suggestion is a good one. Probably better than what I’m doing. But I don’t want to recreate my scenes. Plus, I have a ton of devices and don’t have the majority of them HA. I’m really just using HA to add non-HomeKit compatible devices into HomeKit.

@lonebaggie and @pnbruckner - Thank you both very much for your help! I ended up using a combination of your ideas, and came up with a light switch that turns itself off after 5 seconds. See below. The only issue I found is that sometimes HomeKit doesn’t recognize when it turns itself off, so I also created an action in HomeKit that turns the “lights” off after they are turned on. So far, it is working perfectly. Thanks again for your help!

light:
  - platform: template
    lights:
      harmony_virtual_movie_night:
        friendly_name: "Emulated Hue Movie Night"
        turn_on:
          - delay: 5    # 5 seconds
          - service: light.turn_off
            entity_id: light.harmony_virtual_movie_night
        turn_off:
        set_level:
3 Likes

thank you, using this for pretty much the same thing but with my AC unit.