oem_gateway icon indicating copy to clipboard operation
oem_gateway copied to clipboard

Feature request: Add PVoutput.org buffer as an option to oem_gateway

Open nrgbod opened this issue 10 years ago • 2 comments

Would it be possible for someone to add PVoutput.org as an option in oemgateway. I am new to Python so it is above my head but basically we need to buffer four values from emontx_CT123_Voltage in pvoutput format and then send the average of these values plus time and date every 5 minutes to http://pvoutput.org/service/r2/addstatus.jsp

With V5 of emoncms I used the script below to format and send 5 minute snapshot data ie. not averaged, to pvoutput.org from Rpi............

#!/bin/bash
#
# A simple script to take a few numbers from emonTX and to
# upload them to www.pvoutput.org
#
# It is assumed emonTX is running emonTx_CT123_Voltage this
# then supplies the 4 input parameters required for this
# script
# $1 = CT1 power reading in Watts (To/From main grid supply)
# $2 = CT2 power reading in Watts (Generated  power)
# $3 = CT3 unused
# $4 = Voltage ( * 100)
#
# e.g. /bin/pvoutput -150 1500 0 24150
# is equivalent of exporting 150W generating 1.5kW voltage = 241.5
#

DUMP="PVOUTPUT="
for i in $*; do
   DUMP=$DUMP" "$i
done;

echo $DUMP >> /var/log/pvoutput.calls

NOISE=20
CT1=$1
CT2=$2

# if we are generating in the noise floor then simply exit
if [ "$CT2" -lt "$NOISE" ]
then exit

fi

VOLTS_UNITS=`expr $4 / 100`
VOLTS_FRACTION=`expr $4 % 100`
VOLTAGE=$VOLTS_UNITS"."$VOLTS_FRACTION

APIKEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  # Your API key
SYSID=xxxx  # System you wish to update
# ; http://pvoutput.org/service/r2/addoutput.jsp                                 
#  or http://pvoutput.org/service/r2/addstatus.jsp 

DATE=$(date +"%Y")$(date +"%m")$(date +"%d")
TIME=$(date +"%T")

GENERATED=$CT2
CONSUMPTION=$CT1
if [ "$CONSUMPTION" -lt 0 ]
then
    let "EXPORTED = 0 - $CONSUMPTION"
    let "CONSUMPTION  = $GENERATED - $EXPORTED"
else
    EXPORTED=0
    let "CONSUMPTION = $GENERATED + $CONSUMPTION"
fi

curl -s -d "d="$DATE -d "t="$TIME -d "v2="$GENERATED -d "v4="$CONSUMPTION -d "v6="$VOLTAGE -H "X-Pvoutput-Apikey: "$APIKEY -H "X-Pvoutput-SystemId: "$SYSID http://pvoutput.org/service/r2/addstatus.jsp

#
# For sanity sake, dump our data to a local log file in CSV format
#
CSVDUMP=/var/log/pvoutput.csv
if [ ! -e $CSVDUMP ]; then
    echo "Date,Time,Generated,Consumed,Exported,Voltage" >> $CSVDUMP
fi
echo $DATE","$TIME","$GENERATED","$CONSUMPTION","$EXPORTED","$VOLTAGE >> #$CSVDUMP
echo

nrgbod avatar Oct 11 '13 12:10 nrgbod