So, now that I'm getting ready to send data to a site, I have been playing with feeding variables into a url. This script modifies the PVOutput script so that the key and SID are pulled from variables.
- Code: Select all
import urllib2
import urllib
data = {}
data['key'] = (indigo.variables[775241456].value) #pvoutputKey
data['sid'] = (indigo.variables[1685522851].value) #pvoutputSID
url_values = urllib.urlencode(data)
url = 'http://pvoutput.org/service/r2/getstatus.jsp'
full_url = url + '?' + url_values
response = urllib2.urlopen(full_url)
f = response.read()
pv = f.split(",")
indigo.variable.updateValue(1920763080, value=str(pv[0])) # Date
indigo.variable.updateValue(1705190321, value=str(pv[1])) # Time
indigo.variable.updateValue(690513764, value=str(pv[2])) # Energy Generation
indigo.variable.updateValue(133349311, value=str(pv[3])) # Power Generation
indigo.variable.updateValue(1101260058, value=str(pv[4])) # Energy Consumption
indigo.variable.updateValue(1991582166, value=str(pv[5])) # Power Consumption
indigo.variable.updateValue(835833028, value=str(pv[6])) # Efficiency
indigo.variable.updateValue(74384762, value=str(pv[7])) # Temperature
indigo.variable.updateValue(114588059, value=str(pv[8])) # Voltage
response.close()
pvPowerGen = (int(indigo.variables[133349311].value))
pvPowerCon = (int(indigo.variables[1991582166].value))
pvNetPower = pvPowerGen - pvPowerCon
indigo.variable.updateValue(1894842094, value=str(pvNetPower))
pvEnergyGen = (int(indigo.variables[690513764].value))
pvEnergyCon = (int(indigo.variables[1101260058].value))
pvNetEnergy = pvEnergyGen - pvEnergyCon
indigo.variable.updateValue(326233494, value=str(pvNetEnergy))