-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pieter Verberck
committed
Mar 27, 2024
1 parent
b6ffe24
commit 63945ec
Showing
10 changed files
with
126 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package main | ||
|
||
import "log" | ||
|
||
func steerAssets(token string) { | ||
|
||
currentDateString := "" | ||
|
||
for { | ||
// Get date of current day | ||
currentHackathonTime := getCurrentHackathonTime(token) | ||
newDateString := getDateString(currentHackathonTime) | ||
log.Println("### Current time:", currentHackathonTime) | ||
|
||
// If start of new day (or need not set) | ||
if newDateString != currentDateString { | ||
log.Println("### Starting new day", newDateString) | ||
currentDateString = newDateString | ||
|
||
// Calculate or assume new need | ||
//need := 300 // kWh | ||
|
||
// Get day ahead time of new day | ||
dayAheadPricesJson := getDayAheadPrices(token, currentDateString) | ||
|
||
// Find roof of cheapest surface | ||
calculateRoofPricePerQuarter(dayAheadPricesJson) | ||
} | ||
|
||
// Get real-time price | ||
|
||
// If real-time price < roof => charge | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"log" | ||
"net/url" | ||
) | ||
|
||
func calculateRoofPricePerQuarter(dayAheadPricesJson string) { | ||
headers := map[string]string{} | ||
headers["Content-Type"] = "application/json" | ||
params := url.Values{} | ||
|
||
dataJson := fmt.Sprintf("{\"time_series_data\": %s, \"ev_comfort_charge_capacity_kwh\": %d, \"ev_max_charge_capacity_kwh\": %d, \"buffer\": %f}", | ||
dayAheadPricesJson, | ||
50, | ||
100, | ||
1.0) | ||
|
||
log.Println("calculateRoofPricePerQuarter") | ||
log.Println(dataJson) | ||
|
||
body, err := makeRequest("http://host.docker.internal:5001", "POST", "/calculate_roof_price_per_quarter", headers, params, bytes.NewBuffer([]byte(dataJson))) | ||
if err != nil { | ||
log.Fatal("Error on dispatching request. ", err.Error()) | ||
} | ||
|
||
log.Println(string(body)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"net/url" | ||
"os" | ||
) | ||
|
||
func getDayAheadPrices(token string, dateString string) string { | ||
headers := map[string]string{ | ||
"Authorization": "Bearer " + token, | ||
} | ||
|
||
params := url.Values{} | ||
|
||
params.Add("startDate", dateString+"T00:15:00+01:00") | ||
params.Add("endDate", getNextDay(dateString)+"T00:15:00+01:00") | ||
log.Println("getDayAheadPrices ", params) | ||
|
||
body, err := makeRequest(os.Getenv("TRAXES_API_BASE_URI"), "GET", "/prices/day-ahead-prices", headers, params, nil) | ||
if err != nil { | ||
log.Fatal("Error on dispatching request. ", err.Error()) | ||
} | ||
|
||
return string(body) | ||
|
||
/*var hackathonTimeResponse HackathonTimeResponse | ||
if err := json.Unmarshal(body, &hackathonTimeResponse); err != nil { | ||
log.Fatalln(err) | ||
}*/ | ||
|
||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters