PVOutput.org NodeRed

Hi Jeremy,

Here’s what I use to send data from emonCMS to PVOutput.org:

#!/bin/bash

PVO_API='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' #your PVOutput.org API key
PVO_SYSID='xxxxx' # your PVOutput.org system ID

FEED_ID_A='X' # id number of the feed you want to read data from
FEED_ID_B='X'

DATE=$(date "+%Y%m%d")
TIME=$(date "+%H:%M")

A=$(curl -s http://127.0.0.1/emoncms/feed/value.json?id=$FEED_ID_A)
B=$(curl -s http://127.0.0.1/emoncms/feed/value.json?id=$FEED_ID_B)

#A=$(wget -qO- http://127.0.0.1/emoncms/feed/value.json?id=$FEED_ID_A)
#B=$(wget -qO- http://127.0.0.1/emoncms/feed/value.json?id=$FEED_ID_B)

A=${A//\"} # strip quotes from json string
B=${B//\"}

curl -s -d "d=$DATE" -d "t=$TIME" -d "v2=$A" -d "v4=$B" -H "X-Pvoutput-Apikey: $PVO_API" \
-H "X-Pvoutput-SystemId: $PVO_SYSID" http://pvoutput.org/service/r2/addstatus.jsp

#wget --quiet --post-data "d=$DATE&t=$TIME&v2=$A&v4=$B" --header="X-Pvoutput-Apikey:$PVO_API" \
#--header="X-Pvoutput-SystemId:$PVO_SYSID" http://pvoutput.org/service/r2/addstatus.jsp

send-to-pvo.txt (959 Bytes)

As it sits, it uses curl to send the data. If you prefer to use wget, uncomment the wget lines and comment out the curl lines. Either work well, it’s a matter of personal choice.

Set up a cron job to run it every five minutes, and you should be good to go.