SharpTools

            SmartThings: Custom Presence

            In this tutorial, we will briefly demonstrate how to use Tasker and SharpTools to create an accurate and effective custom presence solution for SmartThings. The built-in presence feature of the SmartThings mobile application has been criticized for randomly indicating that a person is no longer present in their home (when they are sleeping or sitting on the couch).

            At the end of the tutorial, you will have a custom presence solution using the proximity to your WiFi access point as the trigger for determining your presence. Additionally, the tutorial provides commentary on areas where you might choose to use alternative methods/customization that would better determine presence for your home.

            You might also be interested in the following SharpTools articles:

            Requirements

            • Tasker - automation for Android
            • SharpTools - SmartThings control for Tasker
            • Optional: AutoLocation - fused location provider plugin for Tasker
              Alternatively, you can also use the built-in Tasker location providers
            If you are interested in setting up a high accuracy presence solution with AutoLocation, @destructure00 from the SmartThings Community has a fantastic write-up showing how to set nested geofences which balance high-accuracy with great battery life.

            High-Level Approach

            1. Create a Simulated Presence Device in the SmartThings IDE
            2. Create a context for entering/leaving your defined area
              • Geo-fence, WiFi, Cell Towers... or all the above!
            3. Set the Simulated Presence Device to present or away

            Instructions

            Create a Simulated Presence Device

            1. Navigate to the SmartThings IDE
            2. Login (or register and then login)
            3. Select 'My Devices' from the navigation

            4. Click New Device in the top-right corner of the page

            5. Enter a name and Network ID for the device and select the following options:
              Name: Custom Presence
              Device Network ID: FAKE_PRESENCE (or something else unique)
              Type: Simulated Presence Sensor
              Version: Published
              Location: Home (or whatever your location is named)
              Hub: Home Hub (or whatever your hub is named)
            6. Click the 'Create' button at the bottom of the Create Device screen.
            You should now have a new 'Custom Presence' device listed in your SmartThings mobile app. Unlike normal presence devices, you can manually control this presence device setting it to 'not present' (away) or 'present' (arrived). Continue to the instructions below to see how we can use this simulated presence device along with Tasker to create an accurate and effective presence device.

            Create a context for entering/leaving your defined area

            In this section, we will explain how to create a Tasker context for which will trigger when you enter or leave your defined area. Note that there are many different approaches to determining location and only a few of those are noted here. So if you have other ideas on how you might be able to more effectively determine your location, feel free to use those.
            • GPS  - Latitude/Longitude positioning (example)
            • WiFi - proximity or connection to a particular Access Point (example)
            • Cellular - proximity or connection to cellular towers in the area (example)
            • Fused Location - a location provider that combines GPS, WiFi, and Cellular
            • Manual - manual interaction/control to toggle presence indication
            In order to keep this tutorial accessible to the broadest audience, we are going to use the 'WiFi Near'  condition that is built into Tasker. GPS, WiFi, and Cellular options are built-in to Tasker, but we have found that the Fused Location via AutoLocation provider provides the best accuracy both indoors and outdoors (particularly when WiFi is left on).
            1. Open Tasker
            2. From the Profiles tab, click the '+' icon at the bottom of the screen.
            3. Select the 'State' context > Net > Wifi Near
            4. In the SSID field, press the search icon to list the nearby access points
            5. Select your preferred access point from the displayed list
              Note: the SSID field should get filled in with your access point's name (SSID)
            6. Press the back button on your mobile device to save the Context
              Note: Continue onto setting up the action in the section below.

            As noted in the Tasker: Location Without Tears article:
            Wifi Near does regular Wifi Scans and will activate when it recognizes an AP you have configured is nearby. Note: you don't have to connect to the AP. You could configure e.g. the neighbours AP if the signal is strong enough.

            Frequency of checks is controlled by Menu / Prefs / Monitor / Wifi Scan Seconds (screen on) and Menu / Prefs / Monitor / Display Off All Checks (screen off).

            Check the Wifi Toggle box if you don't want wifi on all the time. It will then be toggled when Tasker needs to do a scan. This isn't needed in In Android 4.4+ if you select Scanning Always Available in Advanced Wifi Settings and will save power.

            Set the Simulated Presence Device to present or away

            Following the previous section where we had just completed setting up the context of a Tasker profile and had just clicked the back button to save the context.
            1. After setting up the context section of the profile, you should now be prompted to setup or select a Task
              Note: You can also setup the task outside of a profile by opening Tasker and switching to Tasks tab.
            2. Select the 'New Task +' option
            3. Optionally, enter a Task Name and click the checkmark to continue.
              Note: At this point, we are creating the task for the 'enter' portion of the context (eg. the WiFi is nearby). Later we will create an 'exit' condition for when the Wifi AP is not nearby.
            4. Click the '+' icon at the bottom of the screen to add a new action
            5. Select Plugin > SharpTools > A Thing
            6. Click the pencil icon on the configuration line
            7. Enter the following configuration:
              Device Type: Simulated Presence Sensor
              Device: Custom Presence (or whatever you named it early)
              Command: arrived
            8. Click Apply to save the SharpTools configuration
            9. Press the back button on your phone to save the Action
            10. Press the back button again to close out the Task Edit
            11. From the Profile tab of the main Tasker screen, long press on the 'A Thing' task within your 'Wifi Near' profile and select 'Add Exit Task'
            12. Select the 'New Task +' option
            13. Optionally, enter a Task Name and click the checkmark to continue.
            14. Click the '+' icon at the bottom of the screen to add a new action
            15. Select Plugin > SharpTools > A Thing
            16. Click the pencil icon on the configuration line
            17. Enter the following configuration:
              Device Type
              : Simulated Presence Sensor
              Device: Custom Presence (or whatever you named it early)
              Command: departed
            18. Click Apply to save the SharpTools configuration
            19. Press the back button on your phone to save the Action
            20. Press the back button again to close out the Task Edit
            21. Press the back button one last time to exit out of Tasker and activate the newly created profile

            Closing Comments

            At this point, Tasker is setup to check to see if you are in range of your Wifi access point and will automatically change the presence sensor to arrived when you are near the Wifi access point and away if you are no longer in range of the access point.
            We used the 'Wifi Near' Tasker context in this example to as it is included with Tasker and is easy to understand. Note that the author of this article recommends the AutoLocation plugin which provides a fused location provider which can provide a more flexible geolocation solution. As you might guess, the 'Wifi Near' context is dependent on being able to detect the access point... so if for some reason there are connectivity issues with the access point, the phone will trigger the exit condition.

            The fused location provider in AutoLocation helps get around this by using a geofence and location determined using Wifi+GPS+Cellular so there is a bit of fail-over built into the provider. The geofence capabilities of Autolocation also provide a visual representation your location and makes it easier to increase the size of the circle to reduce false alarms.

            Other Community Thoughts

            Resiliency and Retries: You may be interested in adding more resiliency to your profiles through the use of retries. Some users have found that the transition from Wifi to Cellular (or vice-a-versa) can cause the SharpTools commands to timeout while the network is unavailable.

            Hellfire51 put together a nice example showing how to add retries to your profile:

            Prompt to unlock doors: You may decide that you don't want your phone to automatically perform an action for you. For example, you may prefer the phone to display a notification or prompt asking you if you really want to perform the action.

            eibyer put together an example showing how to use custom presence to trigger a prompt asking if he wants to manually unlock his doors

            Troubleshooting

            • Leaving WiFi turned on for your Android device provides for the best location sensitivity in many applications
            • If you are on Android 4.4+, turn on the 'Scanning Always Available' option from Android Settings > WiFi > Advanced
            • If you are using the AutoLocation plugin or other geofence methods, try increasing the size of your geofence radius to be more forgiving
              • If you live/work/play within in a relatively small area, you may want to decrease the size of your geofence to provide a more accurate indication of presence and prevent false positives.
            • If you believe you are getting false-positives, try adding a 'Notify', 'Say', or 'Flash' action to your entry and exit tasks
              • For example, you might add a notification saying 'Arriving' to the entry task and a notification showing 'Leaving' to the exit Task to help you understand when the phone thinks you are coming or going
              • Additionally, if you are using AutoLocation, you can view the logs to see when AutoLocation thinks you are entering or leaving a Geofence and where it thinks you are at that time

            Helpful?  
            Help us to make this article better
            0 0