Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add carbonintensity.org.uk provider to CLI #36

Merged
merged 1 commit into from
Jul 14, 2022
Merged

Conversation

rossf7
Copy link
Contributor

@rossf7 rossf7 commented Jul 13, 2022

At the moment the CLI only supports Ember and WattTime. For consistency I think we should enable all providers.

This adds carbonintensity.org.uk I'd like to add ElectricityMap as well but I'll do that as a separate PR and I could do with a license key for testing.

go run . -p carbonintensity.org.uk
{
	"from": "2022-07-13T16:30Z",
	"to": "2022-07-13T17:00Z",
	"intensity": {
		"forecast": 224,
		"actual": 215,
		"index": "high"
	}
}

@@ -41,14 +39,25 @@ type ApiClient struct {
}

func (a *ApiClient) GetCarbonIntensity(ctx context.Context, region string) (float64, error) {
latestData, err := a.getLatestCarbonIntensityData(ctx, region)
data, err := a.getCarbonIntensityData(ctx, region)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest in the name was bugging me as I think its redundant.

}
if regionCode != "UK" {
return fmt.Errorf("only region UK is supported")
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We default the region but also check it is set to UK.

@rossf7 rossf7 marked this pull request as ready for review July 13, 2022 17:09
@rossf7 rossf7 requested a review from mrchrisadams July 13, 2022 17:09
Copy link
Member

@mrchrisadams mrchrisadams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good Ross! Merge away!

@rossf7 rossf7 merged commit aa59f93 into main Jul 14, 2022
@rossf7 rossf7 deleted the add-uk-provider-to-cli branch July 14, 2022 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants