i am just a beginner and i have read hours of wiki and so on - but i still have a problem reading a json and show a value on a "utility".
I added a utlity named "PV" from Dummy , Type P1 Smart Meter.
In Events i created a LUA Script name "PVAktLeistung":
Code: Select all
json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()
local config=assert(io.popen('curl "http://10.0.0.241/solar_api/v1/GetInverterRealtimeData.cgi?Scope=Device&DeviceID=1&DataCollection=CommonInverterData"'))
local productie = config:read('*all')
config:close()
local jsonProductie = json:decode(productie)
PVakt = jsonProductie.Body.Data.PAC.Value
commandArray['PV'] = tostring(uservariables['PVakt'])
Code: Select all
{
"Head" : {
"RequestArguments" : {
"DataCollection" : "CommonInverterData",
"DeviceClass" : "Inverter",
"DeviceId" : "1",
"Scope" : "Device"
},
"Status" : {
"Code" : 0,
"Reason" : "",
"UserMessage" : ""
},
"Timestamp" : "2017-07-28T15:45:00+02:00"
},
"Body" : {
"Data" : {
"DAY_ENERGY" : {
"Value" : 9619,
"Unit" : "Wh"
},
"FAC" : {
"Value" : 49.99,
"Unit" : "Hz"
},
"IAC" : {
"Value" : 7.14,
"Unit" : "A"
},
"IDC" : {
"Value" : 2.83,
"Unit" : "A"
},
"PAC" : {
"Value" : 1666,
"Unit" : "W"
},
"TOTAL_ENERGY" : {
"Value" : 1445973,
"Unit" : "Wh"
},
"UAC" : {
"Value" : 233.9,
"Unit" : "V"
},
"UDC" : {
"Value" : 597.3,
"Unit" : "V"
},
"YEAR_ENERGY" : {
"Value" : 1445973.88,
"Unit" : "Wh"
},
"DeviceStatus" : {
"StatusCode" : 7,
"MgmtTimerRemainingTime" : -1,
"ErrorCode" : 0,
"LEDColor" : 2,
"LEDState" : 0,
"StateToReset" : false
}
}
}
}
2017-07-28 18:36:51.285 Error: EventSystem: in PVAktLeistung: /home/pi/domoticz/scripts/lua/JSON.lua:660: html passed to JSON:decode():
Access Error: Unauthorized
when trying to obtain Access to this document requires a User ID
The inverter is a Fronius Symo.