TaskerAndroidPocketablesTutorials

Tasker Emergency Profile – Great for cycling or a night out

It’s all good until somebody gets hurt. As a keen cyclist, I have had a fair share of punctures, and few scraps with cars or near road obstacles. Fortunately, I came out of it unscathed. I’m also responsible for some of that grey hair my mom got, by not telling here where I am and when I will be back. Perhaps it is too little, too late for me, but you may be the right person to talk to. The Tasker Emergency Profile will let designated person know your whereabouts without draining your battery. Perhaps it won’t prevent you from getting in troubles in the first place, but it could make saving your neck little easier.

Tasker Emergency Profile – not only for cycling

This profile is responsible for reporting. It will issue a text message (yes, good old fashion text in case you have no internet coverage) to the person of your choice when:

  • when you leave (it will let them know what time you should be back, and how to request your location)
  • when your battery is about to die (so, they wouldn’t get worried sick)
  • when you have changed your plans and you are running late (cause it makes sense to keep your close ones updated)
  • when you got safely home (so they would stop worry sick)
  • AND I hope that won’t happen when something happened, and you are not back home when you suppose to (so they could find your last location or request one)

GPS is an old debate. It uses a lot of battery power which is so precious when outside. Strava and other fitness trackers can share live location updates for the same purposes, but this will drain your battery considerably faster.  Tasker Emergency Profile will save you some juice by checking your location on request only. I see on forums that a lot of users still trying to toggle GPS, I left this out in this tutorial. Unless there are some privacy concerns, GPS and location reporting works well as it is.

Conditions

The Tasker Emergency Profile contains  5 contexts. These aren’t actually complicated, 3 of them, responsible for returning the location via SMS are linked to the same task, one to cancel the profile altogether. The last one makes sure we can send out a text message.

Low Battery Update

screenshot_20161020-120251Because I want this profile to be active only when I’m cycling, I have created the variable %BikeRide  this will be one of the conditions in my profiles. The second context is battery level which is set to 0-5. This should have enough juice to get the last location and send the SMS. I have picked bigger number instead of 2% just in case we are outside the network, and the SMS is pending to be sent for a while.

Text Location Update

screenshot_20161020-120255

While on the bike, any (or defined – up to you) contact can use a keyword to request your location. The text has to contain the exact word, but the word can be placed anywhere in your regular text. This remains active for the duration of your bike ride. After all – you may not always want to share your position. Just in case you wish to go for that quick drink after work.

Time Condition Update

screenshot_20161020-120300If you are running late, this condition sends the text message unless an action is taken. Without some sensors running wildly and sucking in all the battery power you have left, it is hard to tell when you had an accident. If you have been involved in one, and you are not back on time, the profile will become active and sends a text message out.

Home – close on WiFi

screenshot_20161020-120308Let’s face it, chances are that you will forget once or twice to turn this off in time. If you have a home area set up to enable the WI-FI on your phone, this will disable the Tasker Emergency Profile when you have connected again to the home WI-FI.

Signal check

screenshot_20161020-120313This is a simple profile that checks the signal strength. If a signal is present, variable %InRange is set to 1, otherwise, it is 0. This profile will be used with Wait Until action – to make sure that the SMS is sent when the signal is present. Entry task changes the value to 1 while exit task will set the value of the variable to 0.  Further on the variable is used  to check every 5 second if value of %InRange is 1, then the text message is sent.

Tasks

screenshot_20161020-123238Tasks are kept fairly simple too in the Tasker Emergency Profile. As you have seen in the contexts section Tasker Emergency Profile reuses Send Location profile multiple times. The entire project starts with the Start task. As the tasks are fairly simple please look at the bottom of the page for the action list.

Start

This is where we are going to create and display 1st scene (Bike 999). Later on, I have added a destroy scene as my 1st action to make sure I have an escape, should I close the scene via the  back button.

Send Location

To get the location with a pin on google maps we have you query the coordinates. Fortunately, the location coordinates provided by Tasker (variable %LOCN) are formatted correctly and all we have to do is plug it in inside this URL:

[code]http://maps.google.com/maps?q=loc:%LOCNz=12[/code]

The value of b is responsible for a zoom level when the link is opened. This link works with both Google Maps app and web interface. When the link is composed Wait Until action and %InRange variable sends the text message only when the networks allows us to do so. By default, my text looks like this:

Currently about %LOCACC m away from %GoogleURL

However, if my battery is low, I’d like to send a slightly different message. This also allows me to have all three profiles using the same task:

My phone battery is low.  Just want to let you know where I am.  I went for a bike ride. Currently about %LOCACC m away from %GoogleURL. I’ll call you once I’m back home.

Extend

If I’m running late, I need to pull up a new scene (Extend) and pick new ETA for my return. This task cancels the notification and opens a new scene for me.

Got Home

Once I’m back home, I have to close the profile and let the person know I’m OK. Both manual deactivation and the Wi-F- context is linked to this task. It will deactivate the needed profiles, cancels the notification, sends the message out that I’m safe and then clears the %Bike* variables.

InRange+/-

As discussed in the Signal check condition.

Scenes

Bike 999

screenshot_20161020-125009All interactive elements (apart from the OK button) in the Tasker Emergency Profile do the same thing. They set a value  %new_val to a specific variable. So for number pickers its %BikeHour and %BikeMinute. For the text entry, it is %EmergencyContact and for the checkbox it is %EmergencySend. These are assigned when changed, and the OK button is dealing with the default values and processing the text message.

Few things to discuss here.

A1-A5 – obvious.
A6 – assign the default contact number
A7-A8 – assign the defaults for number pickers
A9 – A10 – Create a variable which will format the time correctly for the SMS. If values are <10 additional zeros are added.
A11 – This variable is used in the Time contexts, needs no zeros but requires a ‘.‘ to work in the context
A12 – notification contains two actions – Extend and End
A16:

Hey!  I’m going on a bike ride.  I should be back at %ReturnTime.  You can always look up my location via text.  Use LOCATION in your text to receive the update, if I’m not back by the time listed give me a call.

Message with instructions which is sent if tick box was selected.

Extend

screenshot_20161020-125015This scene was made as a copy of Bike 999 one. Then other elements were removed and the OK button has been modified a little. Save yourself the trouble and finish the 1st scene first and you will notice that there are only a few things to change.

screenshot_20161020-125055

Remove the actions that don’t belong to this list.  then change your text message to reflect the action:

It’s taking little longer.  I should be back by %ReturnTime

And you are pretty much done here.

Conclusion

Tasker Emergency Profile  can have more than one use. Whether you are going for a long bike ride or just a crazy night  this profile could increase your safety. Perhaps you are still young and it could be an additional argument presented to your parents to let you go out for longer, or a hiking trip. I think I covered most common scenarios, but the project is not limited to these uses.

[tabs tab1=”Low Batt Update” tab2=”Text Loc Update” tab3=”Time Condition Update” tab4=”Home” tab5=”Signal check”] [tabs] [tab id=1]

[code]Profile: Low Batt Update (12)
	State: Battery Level [ From:0 To:5 ]
	State: Variable Value [ %BikeRide ~ 1 ]
Enter: Send Location (10)
	A1: Get Location [ Source:Any Timeout (Seconds):40 Continue Task Immediately:Off Keep Tracking:Off ] 
	A2: Variable Set [ Name:%GoogleURL To:http://maps.google.com/maps?q=loc:%LOCN&z=12 Do Maths:Off Append:Off ] 
	A3: Wait Until [ MS:0 Seconds:5 Minutes:0 Hours:0 Days:0 ] If [ %InRange ~ 1 ]
	A4: Send SMS [ Number:%SMSRF Message:Currently about %LOCACC m away from %GoogleURL Store In Messaging App:Off ] If [ %BATT > 5 ]
	A5: Send SMS [ Number:%SMSRF Message:My phone battery is low.  Just want to let you know where I am.  I went for a bike ride. Currently about %LOCACC m away from %GoogleURL. I'll call you once I'm back home. Store In Messaging App:Off ] If [ %BATT < 6 ]

[/code]
[/tab] [tab id=2]
[code]Profile: Text Loc Update (13)
	Event: Received Text [ Type:SMS Sender:C:ANY Content:*LOCATION* ]
	State: Variable Value [ %BikeRide ~ 1 ]
Enter: Send Location (10)
	A1: Get Location [ Source:Any Timeout (Seconds):40 Continue Task Immediately:Off Keep Tracking:Off ] 
	A2: Variable Set [ Name:%GoogleURL To:http://maps.google.com/maps?q=loc:%LOCN&z=12 Do Maths:Off Append:Off ] 
	A3: Wait Until [ MS:0 Seconds:5 Minutes:0 Hours:0 Days:0 ] If [ %InRange ~ 1 ]
	A4: Send SMS [ Number:%SMSRF Message:Currently about %LOCACC m away from %GoogleURL Store In Messaging App:Off ] If [ %BATT > 5 ]
	A5: Send SMS [ Number:%SMSRF Message:My phone battery is low.  Just want to let you know where I am.  I went for a bike ride. Currently about %LOCACC m away from %GoogleURL. I'll call you once I'm back home. Store In Messaging App:Off ] If [ %BATT < 6 ]

[/code]
[/tab] [tab id=3]
[code]Profile: Time Condition Update (30)
	Time: From %BikeTime Till %BikeTime
	State: Variable Value [ %BikeRide ~ 1 ]
Enter: Send Location (10)
	A1: Get Location [ Source:Any Timeout (Seconds):40 Continue Task Immediately:Off Keep Tracking:Off ] 
	A2: Variable Set [ Name:%GoogleURL To:http://maps.google.com/maps?q=loc:%LOCN&z=12 Do Maths:Off Append:Off ] 
	A3: Wait Until [ MS:0 Seconds:5 Minutes:0 Hours:0 Days:0 ] If [ %InRange ~ 1 ]
	A4: Send SMS [ Number:%SMSRF Message:Currently about %LOCACC m away from %GoogleURL Store In Messaging App:Off ] If [ %BATT > 5 ]
	A5: Send SMS [ Number:%SMSRF Message:My phone battery is low.  Just want to let you know where I am.  I went for a bike ride. Currently about %LOCACC m away from %GoogleURL. I'll call you once I'm back home. Store In Messaging App:Off ] If [ %BATT < 6 ]

[/code]
[/tab] [tab id=4]
[code]Profile: Home(44)
	State: Wifi Connected [ SSID:FASTBERRY MAC:* IP:* ]
	State: Variable Value [ %BikeRide ~ 1 ]
Enter: Got Home (43)
	A1: Profile Status [ Name:Low Battery Update Set:Off ] 
	A2: Profile Status [ Name:Text Location Update Set:Off ] 
	A3: Profile Status [ Name:Time Condition Update Set:Off ] 
	A4: Profile Status [ Name:Signal Check Set:Off ] 
	A5: Notify Cancel [ Title:Bike Profile Active Warn Not Exist:Off ] 
	A6: Wait Until [ MS:0 Seconds:5 Minutes:0 Hours:0 Days:0 ] If [ %InRange ~ 1 ]
	A7: Send SMS [ Number:%EmergencyContact Message:I'm back home now.  Thanks. Store In Messaging App:Off ] 
	A8: Variable Clear [ Name:%Bike* Pattern Matching:On ] 

[/code]
[/tab] [tab id=5]
[code]Profile: Signal Check (11)
	State: Signal Strength [ From:1 To:8 ]
Enter: In Range+ (31)
	A1: Variable Set [ Name:%InRange To:1 Do Maths:Off Append:Off ] 

Exit: In Range- (40)
	A1: Variable Set [ Name:%InRange To:0 Do Maths:Off Append:Off ] 

[/code]
[/tab] [/tabs]
Pocketables does not accept targeted advertising, phony guest posts, paid reviews, etc. Help us keep this way with support on Patreon!
Become a patron at Patreon!

Mat Zolnierczyk

I am passionate about technology, cycling, and art. This would explain why my bike has more computing power than your average office. I own notenoughtech.com and I write for xda-developers.com and pocketables.com NotEnoughTECH | Facebook | Twitter |YouTube |Instagram | Google+ |Donate |Patreon

Avatar of Mat Zolnierczyk