HomeKit Automation Tips

Getting more out of your smart home devices

Workaround for the HomeKit shortcut bug in iOS 15 / tvOS 15 (with examples)

What is the HomeKit shortcut bug introduced in iOS 15 / tvOS 15?

The latest version of iOS 15 and tvOS 15 (at the time of writing) broke the use of conditionals (if-statements) in HomeKit automation shortcuts when it comes to three different inputs:

  • The brightness level of a light
  • The light level measured by a lux sensor
  • The state of a contact sensor (door or window sensor)

If you use the brightness level of a light, the lux value of a lux sensor, or the state of the contact sensor directly in an if-statement, the shortcut will actually work when you run it by tapping the play button in the right bottom corner on the iPhone or iPad. However, when the shortcut is triggered by something, the if-statement will always get False as the result.

UPDATE: It appears that the bug has been fixed with iOS 15.1 / tvOS 15.1 / HomePod Software Version 15.1.

The fix / workaround

I’m sure that this bug will be fixed in a later update. Until then, if you want your shortcuts to keep working, you need to rewrite a little part of them.

(In case you’re using an adblocker, please consider whitelisting this site. Any revenue from Google ads goes to the costs of running this site.)

Advertisements

Brightness level of a light

In this example HomeKit shortcut is triggered by a button on a Hue Dimmer Switch, but it could be triggered by something else as well. The button toggles the lamp LeKlint between brightness levels 33%, 66% and 100%. If the lamp is off, it is turned on to 33%. If the lamp is on at 100%, it is turned off.

To use the brightness level of a light in an if-statement, you need to start by querying the light using the Get the state of Home action, choose the lamp you are basing the if-statement around, and pick Brightness as the Name of the state you are interested in. It’s important to remember that the Brightness of a light does not tell you whether the lamp is turned on or off. The Brightness can be 100%, while the lamp is off.

We then must use the function Get Numbers from Input, where Brightness from above is the input. At this point we can put this number into a variable, or if it’s a short and simple shortcut, we can use the Magic Variable in the if-statement pointing to this number. In this example I set it to a variable called LampBrightness with the function Set variable.

Then follows the nested if-statements. We start by checking if the lamp is off. If this is true, we turn it on with the brightness level 33% using the Control Home action.

Otherwise (if the lamp is not off), we use another if-statement (nested within the first) to check if the brightness is less than 50, using the LampBrightness variable we created earlier. If this is true, we set the brightness level to 66%.

Otherwise (the brightness level is higher than 50%), we use a third if-statement (nested within the second) where we check if the variable LampBrightness is less than 75. If this is true, we turn the lamp to 100%. Otherwise (the brightness level is higher than 75%), we turn the lamp off. This is followed by the three End If where we close the three nested if-statements.

I think this example is long enough that there is a clear benefit to creating a variable where we store the brightness level of the lamp, instead of the Magic variable.

A screenshot of the shortcut
Advertisements

The light level measured by a lux sensor

In this example we are going to use the lux sensor of the Hue Motion Sensor to check if the light level in the room dark enough to turn on the lights (you can of course use a different light sensor). I’ve set the limit to 100 lux, but you can exchange that to whatever you want. The HomeKit shortcut is triggered by the Hue Motion sensor when motion is detected.

As in the example before, the bug prevents us from using the current light level of the lux sensor directly in an if-statement. We need to start by using the Get the state of Home action, selecting the sensor we want to query and then pick Current Light Level.

We then use the Get Numbers from Input function to turn the result from the last function into a number.

Since this is a very short HomeKit shortcut, we will not create a variable, but instead make use of the Magic Variable.

Using an if-statement, we choose the option Select Magic Variable as the Input and select Numbers from above. As the conditional we pick is less than and as the Number we choose the lux value threshold for when the lights should turn on. I chose 100. If the if-statement is true, we’ll turn the lamp on to 100% with the Control Home action. We can remove Otherwise, and the shortcut ends with End If.

Screenshot of the shortcut

The state of a contact sensor

In this example we are going to use an Eve Door & Window contact sensor to check if door is open when push a button on a Hue Dimmer Switch to turn on the Good Night scene. If the door is open, the Good Night scene will not be triggered, but instead a lamp changes color to red at a 100% brightness level.

As in the examples before, the bug prevents us from using the state of the contact sensor directly in an if-statement. We need to start by using the Get the state of Home action, selecting the sensor we want to query and pick Contact Sensor State.

We then use the Get Text from Input function to turn the result from the last function into a string of text.

Since this is a very short HomeKit shortcut, we will not create a variable, but instead make use of the Magic Variable.

Using an if-statement, we choose the option Select Magic Variable as the Input and select Text from above. As the conditional we pick is, but contains would also work.

Next we use the Control Home action to turn the lamp to 100% and red as a warning that the door is open.

