Skip to content

Commit

Permalink
Add regions in properly as Agile Octopus has many regions
Browse files Browse the repository at this point in the history
  • Loading branch information
MattJeanes committed Jun 2, 2020
1 parent f66ff62 commit 3d733cf
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 5 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,25 @@ You will need to set configuration using environment variables, the required one
## Required environment variables
```yaml
- ConnectionStrings__TeslaMate: 'Server=127.0.0.1;Port=5432;Database=teslamate;User Id=teslamate;Password=teslamate;'
- TeslaMate__UpdateIntervalSeconds: '60' # Check for completed charges without a set cost every x seconds
- TeslaMate__UpdateIntervalSeconds: '300' # Check for completed charges without a set cost every x seconds
- TeslaMate__GeofenceId: '1' # You can get this by editing the Geofence inside TeslaMate and getting it from the url
- TeslaMate__Phases`: '1' # How many phases your electricity has, this will usually be 1
- TeslaMate__Phases: '1' # How many phases your electricity has, this will usually be 1
- Octopus__RegionCode: 'A' # See below
```
## Octopus Region Code
Electricity tariffs in Octopus Energy are separated into multiple regions depending on where you live, in order to find your code you can use one of two methods:
1. Go to https://octopus.energy/dashboard/developer/
2. Under Unit Rates, just before 'standard-unit-rates' in the URL provided there is a letter, this is your region code
3. For example in https://<span></span>api.octopus.energy/v1/products/AGILE-18-02-21/electricity-tariffs/E-1R-AGILE-18-02-21-**A**/standard-unit-rates/ your region code is **A**
Or if you're familar with curl / postman / etc
1. Call `GET https://api.octopus.energy/v1/industry/grid-supply-points?postcode=POSTCODEHERE`
2. You will get a response with `"group_id": "_A"` for example, A is your region code
## Docker support
This project is available on Docker
Expand Down
1 change: 1 addition & 0 deletions TeslaMateAgile.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeslaMateAgile", "TeslaMate
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2A3CD4EB-A93A-4D8F-9492-6C2140B3F1C6}"
ProjectSection(SolutionItems) = preProject
.github\workflows\build.yml = .github\workflows\build.yml
kube-deploy.yml = kube-deploy.yml
README.md = README.md
EndProjectSection
Expand Down
11 changes: 10 additions & 1 deletion TeslaMateAgile/OctopusOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ namespace TeslaMateAgile
public class OctopusOptions
{
[Required]
public string AgileUrl { get; set; }
public string BaseUrl { get; set; }

[Required]
public string ProductCode { get; set; }

[Required]
public string TariffCode { get; set; }

[Required]
public string RegionCode { get; set; }
}
}
2 changes: 1 addition & 1 deletion TeslaMateAgile/PriceHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public async Task Update()

private async Task<IOrderedEnumerable<AgilePrice>> GetAgilePrices(HttpClient httpClient, DateTime from, DateTime to)
{
var url = $"{_octopusOptions.AgileUrl}?period_from={from:o}&period_to={to:o}";
var url = $"{_octopusOptions.BaseUrl}/products/{_octopusOptions.ProductCode}/electricity-tariffs/{_octopusOptions.TariffCode}-{_octopusOptions.RegionCode}/standard-unit-rates?period_from={from:o}&period_to={to:o}";
var list = new List<AgilePrice>();
do
{
Expand Down
4 changes: 3 additions & 1 deletion TeslaMateAgile/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
}
},
"Octopus": {
"AgileUrl": "https://api.octopus.energy/v1/products/AGILE-18-02-21/electricity-tariffs/E-1R-AGILE-18-02-21-C/standard-unit-rates"
"BaseUrl": "https://api.octopus.energy/v1",
"ProductCode": "AGILE-18-02-21",
"TariffCode": "E-1R-AGILE-18-02-21"
}
}
6 changes: 6 additions & 0 deletions kube-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
type: Opaque
stringData:
connectionString: '{{connectionString}}'
regionCode: '{{regionCode}}'
---
apiVersion: apps/v1
kind: Deployment
Expand Down Expand Up @@ -35,3 +36,8 @@ spec:
value: '1'
- name: TeslaMate__Phases
value: '1'
- name: Octopus__RegionCode
valueFrom:
secretKeyRef:
name: teslamateagile-secrets
key: regionCode

0 comments on commit 3d733cf

Please sign in to comment.