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

tariff/octopusenergy: Refactor / Support API Keys for tariff data lookup #13637

Merged
merged 12 commits into from
Apr 30, 2024

Conversation

duckfullstop
Copy link
Contributor

@duckfullstop duckfullstop commented Apr 29, 2024

This PR adds support for the apikey option on the octopusenergy tariff provider. Using an API key allows for automatic detection of the user's relevant tariff, and also allows for some potentially exciting functionality down the road such as user-specific tariff (and load shedding?) flexibility.

Splits a new GraphQL provider and Rest out into separate packages. Rest is still required even with GraphQL being available as GraphQL has a lot of restricted endpoints / retains backwards compatibility.

Changes the tariff config flag to productcode as discussed in #13474, and deprecates the former with a warning (not a breaking change).

This PR does NOT add support for handling Intelligent Octopus slots - further work required.

Remake of #11555 - see that PR for more context
Closes #13474
Merge simultaneously with evcc-io/docs#509

duckfullstop and others added 6 commits April 26, 2024 18:48
Initial work, more to be done here, committing as I've been working on this most of the evening!

Splits GraphQL and Rest out into separate packages. Rest is still required even with GraphQL being available as GraphQL has a lot of restricted endpoints.
…ct Octopus parlance

Closes evcc-io#13474 - not a breaking change but deprecates 'tariff'
@duckfullstop
Copy link
Contributor Author

foiled by the linter 😠 can fix tonight?

@andig andig added the enhancement New feature or request label Apr 29, 2024
@andig
Copy link
Member

andig commented Apr 29, 2024

Nah, it's build that fails:

Error: tariff/octopus.go:15:2: octoGql redeclared in this block
Error: 	tariff/octopus.go:10:2: other declaration of octoGql
Error: tariff/octopus.go:15:2: "github.com/evcc-io/evcc/tariff/octopus/graphql" imported as octoGql and not used
Error: tariff/octopus.go:16:2: octoRest redeclared in this block
Error: 	tariff/octopus.go:11:2: other declaration of octoRest
Error: tariff/octopus.go:16:2: "github.com/evcc-io/evcc/tariff/octopus/rest" imported as octoRest and not used

copy/paste error?

tariff/octopus.go Outdated Show resolved Hide resolved
@andig
Copy link
Member

andig commented Apr 29, 2024

Did some small simplifications. Would like to get rid of the token refresh handling- instead use graphQL logging similar to tibber.go?

Update I would even think that the logger should already log the token mutations?

@andig
Copy link
Member

andig commented Apr 29, 2024

Removed the log, please check if ok for you.

@@ -111,7 +108,7 @@ func (c *OctopusGraphQLClient) AccountNumber() (string, error) {
return "", errors.New("no account associated with given octopus api key")
}
if len(q.Viewer.Accounts) > 1 {
c.log.WARN.Print("more than one octopus account on this api key - picking the first one. please file an issue!")
return "", errors.New("more than one octopus account on this api key not 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.

my only proviso on this wording is that it implies we will never support it / people should give up with the integration, whereas we want people to report it so that account selection functionality can be added if necessary - happy to go with breaking loudly though

@duckfullstop
Copy link
Contributor Author

LGTM (untested)

@andig andig merged commit 33aa884 into evcc-io:master Apr 30, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Grid type octpusenergy key is called "tariff" but only accepts "product"
2 participants