Otherwise (the door is not open), we trigger the Good Night scene with the Control Home action. The shortcut ends with End If.

Screenshot of the shortcut

22 thoughts on “Workaround for the HomeKit shortcut bug in iOS 15 / tvOS 15 (with examples)”

  1. Great. Thanks for confirming this. I was surprised no one else mentioned it anywhere else. I use if statements base on Air Conditioner status as well – that is broken too I can confirm.

    It’s amazing a bug like this can get to a public release…HomeKit was buggy to start with but this is getting borderline ridiculous…

    1. Hi Alan,
      You might be able to work around the AC status with the same technique as I did for the contact sensor in the example (using Get the state of Home combined with Get text from Input).

      And yes, it’s disappointing that this bug wasn’t fixed during the beta period. I know people were reporting this bug to Apple back then.

  2. Stefan, thanks for this. It was driving me nuts how to fix.

    Also I took the idea and used a fake switch in Homebridge to create a heating boost for two hours which I’ve been pondering for ages.

    1. Thank you Neil for your comment. It’s always fun to hear when people find these posts helpful 🙂

      Great idea on the dummy switch for a timed heating boost!

  3. Great hint, thanks a lot! But I don’t find it really easy to do it with my temperature check. When I close the window (opening turns the heating off) I normally check an outdoor temperature sensor to decide whether heating stays off or will be turned on again. Guess I’ll go back to iOS weather data… 🤔

      1. Ah, yes, I hadn’t even thought about testing with a temperature sensor… Good catch! I’ll need to do some testing tomorrow and perhaps add it to the post 🙂 Hope it works for you!

        1. Just modified my automations and leveraged the current weather information. Maybe not as accurate as my on temperature sensor but for my use case sufficient

  4. This bug happened right after updating my iOS devices in september, I was confident that people at Apple would fix an obvious problem: “turn on the lights when the light level is less that 2 lux” does seem what many people do with HomeKit automation, right? But 3 weeks and 2 iOS releases later, I was still wondering around in the dark. Litteraly.
    Then I found your post this morning. Nothing from Apple though. Typical.

    Thanks very much, Stefan.

    1. Thank you so much for this comment, Peter. Getting feedback like this gives me lots of motivation to write more posts 🙂 And yes, I really like Apple, but them not fixing this problem (which was present during the whole beta process) before shipping the golden master version was really disappointing.

  5. It is so annoying that this is not fixed yet. I am on the phone with a Senior Support Engineer from Apple literally right now and it seems they are not aware of this bug. How can this possibly be true? I mean, I have quite a complex smart home setup but this bug also effects everybody with just one light, one sensor and one automation – right? Apple *must* know about this and work on this.

    The senior engineer I have on the phone right now is trying to get answers internally.

    … Moments later…

    This – indeed – seems to be new to the engineering team. The advisor took screenshots and also asked me about the Reddit post and also this very post here. He promised me that the engineers will look into it and that I will get feedback on it.

    1. That’s interesting. I’ve reported it, and I know many more have reported it through the Apple’s feedback channels. One would also think/hope that some Apple engineers would would be using HomeKit with shortcuts 😄

      1. ABSO-fucking-LUTELY!

        It’s even worse with “Deutsche Telekom” and its MagentaTV (television streaming) products. Last year, they introduced new streaming boxes with WiFi Mesh functionality and a totally new form factor. Those products are crap from hell and I bet that not a single Telekom employee in a management (or above) position is using them. I’ve reported so damn many bugs since April this year.

        Back to homekit: I also reported it on September 22 to some German support guy at Apple. He insisted in a 18 minute lasting chat that third party products (like the Hue sensors) where causing the problem and that I should wait until their updates. When I complained in the chat that it could not be true, he simply said goodbye and disconnected the chat.

        1. As everything was working perfectly before the iOS/tvOS 15 update, I can’t think it’s the problem of the third party products. It is of course possible that Apple made some changes in the specs and that all the third party vendors would have needed to update to keep it working, but it’s not something I’ve heard reported. I’m also a bit bummed that the Home app on iOS is so buggy since the update, and when writing longer HomeKit shortcuts, you need to keep jumping out of the shortcut to “save” it in progress, since the Home app just quits on you all the time. I hope Apple will put a little bit more focus on HomeKit in the future, but we’ll have to wait and see.

          1. I run into the same issue with crashing Home App when trying to update shortcuts with the workaround shared in the post. I eventually gave up and disabled all automations that stopped working because of this strange bug. I hope it’s going to improve after 15.1 update scheduled for next week.

      2. Thank you for posting your findings!

        I reported through Apple’s feedback website the same issues on October 17th. I included screenshots from my automations and I linked to this article and several Reddit threads where people report same problems. No response so far. In my case, automations stopped working for Philips Hue and Legrand Netatmo right after OS upgrade so it isn’t specific to a particular vendor.

Leave a Comment

Your email address will not be published.