This is a simple powershell script using the API to get a csv file for daily summary data over a range of dates. That can then be imported into a spreadsheet
The summary data is Date,Solar,Import,Export,Consumption,Battery
At the moment one just edits the script to put in start date and number of days but that could be enhanced.
One needs to edit the $GivEnergyPortalAPI with your own apikey and $SerialNum with your own serial id
You then just right click the file and Run with Powershell
$GivEnergyPortalAPI = "apikey"
$SerialNum = "serialno"
$DateFirst = "2022-09-01"
$DatePick = $DateFirst
$DateCount = 30
$page = 1
$pageSize = 300
$DataPointsStr = "Date,Solar,Import,Export,Consumption,Batteryr`n"
########end user input#############
##Go Fetch Data Points##
$headers_Giv_En = @{
'Authorization'="Bearer $GivEnergyPortalAPI"
'Content-Type'='application/json'
'Accept'='application/json'
}
function GetDatePickData {
$Giv_En = Invoke-RestMethod -Method 'GET' -Uri https://api.givenergy.cloud/v1/inverter/$SerialNum/data-points/$DatePick"?"page=$page"&"pageSize=$pageSize -Headers $headers_Giv_En
$Giv_Obj = $Giv_En | ConvertTo-Json -depth 10 | ConvertFrom-Json
$last = $Giv_Obj.Data.Count - 1
$solar = $Giv_Obj.Data[$last].today.solar
$import = $Giv_Obj.Data[$last].today.grid.import
$export = $Giv_Obj.Data[$last].today.grid.export
$consumption = $Giv_Obj.Data[$last].today.consumption
$battery = $Giv_Obj.Data[$last].power.battery.percent
$parArray = @($DatePick,$solar,$import,$export,$consumption,$battery)
$ret = $parArray -join ","
return $ret + "`r`n"
}
for($index = 0; $index -lt $DateCount; $index++) {
Write-Output $DatePick
$DataPointsStr += GetDatePickData
$DateObj = [Datetime]:😛arseExact($DatePick, 'yyyy-MM-dd', $null)
$DateObj = $DateObj.AddDays(1)
$DatePick = $DateObj.ToString('yyyy-MM-dd')
}
$DataPointsStr | Out-File -FilePath .\DataPoints$DateFirst.txt
Write-Output "Data Saved to: DataPoints(Date).txt"
Write-Output "All done - Exit in 5...."
start-sleep -s 5
Exit `