Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Issues with IFTTT pushing sleep data to Google calendar

ANSWERED
Replies are disabled for this topic. Start a new one or visit our Help Center.

Currently, IFTT receives sleep data from Fitbit under limited formats, called ingredients.

 

These "ingredients" are the only pieces of data that can be used in "recipes." Any recipe that integrates with Google Calendar must do so via its quick add function.

 

The issue is that Google Calendar's quick add function is unable to parse Fitbit's input in the limited formats allowed by ingredients.

 

This renders GCal unable to add an event for the duration of one's sleep, a basic feature of sleep tracking. Events are added, but they are for the default duration of 1 hour and have a nonsensical title.

 

A reddit thread a few months ago also discussed this issue and were unable to find a workaround that didn't involve manually editing the events.

 

Is it possible for Fitbit to change the ingredients, and for example, change the FellAsleepAt and AwokeAt ingredients to just provide the time? And provide FallAsleepAtDate and AwokeAtDate as additional ingredients so mitigate the data moved from the prior ingredients?

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

As described in the link in the edit to my previous post, I ended up using IFTTT to push Fitbit's sleep data to a Google Sheet, and then a Google Sheet script to make a Google Calendar event.

 

I'm using Fitbit's first-party IFTTT recipe "Save your Fitbit sleep logs to a Google Spreadsheet" to push to a Google Sheet:

 

{{FellAsleepAt}} ||| {{TotalTimeSlept}} ||| {{TotalTimeSleptInSeconds}} ||| {{TimeToFallAsleep}} ||| {{TimeToFallAsleepSeconds}} ||| {{TimeAwake}} ||| {{TimeAwakeSeconds}} ||| {{AwakeCount}} ||| {{RestlessCount}} ||| {{TimeToLeaveBed}} ||| {{TimeToLeaveBedSeconds}} ||| {{AwokeAt}}

 

 

In that Google Sheet, I set up the following script to run every hour. The script puts the right info into Google Calendar's quick-add function in a way it can understand. Make sure you get the calendarID of the Google Calendar to which you want to push events and replace YOUR_DESIRED_CALENDAR_ID.

 

//push new events to calendar
function pushToCal() {
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = spreadsheet.getActiveSheet();
  var row = sheet.getLastRow();
  var range_date = sheet.getRange(row,1);
  if (sheet.getRange(row, 14).getValue().length<2){
    Logger.log("DateSleep in last row is less than 2, so proceed");
    var datesleep = range_date.getValue();
    var timesleep = range_date.getValue();
    
    var pos1 = datesleep.indexOf(' at'); 
    datesleep = datesleep.substr(0,pos1);
    sheet.getRange(row,14).setValue(datesleep);
    
    timesleep = timesleep.slice(-7);
    sheet.getRange(row,15).setValue(timesleep);
    
    var range_minsleep = sheet.getRange(row,3);
    var range_minawake = sheet.getRange(row,7);
    var mintotalsleep = range_minsleep.getValue()/60+range_minawake.getValue()/60;
    sheet.getRange(row,16).setValue(mintotalsleep);
    
    var QuickAddText = 'Sleep ' + datesleep + ' ' + timesleep + ' for ' + mintotalsleep + ' minutes';
    sheet.getRange(row,17).setValue(QuickAddText);
    
    var calendar = CalendarApp.getCalendarById('YOUR_DESIRED_CALENDAR_ID@group.calendar.google.com');
    calendar.createEventFromDescription(QuickAddText);
  }
    else{
      Logger.log("Went to else statement");
  }
  
}

Not sure if this is the easy solution you're looking for, but you can set this up and then add the Google Calendar to your Apple Calendar. Hope it helps! (and for anyone googling for this issue)

View best answer in original post

Best Answer
0 Votes
8 REPLIES 8

Which recipe are you using? I have it working just fine with the Fitbit recipe created 3rd Feb. Have you edited your Formatted Row data?

 

Versa 2
Best Answer
0 Votes

I've tried both the official Fitbit one (Track your nightly sleep in Google Calendar) and a 3rd party one (Fitbit sleep to Google calendar). Are you using the former? That one doesn't appear to be editable.

 

What's in your Formatted Row data? By chance, are you referring to the Sleep data to Google Spreadsheet recipe instead? I don't recall a "Formatted Row" term with the Google Calendar recipes. Thanks!

Best Answer
0 Votes

This one https://ifttt.com/applets/49132719d-save-your-fitbit-sleep-logs-to-a-google-spreadsheet/edit

 

Formatted Rows are:

 

{{FellAsleepAt}} ||| {{TotalTimeSlept}} ||| {{TotalTimeSleptInSeconds}} ||| {{TimeToFallAsleep}} ||| {{TimeToFallAsleepSeconds}} ||| {{TimeAwake}} ||| {{TimeAwakeSeconds}} ||| {{AwakeCount}} ||| {{RestlessCount}} ||| {{TimeToLeaveBed}} ||| {{TimeToLeaveBedSeconds}} ||| {{AwokeAt}}

 

