Twice a year, a group of Safe Software employees participates in the Bike to Work Week (BTWW) organized byHUB Cycling, a charitable non-profit organization established to improve cycling conditions in Metro Vancouver. BTWW is an initiative to motivate people to use bikes for their daily commutes to work, a whole week long. It’s always a fun week with a bigger group of Safers joining in every year. We always organize at least one longer group ride during the week with a nice evening social event, which is great to get to know new members of the team.

The bike room at Safe Software. (Learn more about our culture:safe.com/careers)

A big part of BTWW is trip logging. Every biker logs the distance of his or her trips for every single day. Along with winning prizes, all logged trips help to improve cycling infrastructure in the communities of Metro Vancouver. All participating teams are also listed in an online leaderboard with a summary of distance, calories burned and greenhouse gases saved. But you need to go to the website every day and log your trips manually to make them count. There must be a way to automate this!

3 steps to automate BTWW trip logging

1. Track rides during BTWW and access them with FME

I have been logging quite a few of my bike rides and runs using an activity tracker, which easily syncs with theStravaapp on my phone via Bluetooth. A while ago, I uploaded aStrava Web Connectionto theFME Hub. This web connection allows me to interact with my activities tracked with Strava via theStrava REST API, directly in FME.Web Connectionsare the perfect way to interact with any web services that provide a REST API. So the first step needed to automate trip logging was already done and is still easily accessible thanks toFME Hub.

2. Log my trips on the HUB Cycling webpage

The second step turned out to be a little bit trickier. The HUB Cycling webpage does not provide an API that would allow us to simply log trips by sending a request to a single URL so I had to improvise. But as it often turns out, almost nothing is impossible with FME. I connected a couple of HTTPCallers following the same steps I would usually do manually: Log in to the webpage, navigate to the trip logging page and finally upload the information about my ride. This worked so well that I decided to create acustom transformer.

FME Workspace: A look insideHUBTripLogger, the custom transformer that automatically logs Strava trips to HUB Cycling.

To make theHUBTripLogger custom transformeravailable to my co-workers and everybody else who wants to log trips with FME during BTWW, I again published it to theFME Hub, which is a great platform to share little projects like this. The new Upload & Edit dialog is very intuitive and walks you through all the steps to upload or update yourcustom transformers.

The interface onhub.safe.comwhere you can edit the way your custom transformer is shared.

Now if we take a closer look at thefull workspace, we can see a few fairly new date & time transformers in action. Working with date & time information can be quite challenging when we work with different formats and web services, and this project is a good example. In total there were 3 common challenges related to date & time information that I had to overcome:

  1. Make sure my request to Strava catches only bike rides of the current day
    Solution:DateTimeStamper&DateTimeCalculator
  2. Provide the timestamp in Unix epoch format for the Strava API request
    Solution:DateTimeConverter
  3. Provide the date in the expected format for the HUB Cycling webpage
    Solution:Again theDateTimeConverter

FME Workspace that logs Strava bike rides in HUB Cycling. [Download here]

Now I had a workspace that queried my Strava account for all my activities and logged all bike rides that were flagged as commutes to theHUB Cycling webpage. The final step is automation.

3. Automate the workflow with a daily schedule

Now that the workflow is ready to get all tracked rides of a single day from Strava to log them as BTWW trips, we need to automate the process for the whole week. So it’s time forFME Server. While not everybody might have access to FME Server, withFME Cloudwe can easily launch an FME Server instance within a couple of minutes. WithFME Server Scheduleswe can now set up our workspace to run on a daily basis for a whole week.

Setting up the Bike to Work Week FME Workspace to run on a daily schedule.

Now the BTWW trip logging is fully automated, and all I need to do is track my rides with an activity tracker and let FME do the rest of the work.

About FME API Automation FME Cloud FME Hub HTTP Safe Culture

Gerhard Fischl

Gerhard is a FME Cloud Technology Expert at Safe Software. He is one of the top soccer players during lunch time soccer and is an avid bicyclist.

Comments

2 Responses to “Automating Bike to Work Week with FME”

  1. Martine Hoefsloot says:

    Gerhard, I want to ttry to get data from Strava myself, but it looks like I can not authorize. developers.strava.com gives another API URL (https://www.strava.com/api/v3/oauth/authorize?response_type=code) /api/v3/ is added. But It seems I get an error in all cases, might it be needed to have a premium account (which I don’t have), this information is missing in FME Hub. Kind regards, Martine

  2. Hi Martine,
    no premium account is needed to use the Strava Web Connection in FME. To use the Web Connection you just need to download it with FME Desktop and add your Client ID & Client secret. To get the Client ID & Client secret you need to create a Strava app first. You can do this by going to your Settings and My API Application in your Strava account (https://www.strava.com/settings/api). Nothing else should be changed in the service definition of the Web Connection.
    According to the documentation, the /api/v3/ path is only used in the API calls, not for the authentication calls:
    https://developers.strava.com/docs/authentication/

    I hope this helps!
    Kind regards,
    Gerhard Fischl

Leave a Reply

相关的帖子