saurabhdaware / tmrowapp-contrib

Tomorrow automatically calculates the climate impact of your daily choices by connecting to apps and services you already use.

Home Page:https://www.tmrow.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tmrowapp-contrib Slack Status CircleCI

This repository contains the open-source integrations that allows the Tomorrow app to automatically calculate your carbon impact. The Tomorrow app is private-by-design: data will stay on device, unless the user explicitly gives consent. It also contains the CO2 models used by the app. This code is maintained by Tomorrow.

To get started, browse existing suggestions. Feel free to watch the presentation of our CEO & Founder Olivier gave to CopenhagenJS, explaining what a javascript developer can do to combat climate change.

You can contribute by

Join us on Slack if you wish to discuss development, need help to get started and want to get access to a developer preview of the app.

Status on integrations

Transportation

Manual

The app let's you input trips manually by distance or time and transportation mode, and amount of passengers for a car trip.

Automated

  • Automated Activity tracking
  • Tripit
  • Uber (contributor:willtonkin)
  • Ryanair (contributor:lauvrenn)
  • Rejsekort

Help us out with an integration and CO2 models. Check what we think makes a great integration!

Utilities

Manual

Working on it.

Automated

  • Sense (contributor:snarfed)
  • Linky (contributor:bokub)
  • Barry
  • Renault Zoé

Help us out with an integration and CO2 models. Check what we think makes a great integration!

Groceries

Manual

The app let's you input meals manually by type of food. Help us out with more CO2 models!

Automated

Nothing yet! Help us out with an integration and CO2 models. Check what we think makes a great integration!

Others

Manual

Working on it.

Automated

Nothing yet! Help us out with an integration and CO2 models. Check what we think makes a great integration!

Status on CO2 models

Our CO2 models sources can be checked by anyone here. Help us out with more and more precise models.

Getting started

To ease development, we've created a development playground.

Integrations

First, you will have to create a JSON file called env.json where to store integration credentials when needed. You can start by creating an empty file.

Run yarn to install dependencies, then run yarn serve to start the playground and point your browser to localhost:3000 to get started.

How an integration works

The job of an integration is to gather activities from a 3rd party datasource. To this end, 3 async methods need to be exported:

async function connect(requestLogin, requestWebView) {
  const { username, password } = await requestLogin();
  // ...
  return newState;
}
async function collect(state = {}, logger) {
  // ...
  return { activities, state: newState };
}
async function disconnect() {
  // ...
  return newState;
}

The connect method is used to ask for user credentials (we also support OAuth flows). The collect method is called periodically (typically every few hours) to fetch new activities. As the methods are pure, and to avoid re-asking the user for credentials everytime the collect method is called, a state object can be used to persist information (such as password, tokens..) across collects.

Activity formats

electricity consumption

{
  id, // a string that uniquely represents this activity
  datetime, // a javascript Date object that represents the start of the activity
  durationHours, // an integer that represents the duration of the activity
  activityType: ACTIVITY_TYPE_ELECTRICITY,
  energyWattHours, // a float that represents the total energy used
  hourlyEnergyWattHours, // (optional) an array of 24 floats that represent the hourly metering values
  locationLon, // the location of the electricity consumption
  locationLat, // the location of the electricity consumption
}

transportation

{
  id, // a string that uniquely represents this activity
  datetime, // a javascript Date object that represents the start of the activity
  durationHours, // a floating point that represents the duration of the activity in decimal hours
  distanceKilometers, // a floating point that represents the amount of kilometers traveled
  activityType: ACTIVITY_TYPE_TRANSPORTATION,
  transportationMode, // a variable (from definitions.js) that represents the transportation mode
  carrier, // (optional) a string that represents the transportation company
  departureAirportCode, // (for plane travel) a string that represents the departure airport, IATA code
  destinationAirportCode, // (for plane travel) a string that represents the final destination airport, IATA code
  departureStation, // (for other travel types) a string that represents the original starting point
  destinationStation, // (for other travel types) a string that represents the final destination
}

Folder structure

  • ./co2eq: carbon models
  • ./integrations: contains all integrations
  • ./integrations/img: contains all integration logos
  • ./playground: source code of the playground
  • ./definitions.js: constant definitions

About

Tomorrow automatically calculates the climate impact of your daily choices by connecting to apps and services you already use.

https://www.tmrow.com

License:GNU General Public License v3.0


Languages

Language:JavaScript 96.9%Language:HTML 3.1%