Create an On/Off Toggle Switch With Home and Shortcuts

Apple’s Home is my go-to app for control of my HomeKit devices, and generally, for basic automations and scenes, it’s also my preferred option. It does have a few limitations, for which many 3rd party HomeKit apps help fill in the gaps, but I just like the layout and the ease of use. That said, one really seemingly simple feature does seem to have alluded Home, which is a simple toggle feature. Currently, you can program a smart switch to turn something on, but you can’t program it to turn on when it’s off and off when it’s on, which for a traditional switch is a fundamental function. Why this hasn’t been created is anyone’s guess, and in fact, the Mi Home app is already capable of such a task. It is achievable via third-party apps, using conditions, but it’d be really nice to do it all in one place. Thankfully, with Shortcuts integration into the Home app this is now a possibility, although it’s still not as easy as it is in the aforementioned Mi Home app, but still.

For this example, I’m going to use two Vocolinc L2 (tunable white) smart bulbs, that have been grouped under the name ‘Prayer Lights’ (don’t ask…), and an Aqara Double Rocker Switch. I’ve also set up two scenes that I’ll be using in this automation – Prayer Lights ON and Prayer Lights OFF.

The overview of this automation is actually very simple, but I’ve gone into it step-by-step, so you can easily create this automation yourself. The automation works like this;

  1. When the rocker switch is pressed…
  2. IF the Prayer Lights are OFF, then turn them ON
  3. otherwise, turn the Prayer Lights OFF.

So it’s essentially checking the status of the lights connected to the switch and turn them off or on, depending on the state they are in.

THE AUTOMATION

  • Long-press the rocker switch* tile to get to the settings page
  • In the settings page, you will see your buttons, waiting for a scene or device added to them
  • Click Add, then instead of selecting a device or scene, scroll to the bottom and select ‘Convert to Shortcut’

* In this case, this double rocker switch is the older type, so it doesn’t have double or long-press options, merely single press.

  • You will then see the Shortcut screen with ‘set – scenes and accessories’ by default
  • Click on the + icon, and select ‘scripting’, then ‘If’ (If might be a ready selectable option).
  • You then need to reorder these tiles so that the Scripting tile is above the current Set tile
  • In the Scripting tile, press ‘Input’ then choose ‘Select a Home Accessory’ from the pop-up menu.
  • Your list of accessories will appear, so in this case, I’m selecting the Prayer Lights I initially mentioned.
  • As Prayer Lights is actually two bulbs, it just shows one of the bulbs for this automation, which is ok
  • Next, select ‘Name’, and select ‘Is off’ **

** in the case of these bulbs there are more options than normal, that reference special light effects in Vocolinc’s LinkWise app

  • Select the Set tile and drag it up, so that it’s below the If tile
  • Click on Scenes and Accessories
  • Select the scene created for these lights – in this case, Prayer Lights ON. Click Next

The first part of your automation is now set, which is simply – IF Prayer Lights are OFF, set Prayer Lights ON. Now to the second part.

  • Click on the + icon again
  • Select Control New Taipei (this is the name of my HomeKit Home, so whatever the name of your Home is will appear here)
  • Another tile is created. Click on Set – Scenes and Accessories once again
  • Your scenes and accessories will show up, so in my case, I’m choosing Prayer Lights OFF, having chosen Prayer Lights ON previously
  • I now need to move this tile up so that it’s below the Otherwise tile
  • The complete automation is in place which is;
    1. When I press the Aqara Rocker Switch
    2. If Prayer Lights (Vocolinc L2 2) is off
    3. Set (Scene) – Prayer Light ON
    4. Otherwise Set (scene) – Prayer Lights OFF
    5. End If (meaning automation has completed)
  • Click Next, then click Done to save your automation.

That’s it. Whilst it may seem complex due to my step by step instructions, it should literally take you a minute to create this automation, if not less. It definitely helps to create a couple of scenes (if you can spare them, with the current 100 scene limit) that have the lights off and on, but it’s not necessary. It’s important to note that in some cases, whilst you may be controlling a set of lights (grouped in Home) when it comes to the automation checking the status of them to determine whether to turn them on or off, it only needs to check one bulb in the group, so it’s good practice to make sure that same bulb is chosen as the designated bulb in all automations for the most part.

Big thanks to Mariusz Szwed for help in figuring this all out!

Simon

Editor - Musician, graphic designer and HomeKit aficionado.

4 thoughts on “Create an On/Off Toggle Switch With Home and Shortcuts

  • 5th February 2020 at 12:25 pm
    Permalink

    I like this idea and concept. I can have the Script Automation setup for a Button or in Automations and hit the Test this button or the Play in the Shortcut and it works great!

    Though once I add it to the button or have a button trigger an automation, I can see the button flash as I pressed it, nothing. I can assign a simple light, press, works. Create the shortcut, press test, works, press the button, no work. I tried a few buttons, switches, automations, nothing that triggers it Automatically without pressing something on Homekit wont make it work. Even in HomeKit turning on the Automation trigger entry does not run the script.

    If its On, it wont turn it off, if its off it wont turn it on. Since the script works in the test I know the Logic in it is fine.

    Testing and congrats with IPad Pro, 12” 13.3, Apple TV3 as Home Hub, running latest TVOS.

    Any Suggestions?

    Reply
    • 5th February 2020 at 12:30 pm
      Permalink

      Hi Scott, have you updated to 13.3.1 for both iPad and Apple TV? This method was broken when 13.3 came out but it’s working (for me) in 13.3.1.

      Reply
      • 23rd February 2020 at 7:09 pm
        Permalink

        Hi Simon,

        I’m relatively new to the smart home automation scene. Just last month I got myself a couple of Aqara devices like the switches, turnable bulbs and sensors together with the Xiaomi Gateway v2. I came across your site while searching for reviews on aqara devices.

        Your article on this page mentioned about setting up conditions via third-party apps, on top of the official Mi Home app. Can you help to pinpoint me to these third party apps? The Mi Home app indeed has its own limitations and I’m trying to find ways to work around it. Thanks in advance for your help.

        Reply
        • 23rd February 2020 at 8:26 pm
          Permalink

          Hi. When I mention 3rd party apps, it’s in relation to 3rd party HomeKit apps only, not 3rd party apps for Mi Home products, if that’s what you mean. Eve for HomeKit app is one such app, as well as Controller for HomeKit.

          If you need help with Mi Home, just let me know what I can help with and I’ll try my best.

          Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.