Apple Scripts

A dog timer Shortcut

Shortcuts User Guide - Apple Support

I’ve played with the Shortcuts app a few times and although their power is impressive, I haven’t found a need for any in my day-to-day workflow. This Shortcut may finally change that.

Here’s the problem

Our dog literally can’t handle the heat. She’s a Miniature Schnauzer born with a microtrachea so she struggles to regulate her body temperature. If she gets overheated it’s bad news.

I typically let her out multiple times a day while working from home. All I have to do is open up our back door, let her out into her fenced doggie area, and let her back in when it’s time.

That last item is trickier than it sounds – if I don’t set a timer I risk getting into the zone at work and losing track of the world. That could be disastrous, so up until now I’ve set a timer and altered the duration depending on the temperature outside. I wondered if I could improve that with a Shortcut.


Build a Shortcut to:

  1. Fetch the outside temperature
  2. Set (or don’t set) a timer of varying duration depending on how hot it is

Timer algorithm

  • Temp <= 75°F: She can stay out for 25 minutes
  • 75°F > Temp <= 85°F: Map this range from 25 minutes to 1 minute
  • Temp > 85°F: She shouldn’t go out right now

These undoubtedly will get tweaked in the future.

Here’s the Shortcuts solution:

Screenshot of the Shortcut defining the algorithm.
Code reviews welcomed
Screenshot of the timer created by the Shortcut.

A programmer’s perspective

There’s a great chance I’m missing something simple to improve the “code”, but if it works it works. I don’t think we’ll need to focus on DRY principles or unit tests any time soon. 😀

Arguably the most powerful line is the first one – magic happens and tada 🪄 the weather is provided for any place you choose. That’s pretty cool!

Some gripes:

  • Why can’t I set the Time variable to a parsed number directly Maybe there’s a better way I haven’t explored.
  • As you can see in the screenshot, this Shortcut isn’t supported on macOS because there’s no “Start Timer”. Why not? The shortcut runs fine on iOS / iPadOS.