Am I barking up the wrong tree?

Versa 2
Best Answer
0 Votes

Haha possibly, though I appreciate the attempt!

 

I'm referring to sleep data being pushed to Google Calendar instead of Google Spreadsheets. I can't imagine there being issues pushing to Google Spreadsheets since there's no parsing that needs to be done. Pushing to Google Calendar, however, can only be done through Calendar's quick add function, which attempts to understand natural language input. Like I mention in my original post, the formats provided by Fitbit's ingredients don't play nicely with the quick add function. Hence, I'm hoping fitbit can edit the sleep ingredients and add some granularity. I hope that makes sense.

 

Edit: One could just write a script to parse and push from Google Spreadsheet to Calendar I suppose.

Best Answer
0 Votes

I saw a few posts and that you obviously know what you are talking about when it comes to pushing sleep data. I would like to get my sleep data into a calendar app. I use a Mac and use the default calendar but would switch to another reasonable app that has the same kind of functionality if I could get my sleep data into my calendar. All of the posts I saw on this were a few years old and wondering if there is an easy solution these days. 

Best Answer
0 Votes

As described in the link in the edit to my previous post, I ended up using IFTTT to push Fitbit's sleep data to a Google Sheet, and then a Google Sheet script to make a Google Calendar event.

 

I'm using Fitbit's first-party IFTTT recipe "Save your Fitbit sleep logs to a Google Spreadsheet" to push to a Google Sheet:

 

{{FellAsleepAt}} ||| {{TotalTimeSlept}} ||| {{TotalTimeSleptInSeconds}} ||| {{TimeToFallAsleep}} ||| {{TimeToFallAsleepSeconds}} ||| {{TimeAwake}} ||| {{TimeAwakeSeconds}} ||| {{AwakeCount}} ||| {{RestlessCount}} ||| {{TimeToLeaveBed}} ||| {{TimeToLeaveBedSeconds}} ||| {{AwokeAt}}

 

 

In that Google Sheet, I set up the following script to run every hour. The script puts the right info into Google Calendar's quick-add function in a way it can understand. Make sure you get the calendarID of the Google Calendar to which you want to push events and replace YOUR_DESIRED_CALENDAR_ID.

 

//push new events to calendar
function pushToCal() {
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = spreadsheet.getActiveSheet();
  var row = sheet.getLastRow();
  var range_date = sheet.getRange(row,1);
  if (sheet.getRange(row, 14).getValue().length<2){
    Logger.log("DateSleep in last row is less than 2, so proceed");
    var datesleep = range_date.getValue();
    var timesleep = range_date.getValue();
    
    var pos1 = datesleep.indexOf(' at'); 
    datesleep = datesleep.substr(0,pos1);
    sheet.getRange(row,14).setValue(datesleep);
    
    timesleep = timesleep.slice(-7);
    sheet.getRange(row,15).setValue(timesleep);
    
    var range_minsleep = sheet.getRange(row,3);
    var range_minawake = sheet.getRange(row,7);
    var mintotalsleep = range_minsleep.getValue()/60+range_minawake.getValue()/60;
    sheet.getRange(row,16).setValue(mintotalsleep);
    
    var QuickAddText = 'Sleep ' + datesleep + ' ' + timesleep + ' for ' + mintotalsleep + ' minutes';
    sheet.getRange(row,17).setValue(QuickAddText);
    
    var calendar = CalendarApp.getCalendarById('YOUR_DESIRED_CALENDAR_ID@group.calendar.google.com');
    calendar.createEventFromDescription(QuickAddText);
  }
    else{
      Logger.log("Went to else statement");
  }
  
}

Not sure if this is the easy solution you're looking for, but you can set this up and then add the Google Calendar to your Apple Calendar. Hope it helps! (and for anyone googling for this issue)

Best Answer
0 Votes

Typed up a reply but I think Fitbit's spam filter erroneously marked it since it contains google script code?

I've copied the same contents to the following paste: pastebin !!!! .  !!!! com !!!! / !!!! 9SvVQsCr

Best Answer
0 Votes

Hello @drewta and @spikey_richie. Welcome to the Forums @iboutros.

 

I apologize for the delay in my response.

 

@drewta Thanks for taking the time to share that with everyone! I am sure that other users will definitely find it useful.

 

If you have the time, be sure to visit one of our Discussion boards. Lots of different topics to talk about with other users.

 

Let me know if you have any further questions.

Lanuza | Community Moderator

Remember to vote for posts that helped you out! Tired of the same workout music? Try a Podcast! 🙂

Best Answer
0 Votes