List NordPool electric prices using powershell.

This is a small script using nordpoolgroup api to get todays electric prices for Kr.sand – Norway. This is the same API as their webpage uses. All the urls and parameters can be found using developermode in the browser. This code is only to demonstrate that it can be done. It all started when i first saw the Homeassistant integration on github .

$today=Get-Date -Format "d-M-yyyy"
$url="" #23 = Hourly ,24 = Daily, 25 = Weekly, 26 = Monthly, 27 = Yearly

$response=Invoke-RestMethod -Uri $url
foreach ($row in ${ 
    $localrow= $row.Columns | Where-Object {($ -like "Kr.sand")} 
  [float]$cost=((($localrow[0].value).tostring()).Replace(' ','')).replace(',','.')
    Write-Output "$($datetime) - øre/kWh ink mva $([math]::round(($cost/10 * 1.25),2))"
    $prices+=[math]::round(($cost * 1.25),2)

$prices|Measure-Object -Average -Maximum -Minimum

Leave a Reply