Nest Thermostat, Occupancy Tracking

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

  1. Android Phone
    1. MacroDroid App Installed
  2. Nest Thermostat
  3. IFTTT Account (Must be Pro as this takes more than the 3 apps allowed in Standard).
    1. Nest account linked to IFTTT
    2. Google account linked to IFTTT
    3. Maker Webhooks account linked to IFTTT

Step 1: Create a New Google Sheet ("Make a Copy" of My Shared Spreadsheet to Your Google Drive)

  1. Copy my shared Occupancy Tracking google sheet:
    1. Shift + Click this link to open in another tab.
    2. Click File
    3. Click "Make a copy"
    4. Save in your google drive.
    5. 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

  1. clicking on the share button
  2. 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

    1. Using a web browser, navigate to https://ifttt.com/maker_webhooks/settings
    2. Copy the text from the "URL" field on the displayed page into your paste buffer
    3. Paste that url into the browsers address bar
    4. This page should show you how to use the webhooks we just created.
    5. The structure of the URL will look like this:
      1. "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.

    1. Click add Macro
    2. Enter the Macro name for the event you are creating. I used the following names
      1. Person1LeavesSmall
      2. Person1ArrivesSmall
      3. Person1LeavesLarge
      4. Person1ArrivesLarge
    3. Click on the plus in the upper right corner of triggers
    4. Click on "Location"
    5. Click on "Geofence Trigger"
    6. Choose either "Area Entered" or "Area Exited" depending on the event you are creating.
    7. Check "Trigger if previous location unknown"
    8. 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
    9. Click "ok"
    10. Select the previously created geofence for this event
    11. Click on the plus in the upper right corner of "Actions"
    12. Click on "Applications"
    13. Click on "Open Website / HTTP GET"
    14. 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.
    15. Check the box for "HTTP GET"
    16. Click OK
      1. 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.
    17. Click the Left arrow next to your Macro name
    18. 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

    1. Open the Google spreadsheet using a browser.
    2. Click the file menu.
    3. Click "Spreadsheet settings".
    4. Click the "Calculation" tab
    5. Change the "Recalculation" drop down to "On change and every minute".
    6. 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.

    1. Login to IFTTT.com
    2. Click the create menu
    3. Click on the "If this" button
    4. Search for Sheets
    5. Click on "Google Sheets"
    6. Click on "Cell updated in spreadsheet"
    7. Do one of the following:
      1. Enter the folder path and Filename of the spreadsheet
        or
      2. Copy and paste the spreadsheet URL into "Or copy and paste the spreadsheet URL"
    8. 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)
    9. Click the "Create Trigger" button.
    10. Click the "Then That" button.
    11. Search for "Nest Thermostat"
    12. Click "Nest Thermostat"
    13. Click "Set Temperature".
    14. Select your thermostat from the ""Which Device" section dropdown.
    15. In the "Temperature" section, enter "{{Value}}". Quotes not needed.
    16. In the "Degrees in" section, select either "Fahrenheit" or "Celsius", depending on the values you used in the spreadsheet.
    17. Click the "Create Action" button.
    18. Click the "Continue button".
    19. 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".

    Be the First to Share

      Recommendations

      • Anything Goes Contest 2021

        Anything Goes Contest 2021
      • One Board Contest

        One Board Contest
      • Raspberry Pi Contest

        Raspberry Pi Contest

      Comments