Using time of day as a parameter might be useful for determining the brightness or color of your lights to be used when turning on your lights. Perhaps you want a higher brightness level in the middle of the day, and a softer warmer light in the evening.
This isn’t as straightforward to do in HomeKit as many would want, but by using some logic in a HomeKit shortcut, it doesn’t take many minutes to get done. If you need a more in-depth explanation on how to get started, please check the first Do more with the Hue Dimmer Switch (or any switch) in HomeKit post.
Example 1 (simple)
In this example we’ll use a Hue Dimmer Switch button as the trigger for the shortcut.
Here’s what we want the shortcut to do: If the lights are turned on between 7:00 a.m. and 3:59 p.m., the lights should be set to 100% brightness and use a cooler color temperature. Between 4:00 p.m. and 6:59 a.m., the lights should be set to 60% brightness and a warmer color temperature. The lamp’s name is LeKlint.
The first thing to note is that we need to use the 24-hour time format. So 7:00 a.m. becomes 7:00 and 4:0m p.m. becomes 16:00. These are the only numbers we need to use.
We’ll start with the Format Date action, and choose Current Date. We then need to go to Show More and set the Date Format to None and Time Format to Short. This will give us the current time (hours and minutes) in the 24-hour format. We can then use the action Get numbers from input, and the Formatted Date will be preselected. This will give us the number for the current hour. Next we’ll add an If statement, and when setting the Input we’ll choose Select Magic Variable.
This will give us the ability to select Numbers that is being returned from the Get numbers from Input action.
As condition for the If statement we choose is between, and set the numbers 7 and 16 as parameters.
Now we only need to add the Control Home action twice for the light we want to control, and in the first instance set it to the brightness and color we want between 7:00 a.m. and 3:59 p.m., and in the second instance set it to how we want it for the rest of the day.