Use Alexa, Apilio, Kasa, and IFTTT to save money each night!

[Disclaimer] This is my first post, apologizes for formatting issues/typos

Want to set up an automation system that requires no effort to save money every night?! You wouldn’t have clicked on this link if the answer is no. :innocent:

This automation system will:

  1. Turn the AC on when you go to sleep (colder temps = better sleep).
  2. After a specified time it will turn the AC off while you’re sleeping (@ 1am for me).
  3. Finally, it will turn the AC back on at another specified time (@ 6am for me).
    The last step checks if you’re home before turns AC back on

Materials

  • Alexa
  • AC unit that can communicate w/IFTTT (Mine is connected to a Kasa smartplug)
  • Time to set this up

------Setup a boolean variable which tells Apilio if you’re awake or not
Annotation 2020-06-10 120407

---------Link Alexa trigger to toggle Apilio awake state when going to sleep
Go to IFTTT and create an Alexa trigger for a specific phrase
Annotation 2020-06-10 115109
Annotation 2020-06-10 115109

The given phrase doesn’t matter as you will override it later. (You’ll see)
Annotation 2020-06-10 115427

Now we create the IFTTT action which links to Apilio and updates sleep state
Annotation 2020-06-10 115919
Annotation 2020-06-10 115946

The variable “awake_ongoing” is going to be false when I’m sleeping
Annotation 2020-06-10 120056

Here’s the logic, but know that what you say to Alexa to trigger the routine can still be changed

Creating the Alexa routine to turn on AC when sleeping and to update Apilio sleep state variable


[Important] What you put here in the “When you say” section is what will cause everything else to run.

[Note] My AC is connected to a Kasa smartplug which in turn is connected to my Alexa.

Simple Alexa routine to turn off AC at a specified time (1am)

Now we need to create a time variable in Apilio and I do that by combining it with IFTTT.
Since Apilio has no time variables I will use a boolean value to check if it is a certain time or not
Annotation 2020-06-10 122806

Setting up the IFTTT trigger
Annotation 2020-06-10 122915

Updating our time variable to true in Apilio
Annotation 2020-06-10 123043
Annotation 2020-06-10 123137

Heres the logic

Now we will have to reset the time variable as after 1 minute the time variable “time_6am” will no longer be true.

To do that we must create an Apilio condition that will check the value of our time variable
Annotation 2020-06-10 123559

Now we create a logic block to reset our time variable back to true!
[Important] I wait 2 minutes before resetting to account for any processes that might update slow

When the time variable gets updated to true, it will reset back to false after 2 minutes



Annotation 2020-06-10 124540

We must create the IFTTT action to update Apilio time variable to false

This is from the Apilio logicblock
Annotation 2020-06-10 124838
Annotation 2020-06-10 124959

Annotation 2020-06-10 125029

Heres the logic, remember that this will happen 2 minutes after IFTTT update time variable at 6am

Need a way for Apilio to tell if we’re currently home so that it only turns the AC if someone is present.

First we need Apilio location variable which IFTTT can update

IFTTT location trigger


Annotation 2020-06-10 125636
— Being home is a boolean so it’s easier to chose the toggle option here

Enter your home location

Have Apilio update location variable
Annotation 2020-06-10 125826

Heres the logic

Now we can finally set up our final logicblock that will check if we are home and if it’s 6am. If both are true, IFTTT will tell Kasa to turn the AC on



Annotation 2020-06-10 130405

Last IFTTT trigger (previous picture)


Annotation 2020-06-10 130558

kasa will turn the AC on if home + 6am
Annotation 2020-06-10 130642
Annotation 2020-06-10 130724
Annotation 2020-06-10 130754

Final logic

In order to prevent an error you must also reset your Apilio awake status variable to true when waking. (Similair to how you must reset the 6am time variable back to false)

The way I do this is with a Siri shortcut automation that runs when my morning alarm goes off and will send a webhook to IFTTT which in turn, triggers the Apilio awake status back to true
— This is an important step that I am showing so please let me know if you need further help

THAT IS ALL

[Discussion] I understand that there are a lot of moving parts and again this is my first time trying to explain my workflows so forgive me if you are confused.

What’s important to know with this method is that there are very few things that MUST happen for this to work.
— I must have my phone with me connected to the internet and at home (no effort)
— I must tell Alexa that I am going to sleep by saying my selected phrase (“Alexa, sleep time.”)
— I must stop my phone alarm when waking (no effort)

Truly other than those 3 actions above, you will not have to do anything else and you will still get cold air upon sleeping/waking, but you wont be wasting money having your AC run all night as you used Apilio to automate that process for you!!!

3 Likes

Wow Jon, that’s going to help a LOT of people, great effort and thanks for taking the time to post such a comprehensive guide! DanT

1 Like