Introduction: Nest Thermostat, Occupancy Tracking
My home cooling automation using my Nest Thermostat had, until recently, been run by IFTTT using Life360's "first to arrive at home" and "last to leave home" triggers. This was great because I could add family members into my Life360 circle and if they were the first to arrive into the geo-fence for home, IFTTT would trigger the Nest Thermostat to set the right temperature. Additionally, when the last person left that same geo-fence it would set the Nest thermostat to the ECO Temperature.
The problem came at the beginning of December 2020 when Life360 announced the end of IFTTT Integration:
Email Sent By IFTTT:
"Hello,
On December 2, 2020, the Life360 service will be removed from IFTTT because the Life360 team no longer supports the service.
For alternative services, take a look at other smart hub & systems services on IFTTT.
We appreciate your understanding."
I did some research and there are several products that do geo-fencing and others that track home occupancy but they all charged fees or were overly complex for my needs.
I settled on a solution that combines an app called MacroDriod (only runs on Android phones), IFTTT Maker Webhooks and Google Sheets to maintain the occupancy state of my home.
Supplies
- Android Phone
- MacroDroid App Installed
- Nest Thermostat
- IFTTT Account (Must be Pro as this takes more than the 3 apps allowed in Standard).
- Nest account linked to IFTTT
- Google account linked to IFTTT
- Maker Webhooks account linked to IFTTT
Step 1: Create a New Google Sheet ("Make a Copy" of My Shared Spreadsheet to Your Google Drive)
- Copy my shared Occupancy Tracking google sheet:
- Shift + Click this link to open in another tab.
- Click File
- Click "Make a copy"
- Save in your google drive.
- Make note of the file name and directory that you store it in.
For the purposes of this Instructable, we will assume the IFTTT directory and the file will be named "Occupancy Tracking". Note you might want to give it a nice obfuscated name to help it be more secure.
P.S: Do not ask me to give you the permission to edit this file. Before you make any changes, which you will not be able to make because I shared this as a read only spreadsheet, do a "make a copy" in your own google drive and then proceed with making edits.
Step 2: Security
Speaking of security, take a moment and assure that the sheet you have copied is private to only you. This can be done by opening your copied spreadsheet and hovering over the share button. it should look like the first image above.
If it does not, click the share button and change to "restricted" by
- clicking on the share button
- changing it to restricted. (should look like the second image above)
Reasoning: We don't want people to know when your family is not home.
Step 3: Update Your Spreadsheet With Tracked Family Members
The spreadsheet comes with two members to track, Person1 and Person2. These names are stored in the spreadsheet in cells B2 and B3. If you wish (not required) you can update these names to the names of the individuals you want to track..
Step 4: Add or Remove Family Members
If needed, you can add or remove family members from the spreadsheet. I have left room to do this in rows 4-6.
- To add additional family members; simply copy row 2 or 3 and paste into row 4, 5 or 6.
- To remove family members simply delete the contents of the row.
Note: Do not delete all family members or you will lose the formulas stored in column E. Also, the more people you have added, the more IFTTT Webhooks you will need to create.
Step 5: Disabling Family Members
Column D of the spreadsheet is used to either enable or disable family members. For example: let's say that you and your spouse are the only family members being tracked, but your spouse is away visiting family in another State. You would not want your AC to stay on when you left home, so you can disable your spouse from consideration by changing column D for them to "No". By doing this, your spouse's arrival home or departure will not affect the Nest Thermostat temperature.
Step 6: Set Your Desired Temperatures
- Cell G2 controls the desired temperature when "The First person arrives home". Set this value to the desired temperature when people are home.
- Cell H2 controls the desired temperature when "The Last person leaves home". Set this value to the desired temperature when no one is home.
Some Examples:
- If you live in Hawaii and want the temperature to be 75 when you are home and the max temperature to be 85 when you are away, you would set G2 to 75 and H2 to 85.
- If you live in Seattle and it is winter, you might set H2 to 70 and G2 to 65. This would give you a temperature of 70 while at home and allow the house to drop to 65 when not home.
Step 7: Create Two Geo-fences in Macrodroid
If you have not already done so, install the Macrodroid App from the Google Play Store. Be sure to install on the smart phone of each family member being tracked.
Open Macrodroid and click on Geofences
I create two concentric geofences centered on my home and named them "HomeSmall" and "HomeLarge".
The smaller one I like to keep at about 100 meters. The larger should be made as large as the distance it takes, on the average, for your house to cool or heat by the time you arrive.
Step 8: Create IFTTT Maker Webhooks for Entering and Exiting Each Geofence
A. Log onto https://ifttt.com.
B. Click the "Create" menu pick
C. Search for webhooks and click on the service.
D. Only one choice for a trigger will be available, click on it.
E. Enter a name for the event, in this case I used Person1Arrives; however, this can be named whatever you like.
e.g. Person1Arrives and Person1Leaves
F. Click create trigger:
G. Click the "then that" button
H. Search for and click on "sheets"
I. Click on "Update cell in spreadsheet"
J. In the "Drive folder path" section empty it out (defaults to the IFTTT folder on your google drive) or put in the full path to your spreadsheet.
K. In the "Spreadsheet name" section put the name of your spreadsheet. In my case it is "Occupancy Tracking" (Quotes not needed)
L. In the "Which cell?" section, put the cell in column C where the person entering or leaving the zone's "HOME" or "AWAY" status will be stored. e.g. In my original spreadsheet for person1, the cell required is C2.
M. In the "Value" Section, in all caps put either "HOME" or "AWAY" (quotes not needed). Which one you choose depends on if you are creating a Webhook for leaving or entering a geo-fence.
N. Click "Create Action".
O. Click "Continue"
P. Click Finish
Loop back through the steps above (A through P) for each person in your family that is being tracked. You should end up with an "Arrives" and "Leaves" event for each person.
Step 9: Gather Information About Your Maker Event URLs
- Using a web browser, navigate to https://ifttt.com/maker_webhooks/settings
- Copy the text from the "URL" field on the displayed page into your paste buffer
- Paste that url into the browsers address bar
- This page should show you how to use the webhooks we just created.
- The structure of the URL will look like this:
"https://maker.ifttt.com/trigger/{myEvent}/with/key/{myKey}
e.g. "https://maker.ifttt.com/trigger/Person1Leaves/with/key/ %*&(*(%$$*"
Make note of this as you will use this in the next step.
Step 10: Create Macros in Macrodroid for Each Event for Each Person
Open Macrodroid on the phone of the person you want to be tracked.
- Click add Macro
- Enter the Macro name for the event you are creating. I used the following names
- Person1LeavesSmall
- Person1ArrivesSmall
- Person1LeavesLarge
- Person1ArrivesLarge
- Click on the plus in the upper right corner of triggers
- Click on "Location"
- Click on "Geofence Trigger"
- Choose either "Area Entered" or "Area Exited" depending on the event you are creating.
- Check "Trigger if previous location unknown"
- Consider changing "Location update rate" to a lower number. Note, this will have an effect on the battery usage as noted on the Macrodroid screen
- Click "ok"
- Select the previously created geofence for this event
- Click on the plus in the upper right corner of "Actions"
- Click on "Applications"
- Click on "Open Website / HTTP GET"
- Paste the appropriate Webhook URL from "Step 11" from previous section in the "Enter URL" Field. Make sure to use the correct event name, IE Person1Leaves.
- Check the box for "HTTP GET"
- Click OK
- At this point, it is a good idea to test the action and validate the effect on your spreadsheet. This can be done by single tapping the action and clicking test action. It should update the appropriate cell in your spreadsheet to either "HOME" or "AWAY" depending on the event you are working with.
- Click the Left arrow next to your Macro name
- Click Save
Do step 1-18 in this section on each tracked family member's phone. Four Macros will be created on each tracked family member's phone. (Example Macro names are above in step 2)
Step 11: Modify "Recalculation" Spreadsheet Setting
- Open the Google spreadsheet using a browser.
- Click the file menu.
- Click "Spreadsheet settings".
- Click the "Calculation" tab
- Change the "Recalculation" drop down to "On change and every minute".
- Click the "Save Settings" button.
Step 12: Create an IFTTT Applet That Connects the Nest Thermostat to the Spreadsheet
The final step is to create an IFTTT Applet that links the change event of the spreadsheet for the "Nest Temperature" cell to the Nest thermostat.
- Login to IFTTT.com
- Click the create menu
- Click on the "If this" button
- Search for Sheets
- Click on "Google Sheets"
- Click on "Cell updated in spreadsheet"
- Do one of the following:
- Enter the folder path and Filename of the spreadsheet
or - Copy and paste the spreadsheet URL into "Or copy and paste the spreadsheet URL"
- Enter the folder path and Filename of the spreadsheet
- In the "Which cell to Monitor" section, put the cell that represents "Nest Temperature".(In my original spreadsheet, this is cell "E7", quotes not needed)
- Click the "Create Trigger" button.
- Click the "Then That" button.
- Search for "Nest Thermostat"
- Click "Nest Thermostat"
- Click "Set Temperature".
- Select your thermostat from the ""Which Device" section dropdown.
- In the "Temperature" section, enter "{{Value}}". Quotes not needed.
- In the "Degrees in" section, select either "Fahrenheit" or "Celsius", depending on the values you used in the spreadsheet.
- Click the "Create Action" button.
- Click the "Continue button".
- Click the "Finish" button.
Congratulations, if all went well you have just established a way to control your thermostat when "The first person arrives home'" or the "Last person leaves home".