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
- suggesting a new integration
- coding a new integration
- updating our carbon models
- correcting a bug in an existing integration.
- submitting ideas, feature requests, or bugs in the issues section.
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
The app let's you input trips manually by distance or time and transportation mode, and amount of passengers for a car trip.
- 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!
Working on it.
Help us out with an integration and CO2 models. Check what we think makes a great integration!
The app let's you input meals manually by type of food. Help us out with more CO2 models!
Nothing yet! Help us out with an integration and CO2 models. Check what we think makes a great integration!
Working on it.
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.
To ease development, we've created a development playground.
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.
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 collect
s.
{
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
}
{
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
}
./co2eq
: carbon models./integrations
: contains all integrations./integrations/img
: contains all integration logos./playground
: source code of the playground./definitions.js
: constant definitions