[HOW TO] SmartThings Presence reporting using AutoMagic/SharpTools

android
project_presence

(Scott H) #1

tldr; When my WiFi connects, OR when I’m within 120m of my home, I set myself as “present”. When my WiFi is disconnected AND I’m more than 400m from home, I set myself as “not present”.


If you’re interested in Presence Reporting, you’ve probably been to the [HOW TO] SmartThings Presence reporting using Tasker/SharpTools/AutoLocation post. @destructure00 has a lot of great info there on the what/how/why as well as some links to other good resources. If you want more info, I’d recommend taking a look there.

I’m doing the same thing, only along with SharpTools, I’m using Automagic instead of Tasker & AutoLocation. The cost is pretty close, Automagic is currently $3.90 (if you want to try it out, you can get a trial version from the Automagic website here) and Tasker + AutoLocation would be $4.50. But I’ve been using Automagic for years, and I prefer it to Tasker.

I consider myself home if EITHER my WiFi connects, OR I’m within 120m of home. I consider myself departed only when my WiFi is disconnected AND I’m more than 400m from home. I don’t want my presence to bounce if my WiFi cuts out for a minute or my phone’s GPS freaks out (which happens from time to time). I don’t have this controlling access (door locks etc.) yet - when I get a connected lock (which is on my shopping list :smile:), I may have to adjust a bit.

So on to the process:


