There has been a profile for driving, cycling and getting back to the car or saved location already. We are missing a public transport profile to close this experimental mini-series. The train schedules and delays Tasker project aim to give you the information you need. If Google Transit covers your country, this should work for you. You can check if your location is supported here:
https://maps.google.com/landing/transit/cities/
For a while now I have been trying to get the train schedules and delays available to me on request. I have noticed, that Google Now gives you the train schedules and delays card, but the card isn’t available until you get to the train station. I plan some of my journeys but I find entering each train ticket very impractical to receive Leave Now Card.
A few tests later I was able to display this card with a live train table on request:
Limitations
Because Google is being clever and all that, Cards should be displayed on your device when Google thinks you need it, not when you would like to see one. This means that there are situations when the card with the schedules and delays may not be displayed when you have a calendar event with a location in the same city within next few hours.
Removing the location from the event works, and the Google Now Card is reporting correctly.
While the train updates show up instantly, going back to the original location may take few moments. Bear in mind this will mess up your %LOC variable in Tasker until the next GPS fix is available.
Train schedules and delays Tasker Profile
For the purpose of this tutorial I will split the request into two triggers:
Dialog request
Manual Lookup Abort Existing Task A1: AutoTools Dialog [ Configuration:Dialog Type: List Title: Pick the train station Icon: /storage/emulated/0/ Material-Icons-011017-121644/res/drawable-xxxhdpi/ic_train.png List Type: 0 Texts: Yarn,Manchester Text Size: 20 Text Color: #E3F2FD Button Text Color: #E64A19 Image Width: 100 Commands: 54.4939:-1.3516,53.4774:-2.2309 Dim Background: true Top Margin: 16 Bottom Margin: 16 Bottom Buttons Top Margin: 16 Bottom Buttons Bottom Margin: 16 Close On Select: true Separator: , Command Variable: atcommand Cancelable: true Turn Screen On: true Timeout (Seconds):60 ] A2: Variable Split [ Name:%atcommand Splitter:: Delete Base:Off ] A3: Variable Set [ Name:%lat To:%atcommand1 Recurse Variables:Off Do Maths:Off Append:Off ] A4: Variable Set [ Name:%lon To:%atcommand2 Recurse Variables:Off Do Maths:Off Append:Off ] A5: AutoLocation Mock Location [ Configuration: Starting Mock Locations Persistent Notification: true Notification Title: We are set your location to %attext Notification Text: Don't worry it will get cancelled soon. Latitude: %lat Longitude: %lon Accuracy: 10 Timeout (Seconds):0 ] A6: Variable Set [ Name:%LocationTimeout To:%TIMES+180 Recurse Variables:Off Do Maths:On Append:Off ]
In this scenario, the coordinates for each station have to be assigned manually, this is a great way of adding your train stations for the commute or regular travels.
To start with this, we will need to use Google to find the exact coordinates for each station in question. Google maps won’t show you the coordinates directly if a named location is displayed, but you can find it in the URL of the location:
https://www.google.co.uk/maps/place/Leeds+Station/@53.7943125,-1.5497304,17z
The Latitude is first (53.7943125) and the Longitude second (-1.5497304). We need to format it so we could use it with the AutoTools Dialog action:
53.7943125:-1.5497304 (please note the colon)
A1
My AutoTools Dialog action stores the names of the stations in the Text field (separated by comma) and the associated coordinates are stored in the Commands field (also separated by comma):
- Yarm, Manchester
- 54.4939:-1.3516,53.4774:-2.2309
The dialog will be closed once the option is selected. You can find this behavior in advanced settings.
A2-A4
I need to split these when the appropriate option is pressed and separate the coordinates with the splitter ‘:’ (colon) Next, just store the %atcommand1 in %lat and %atcommand2 in %lon using Variable Set action.
A5
These values will be used in AutoLocation Mock Location action as Latitude and Longitude entries. I will also pass the %attext in the associated notification because I’m fancy like that!
Accuracy 10m is enough to get the Google Now triggered.
A6
Lastly, I will create a timeout by setting the variable %LocationTimeout to %TIMES+180 (or however long in seconds you wish to keep the fake location on) Select ‘do math‘. That action will trigger our canceling profile later.
Voice request
Profile: Lookup any Train station Event: AutoVoice Recognized [ Configuration:Command: "show me trains at*. (regex)" ] Enter: AutoLocation lookup (81) A1: AutoLocation Info [ Configuration:Coordinates Search Query: %avcommnofilter Coordinates Max Results: 1 Timeout (Seconds):60 ] A2: AutoLocation Mock Location [ Configuration: Starting Mock Locations Persistent Notification: true Notification Title: I'm pretending that you are at %avcommnofilter Notification Text: I will reset the location soon Latitude: %alcoordenatelatitudes1 Longitude: %alcoordenatelongitudes1 Accuracy: 10 Timeout (Seconds):0 ] A3: Variable Set [ Name:%LocationTimeout To:%TIMES+180 Recurse Variables:Off Do Maths:On Append:Off ]
A1
The AutoLocation Info action is used to get the coordinates of the train station. I’m limiting the results to one entry only. This way I will know where in the %alcoordenatelatitudes() and %alcoordenatelongitudes() arrays (please note the spelling mistake in the variable – I will get this reported).
Profile
To pass the name of the train station I’m using the AutoVoice recognize event. The command filter is: show me trains at*. (regex) (using the hard way option). The name of the train station will be stored in the %avcommnofilter variable, which is used to perform the AutoLocation Info action for the coordinates search.
A2
Once the coordinates are known, I simply use again AutoLocation Mock Location action to start the service with Latitude = %alcoordenatelatitudes1 and the Longitude = %alcoordenatelongitudes1 (I’d limited my result to 1 for that precise reason)
A3
Lastly, I’m adding the same action variable set, to trigger the end of location spoofing. Set the %LocationTimeout to %TIMES+whatever seconds you wish.
Cancel the Location spoofing
Profile: End fake location (84) Time: From %LocationTimeout Enter: Cancel fake location (82) A1: AutoLocation Mock Location [ Configuration: Stopping Mock Locations Timeout (Seconds):0 ] A2: Variable Clear [ Name:%LocationTimeout Pattern Matching:Off ]
A very simple task, in which AutoLocation Mock Location gets unchecked and cancelled and the variable %LocationTimeout cleared.
Conclusion
Sadly the Train schedules and delays Tasker profile can’t be used for now to get the same information from the coach stations. I hope this will change in the future. I find this project to be a very handy solution whenever I want to check the status of a train I’m trying to catch. What are your thoughts?
Project Download
Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.