#!/bin/sh # # fslurp, Copyright (c) 2012-2013 David Stone # # $RCSfile: fslurp2pvoutput.sh,v $ # $Revision: 1.1 $ # $Date: 2013/04/20 21:04:49 $ # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both the # copyright notice and this permission notice appear in supporting # documentation. No representations are made about the suitability of this # software for any purpose. It is provided "as is" without express or # implied warranty. # # # Sample script to fetch current daily total KWH production and send it # to pvoutput.org. # # To use, update the PVAPIKey, PVSystemID, FSlurp, and CURL variables below PVAPIKey=add key here PVSystemID=add system id here # Location of fslurp FSlurp=./fslurp # Location of curl CURL=/usr/bin/curl ####################################### ServiceURL=http://pvoutput.org/service/r2/addstatus.jsp Header1="X-Pvoutput-Apikey: $PVAPIKey" Header2="X-Pvoutput-SystemId: $PVSystemID" # Options for the report from fslurp Delimiter=, # fslurp report field delimiter FSlurpOptions="-p /dev/ttyUSB0" FSlurpOptions="${FSlurpOptions} -t %Y%m%d,%H:%M" # format date as YYYYMMDD FSlurpOptions="${FSlurpOptions} -r all" # Use day report FSlurpOptions="${FSlurpOptions} -d $Delimiter" # Use delimited report # Get the data from fslurp reportOutput=`$FSlurp $FSlurpOptions ` #if the inverter is off skip doing the update if [ "$reportOutput" != "" ]; then echo $reportOutput Date=`echo $reportOutput | cut -d$Delimiter -f1` Time=`echo $reportOutput | cut -d$Delimiter -f2` Power=`echo $reportOutput | cut -d$Delimiter -f6` Generated=`echo $reportOutput | cut -d$Delimiter -f12` # Convert KilowattHour data from Inverter to WattHour data. # changed fslurp code from get thoundsands value to get value to be in Wh #Generated="${Generated}000" # if overflow is the current value send 0 if [ "$Power" = 'overflow' ]; then Power="0" fi CURLData= CURLData="${CURLData} -d d=$Date" CURLData="${CURLData} -d t=$Time" CURLData="${CURLData} -d v1=$Generated" CURLData="${CURLData} -d v2=$Power" $CURL -H "$Header1" -H "$Header2" $CURLData $ServiceURL fi