How I make it happen

  1. Create a virtual presence sensor in SmartThings.

    1. Open ST IDE in your browser
    2. Choose My Devices from the top menu
    3. Click the green New Device button at the top right of your device list
    4. Fill out Name, Label, give it a unique Device Network ID (I’m going to have one for everyone in the house, so I’m using PRESENCE_SCOTT for me), choose Simulated Presence Sensor from the Type drop-down menu, Version - Published, Location - select your location, Hub - select your hub, then Create.
  2. Authorize SharpTools to access your devices

    1. Open SharpTools App
    2. Tap hamburger menu it top left corner
    3. Tap Settings
    4. Tap Authorize Things. This will take you to the ST IDE Login where you can tell ST which devices SharpTools can access.
    5. Once you have your presence sensor in your list of things, you need to add a subscription so AutoMagic knows when your presence changes. Find your presence sensor in the list, long press, then select Subscribe to Presence. If your subscription is successful, you will get a little star at the top right corner of the device.
  3. Create global variables in Automagic

    1. Open Automagic App
    2. Tap the hamburger menu in the top left corner
    3. Select Global Variables
    4. Tap the red + icon at the bottom of the screen
    5. Type in “at_home” (after “global_”) to create the global_at_home variable and tap OK
    6. Expand the drop-down list, and select Boolean, then set to true if you’re currently at home, or false otherwise, then tap OK
    7. Tap the red + icon at the bottom of the screen
    8. Type in “my_presence” (after “global_”) to create the global_my_presence variable and tap OK
    9. Leave the type as “String”, and enter present if you’re currently at home, or not present otherwise, then tap OK
    10. Click the left arrow at the top of the form to return to the main screen
  4. Create “Arrive Me” flow in Automagic

    1. Tap the red + icon at the bottom of the screen
    2. Open the menu by tapping the 3 vertical dots in the top-right corner and select “Rename Flow”
    3. Name the flow “Arrive Me”
    4. Select the grey box (this is the trigger box, we’ll be leaving the trigger empty for this flow)
    5. Tap the plus icon below the trigger box and select Condition
    6. Find and select the “Expression” condition type (you may need to click “NEW…” at the bottom of the screen to see the full list)
    7. Below Insert common script parts, tap VARIABLE, and select global_my_presence
    8. In the Expression field,add: == "present"; so you should have: global_my_presence == "present";
    9. Click SAVE
    10. Tap the plus icon below the condition box and select False
    11. Select Action in the next dialog box
    12. Find and select the “Plugin (Experimental)” action type
    13. From the Plugin dropdown, select “A Thing”
    14. Tap Configure
    15. Select “Simulated Presence Sensor” as the device type, your presence sensor’s name (PRESENCE_SCOTT in my case) as the device, and “arrived” as the command, then click APPLY
    16. Click SAVE
    17. Tap the plus icon below the action box and select Action
    18. Find and select the “Script” action type
    19. Below Insert common script parts, tap VARIABLE, and select global_my_presence
    20. In the Expression field,add: = "present"; so you should have: global_my_presence = "present";
    21. Click SAVE
    22. Click the left arrow at the top of the form to close (and save) the flow
  5. Create “Depart Me” flow in Automagic

    1. Tap the red + icon at the bottom of the screen
    2. Open the menu by tapping the 3 vertical dots in the top-right corner and select “Rename Flow”
    3. Name the flow “Depart Me”
    4. Select the grey trigger box (we’ll be leaving this one empty too)
    5. Tap the plus icon below the trigger box and select Condition
    6. Find and select the “Expression” condition type
    7. Below Insert common script parts, tap VARIABLE, and select global_me_home
    8. Click SAVE
    9. Tap the plus icon below the condition box and select False
    10. Select Action in the next dialog box
    11. Find and select the “Plugin (Experimental)” action type
    12. From the Plugin dropdown, select “A Thing”
    13. Tap Configure
    14. Select “Simulated Presence Sensor” as the device type, your presence sensor’s name (PRESENCE_SCOTT in my case) as the device, and “departed” as the command, then click APPLY
    15. Click SAVE
    16. Tap the plus icon below the action box and select Action
    17. Find and select the “Script” action type
    18. Below Insert common script parts, tap VARIABLE, and select global_my_presence
    19. In the Expression field,add: = "not present"; so you should have: global_my_presence = "not present";
    20. Click SAVE
    21. Click the left arrow at the top of the form to close (and save) the flow
  6. Create “Geofence Arrival Boundary” flow in Automagic

    1. Tap the red + icon at the bottom of the screen
    2. Open the menu by tapping the 3 vertical dots in the top-right corner and select “Rename Flow”
    3. Name the flow “Geofence Arrival Boundary”
    4. Select the grey trigger box
    5. Tap the icon above the trigger box with the 4 horizontal lines (cheeseburger??:slight_smile:)
    6. Find and select the “Location” trigger type (you may need to click “NEW…” at the bottom of the screen to see the full list)
    7. Select Method = Modern (Experimental)
    8. Tap “PICK LOCATION”, find your home’s location on the map, and click SAVE
    9. Name your location “Home120”
    10. Set Radius = 120.0 (you can tweak this as needed, but 120 has worked well for me)
    11. Check the “Entering” box under Entering / Exiting
    12. Click SAVE
    13. Tap the plus icon below the trigger box and select Action
    14. Find and select the “Script” action type
    15. Below Insert common script parts, tap VARIABLE, and select global_me_home
    16. In the Expression field,add: = true; so you should have: global_me_home = true;
    17. Click SAVE
    18. Tap the plus icon below the action box and select Action
    19. Find and select the “Execute Flows” action type
    20. Tap the 3 dots at the end of the Flow pattern list, find and select the “Arrive Me” flow, and click OK
    21. Click SAVE
    22. Click the left arrow at the top of the form to close (and save) the flow
  7. Create “Geofence Departure Boundary” flow in Automagic

    1. Tap the red + icon at the bottom of the screen
    2. Open the menu by tapping the 3 vertical dots in the top-right corner and select “Rename Flow”
    3. Name the flow “Geofence Departure Boundary”
    4. Select the grey trigger box
    5. Tap the cheeseburger icon above the trigger box
    6. Find and select the “Location” trigger type
    7. Select Method = Modern (Experimental)
    8. Tap “PICK LOCATION”, find your home’s location on the map, and click SAVE
    9. Name your location “Home400”
    10. Set Radius = 400.0 (again, tweak if needed)
    11. Check the “Exiting” box under Entering / Exiting
    12. Click SAVE
    13. Tap the plus icon below the trigger box and select Action
    14. Find and select the “Script” action type
    15. Below Insert common script parts, tap VARIABLE, and select global_me_home
    16. In the Expression field,add: = false; so you should have: global_me_home = false;
    17. Click SAVE
    18. Tap the plus icon below the action box and select Condition
    19. Find and select the “WiFi Connected” condition type
    20. Tap the 3 dots at the end of the SSID List, select your home WiFi SSID(s), and click OK
    21. Click SAVE
    22. Tap the plus icon below the condition box and select False
    23. Select Action in the next dialog box
    24. Find and select the “Execute Flows” action type
    25. Tap the 3 dots at the end of the Flow pattern list, find and select the “Depart Me” flow, and click OK
    26. Click SAVE
    27. Click the left arrow at the top of the form to close (and save) the flow
  8. Create “Home WiFi Connect” flow in Automagic

    1. Tap the red + icon at the bottom of the screen
    2. Open the menu by tapping the 3 vertical dots in the top-right corner and select “Rename Flow”
    3. Name the flow “Home WiFi Connect”
    4. Select the grey trigger box
    5. Tap the cheeseburger icon above the trigger box
    6. Find and select the “WiFi Connected” trigger type
    7. Tap the 3 dots at the end of the SSID List, select your home WiFi SSID(s), and click OK
    8. Click SAVE
    9. Tap the plus icon below the trigger box and select Action
    10. Find and select the “Script” action type
    11. Below Insert common script parts, tap VARIABLE, and select global_me_home
    12. In the Expression field,add: = true; so you should have: global_me_home = true;
    13. Click SAVE
    14. Tap the plus icon below the action box and select Action
    15. Find and select the “Execute Flows” action type
    16. Tap the 3 dots at the end of the Flow pattern list, find and select the “Arrive Me” flow, and click OK
    17. Click SAVE
    18. Click the left arrow at the top of the form to close (and save) the flow
  9. Create “Home WiFi Disconnect” flow in Automagic

    1. Tap the red + icon at the bottom of the screen
    2. Open the menu by tapping the 3 vertical dots in the top-right corner and select “Rename Flow”
    3. Name the flow “Home WiFi Disconnect”
    4. Select the grey trigger box
    5. Tap the cheeseburger icon above the trigger box
    6. Find and select the “WiFi Disconnected” trigger type
    7. Tap the 3 dots at the end of the SSID List, select your home WiFi SSID(s), and click OK
    8. Click SAVE
    9. Tap the plus icon below the trigger box and select Action
    10. Find and select the “Script” action type
    11. Below Insert common script parts, tap VARIABLE, and select global_me_home
    12. In the Expression field,add: = false; so you should have: global_me_home = false;
    13. Click SAVE
    14. Tap the plus icon below the action box and select Condition
    15. Find and select the “Location” trigger type
    16. Tap “PICK LOCATION”, tap the 3 vertical dots in the top-right corner, select “Existing Locations”, select “Home400”, and click SAVE
    17. Check the “Inside” box under Accept Every Update
    18. Click SAVE
    19. Tap the plus icon below the condition box and select False
    20. Select Action in the next dialog box
    21. Find and select the “Execute Flows” action type
    22. Tap the 3 dots at the end of the Flow pattern list, find and select the “Depart Me” flow, and click OK
    23. Click SAVE
    24. Click the left arrow at the top of the form to close (and save) the flow
  10. Toggle all 6 of the flows you created to “on” with the toggle button at the top right of each

  11. Profit!


I tried to make this so someone who isn’t already familiar with AutoMagic would be able to follow it and get everything set up. Hopefully I got everything, but certainly let me know if something looks off, or if you have any questions. I’m going to test this guide by using it to add the functionality on another phone, so I’ll come back and update if I find any problems there.


Update 2/11/18: Added step for creating & using global variables, and updating labeling of locations from just “Home” to “Home120” & “Home400”


(Chris) #2

Nice writeup! :sunglasses: