When I wake up, in the morning light......
OK, showing my age with this title... but us old farts can automate stuff too!
This is a tale of first world woe, with a reasonably happy ending... I hope.
I've bought a house... yay! It's not a new house. It's really 2 or 3 buildings that has grown and merged since sometime in the 1850's, and made from granite - mostly - with some concrete thrown in for good measure. The electrics are, mostly, pre 1970's as the wiring is pre EU standard, but it has had some upgrades.
Basically, It's not the easiest house to automate. Just putting in switches... the walls will kill drill bits and none of the wiring has a neutral.
In the kitchen I have a 90 year old Aga! It's coal fired. Here I am, a person who generally works on the cutting edge of technology and part of my house is still in the steam age! I've only been in the house for 3 weeks, and I hate this thing! Unfortunately, I haven't resolved this issue, but it was the impetus to me doing this automation. Basically, a bad day with the Aga made me think about how I can make my day easier.... even in just a small way.
It started with me using my wakeup alarm. This alarm is set in the Health app (Annoyingly) and I find it not intuitive. Basically, though, you set up your sleep cycle.
You can see that my sleep cycle stops at 7:30am, which is when my Wakeup alarm goes off. Again, annoyingly, you can't tell the Wakeup alarm to use a HomePod (Grrrr).
So, now I can perform a Personal Automation on my wakeup alarm, because it is my phone I can't do a Home Automation. This is breaking one of my rules, which is one place to automate everything.
Open the Shortcuts app, and in the bottom of the screen, you will see "Automation". Select that, and then select the '+' in the top right hand corner of the next screen, then select "Create Personal Automation".
Near the top of the next screen, you will see <Alarm>, select that and then on the next screen select <Is Stopped> and <Wake-up>, Press <Next> at the top of the screen.
location, location, location
You now need to tell the automation what to do when the alarm goes off. In my case, I only want to do something when I'm at home. When I lived in the states, my suburb was good enough, but now I live in a Rural area it is not exact enough, so now I'm using my post code. I need, to start, to know my location. At the bottom of the screen, you will see "Search", tap that and start to type "get current location". You will be directed to another screen and it will show. Select "Get current location".
When you are returned to the last screen, you may note that "Get current location" has a little blue arrow. It is about how precise you wish to be. By default it is 100m. In this case, it is good enough. You can be more, or less precise if you wish. If you wish to change, press the blue arrow and select your desired accuracy.
If......
Now we need to test on the location. We will need an "IF" statement. Again, at the bottom of the screen, search for "if". It will appear under scripting. Select it. Again, it will return you to the previous screen, and you should see that it says "If Current Location". That's not really helpful. I needed to check on post code.
Taping on "Current Location" will show some of the variables. Postcode is now shown, show just push the card up, and you will see it. Select it, and then press the 'X" in the top right hand corner.
Again, you are returned to the previous screen, and you will see that "Current Location" has changed to Postcode. and then in a wishy washy Blue you will see Condition. Tap that and you'll be presented with a number of options.
You can select "is" to be precise, or "contains" to be less exact. I chose contains. It, again, returns you, and now you have a wishy washy blue word saying "Text". This will be part or your whole post code. I like in a small village, and "TR12 6" is enough to identify where I am. (In the UK, a full postcode will pinpoint you to just a few houses). Just tap "Text", and type what ever you need. When finished, press "done" in the virtual keyboard.
Good news! You have now set up your IF statement. If you don't need the "Otherwise", then you can delete it, by pressing the "x" at the end of that line. I'm keeping it as I travel quite a distance and stay overnight for work 2 days a week. I'm not sure what I will use it for, yet, but it does no harm to keep it there.
It's all about Control
We still haven't actually done anything yet. It's about time. I want my bed side light to come on.
Again, in search type "Control"
It'll give you a few options, you will see that I have two homes defined. This is because I actually have admin control of my mother's house as well as my own. So, if you have multiple house, select the one you need. In my case, it is "Control Barclay House". It then drops an action "Set Scenes and Accessories". It drops that outside the IF statement, which is about as much use as a chocolate tea pot! Fear not! You can Drag it up into your IF statement.
Then touch "Scenes and Accessories", and it will show you all the scenes and accessories for the home selected. Next to my bed, I have an Eve Flare, so I am going to select that, and then press <Next> in the top right of the screen. It then shows the Eve Flare, and you can control it in any way you wish. I just switch mine on. Then press <Done>.
I have now programmed my bed site light to come on when I turn off my wakeup alarm.
If that's enough for you, then select <Next>
But, wait.... there's more! I want to turn on the landing light, Hall light and lights in the kitchen diner!
How close to sunrise?
I could do that at the same time as my bed side light. That's great, but only in the winter. What's the point of doing that in the summer?
I need another conditional, which is going to check based on how many minutes it is after sunrise. I'll only turn on those lights if it is less than 30 minutes after sunrise.
Now you need to know when sunrise is.
Obviously it is in "Current Weather", right?
So, at the bottom of the screen.... yep Get Current Weather, and move it up under turning on the light. you can then get sunrise time by getting it from the current weather conditions. you do that by typing "get details of weather conditions". Move that up to under "Get Current Weather". You then touch "Date" which should be in blue, which will take you to a list of details. school up, and you will see "Sunrise Time". Select that, and it will return you to the previous screen.
Brilliant, you now know when sunrise is/was, but you do not know how far from it you are. This introduces a great function.
Once more, in search type "Get time", and you should see "Get Time Between Dates". Select that and, once more, move it up into the IF statement, below getting sunrise time. it should default to being in minutes.
Now we need another "If" statement again. Once more move it up the stack, and it should default to "If Time Between Dates", and you need to add the condition "if less than or equal to 30"
In this case, I got rid of the "otherwise"
now you add what you want to control again. In my case it was a bunch of lights.
Now, I also get it to make me a cup of coffee... but that's going to be part of another blog post.
Press <Next>
You should then make sure the automation is Enabled, and "Ask Before Running" is Disabled... unless you want to be absolutely sure. I also turned off the notification. I know it's running when my bedside light comes on!
Press <Done> in the top right hand corner.
You should be good for getting up in the morning now.
Later, when I have my Lux sensors, I'm actually going to include that as it's really how bright/dim the ambient light is that makes you decide on putting on the lights.
<update 21st Feb 2022>
Do something based on time
I've now turned on the Heater in my study for when I'm working from home. This is based on what time I get up, as my office is over 270 miles (440km) away. I may have to get up early for something, so I used 5am as the cut off point.
So the logic now looks like:
Run when I turn off my wake-up alarm
If my current location has a postcode that contains "TR12 6"
Turn on the bedside light
If time is less than or equal to 30 mins after sunrise
Turn on Landing Light
Turn on Kitchen Light
Turn on Dining Room Light
Turn on Hall Light
EndIf
Make me a coffee (This bit will be another post)
If after 5am
Turn on Heater in Study to Heat to 19C
EndIf
EndIf
So, how did I do the last bit?
Well, as usual, go to search and say "Get Date", and on the next screen you will see that as an option. When that is added to the bottom of you scripts, then search for "Format Date". That is also added to the bottom of the script.
You will note there is a little blue arrow, press that, and you will see a drop down menu. click on "Short" on the same line as Date Format, and then select "Custom". You will be returned to the previous screen and you will see quite a long string next to Format String. Delete all of that and replace with "Hmm", and press <Done>. This is case sensitive, and you use only a single H, which represents the hour in the 24 hour clock (2pm is 14). The double lowercase mm means minutes, but when you only have a single digit, it will pad out with a 0. Thus 1 minutes past 2pm, will show as 1401, or 5am will be 500.
We have the time in text, but we need a number.
In Search type "Get Numbers from Input", and select it to be added to the bottom of your script, and it should automatically show it with "Formatted Date".
Now we need to see if the number is greater than my desired time of 5am, or what is now expressed at 500.
Add an If statement, and it will show as "If Numbers Condition". Delete the "Otherwise"., and tap on Condition and select "is greater than or equal to". You are returned to the previous screen, tap on "Number", type in 500 and <Done>
We need to add what we want to do, which is to turn on the Heater and to 19C.
Search down the bottom for Control and, if you have multiple homes, select the correct Home, just like further up in the script. You re now returned to the previous screen and you tap on "Scenes and Accessories", Select the Accessory you which to control, tap <Next>. In my case it shows teh Heater as being off, so I changed it to be on, and selected a temperature. where it then returned me again to the selected Accessory, just with its status changed, and then click on <Done>
Then Drag up the "Set Study Heater" to above the EndIf statement, so that it is inside the conditional IF of being 5am or later.
That whole segment is outside the test on the post code. If you look up, there is another EndIf. Drag that down to the bottom of the script.
And now the Script is complete.
Comments
Post a Comment