Add output to PVOutput with Powershell

Add output to PVOutput with Powershell

In this article, we will see how to setup your PVOutput account in order to add output to PVOutput with Powershell.

I found a ton of info on how to add Ouput to PVOutput with curl, but nearly nothing (as I needed it) for Powershell. No wonder why I received a couple of questions on this.

If you’re the owner of a GoodWe inverter, take a look at Get GoodWe data with Powershell.

I don’t want to go too deep, so in this article I will just explain how to send data to your own system on PVOutput and how to set up the account to be able to do so.

Set your PVOutput account

In order to make API calls to PVOutput, against your system, you’ll need to enable API Access and generate a new API Key. You will also need the System Id you want to manage.

This is super easy as it’s all located in the same area of the account settings.

  • Login to PVOutput
  • Click Settings
  • Scroll at the bottom and:
    • Enable API Access
    • Click New Key to generate a new Key
    • Write down your system ID
    • Save

That’s it! We’re ready to send data to our system.

Note: Before proceeding, make sure your system is correctly set up. You need to ensure you’ve added the right amount of solar panels as well as the correct Watt hour or else you may end up receiving errors.

A very simple script

So, this script is very simple and will just show you how to send your system’s outputs to PVOutput. I strongly recommend adding a Try/Catch to make sure you Catch any error (so that you can also set up an alert, perhaps with Telegram: Automating Telegram Messages with Powershell) and, most importantly, you want to automatically get the date, time etc automatically (look at Get GoodWe data with Powershell to see how I grabbed these info from my inverter).

#List of fields available: https://pvoutput.org/help.html#api-addstatus

$PVOutputAPIKey = "YOUR_API_KEY"
$PVOutputSystemID = 12345

$PVOutputURL = "https://pvoutput.org/service/r2/addstatus.jsp"

$Date = "20180403"
$Time = "16:55"
#Watt hour generated so far today
$EnergyGeneration = "14600"
#Current Power generation in Watt
$PowerGeneration = "3010"
#Current system temperature in Celsius
$Temperature = "36.8"

#Add all parameters to a variable, these will be linked to the URL
$PVOutputParams = "d=$($Date)&t=$($Time)&v1=$($EnergyGeneration)&vs=$($PowerGeneration)&v5=$($Temperature)"

#Add the Headers for the request (they'll include the API Key and the System ID)
$PVOutputHeaders = @{"X-Pvoutput-Apikey" = $PVOutputAPIKey; "X-Pvoutput-SystemId" = $PVOutputSystemID}

#Build the full URI for the request
$PVOutputFullURI = "$($PVOutputURL)?$($PVOutputParams)"

#Finally send the request
$PVOutputInvokeResult = Invoke-WebRequest -Uri $PVOutputFullURI -Method Post -Headers $PVOutputHeaders

Super easy! You can add more functionalities, like I said above. One of them could also be checking for the Content (or Status/Description) that will be held in $PVOutputInvokeResult:

Have fun 🙂

IT Droplets

IT Droplets