This is a tool to add your sleep events to your calendar. It uses the Oura Cloud API to get your sleep data and the Google Calendar API to add the events to your calendar.
https://cloud.ouraring.com/v2/docs#section/Data-Access
https://developers.google.com/calendar/api/quickstart/python I'd recommend using the quickstart to get your credentials.json file. You'll need to enable the Google Calendar API for your account.
-
Clone the repo
-
Follow the quickstart guide for the Google Calendar API to get your credentials.json file (this may require setting up a Google Cloud Platform project)
-
Get your Oura API token (https://cloud.ouraring.com/personal-access-tokens)
-
Set up your secrets.json file (with your API token + calendar ID)
-
Install the requirements I didn't make a virtual environment for this, but you can if you want to This project uses pretty standard dependencies like requests, json, matplotlib (incase you want to visualize your data), datetime, os, and a handful of google packages which are noted in the quickstart guide.
-
Set your config variables at the top of main.py
-
Run the script
python3 main.py
- Check your calendar!
Note:
- I also created a cron job to run this script every day twice a day (once at midnight and once at noon), check out how to do it here
0 0,12 * * * /YOUR PATH/Oura2Calendar/sleep2calendar-cron.sh
- By default, the script will only add events for the current day. If you want to add events for past days, you can set the history variable to True + set your start date. This will add events for every day from the start date to the current day.
- This script can be a little buggy if you try to run history mode multiple times, as checking for duplicates isn't perfect (by default getting past events caps out at 250 events). If you want to run history mode multiple times, I'd recommend deleting the events from your calendar first.