I have an Enphase Envoy hub for my solar PV system and I’m trying to get the local data into openHAB 3 running on Window 10.
I have the CURL command and token part working and if I run the following in an elevated Windows command prompt I get an output:
curl -f -k -H "Accept: application/json" -H "Authorization: Bearer eyJra***" -X GET https://192.168.1.***/ivp/meters/readings
{
"eid": 70***,
"timestamp": 1681544341,
"actEnergyDlvd": 151670.391,
"actEnergyRcvd": 0.000,
"apparentEnergy": 175245.540,
"reactEnergyLagg": 31045.032,
"reactEnergyLead": 0.094,
"instantaneousDemand": 2276.366,
"activePower": 2276.366,
"apparentPower": 2276.366,
"reactivePower": 85.737,
"pwrFactor": 1.000,
"voltage": 248.142,
"current": 9.176,
"freq": 50.000,
"channels": [
{
"eid": 17***,
"timestamp": 1681544341,
"actEnergyDlvd": 151670.391,
"actEnergyRcvd": 0.000,
"apparentEnergy": 175245.540,
"reactEnergyLagg": 31045.032,
"reactEnergyLead": 0.094,
"instantaneousDemand": 2276.366,
"activePower": 2276.366,
"apparentPower": 2276.366,
"reactivePower": 85.737,
"pwrFactor": 1.000,
"voltage": 248.142,
"current": 9.176,
"freq": 50.000
},
{
"eid": 17***,
"timestamp": 1681544341,
"actEnergyDlvd": 78.489,
"actEnergyRcvd": 0.000,
"apparentEnergy": 206.950,
"reactEnergyLagg": 14.369,
"reactEnergyLead": 0.059,
"instantaneousDemand": 0.100,
"activePower": 0.100,
"apparentPower": 0.987,
"reactivePower": 0.000,
"pwrFactor": 0.000,
"voltage": 6.227,
"current": 0.158,
"freq": 50.000
},
{
"eid": 17***,
"timestamp": 1681544341,
"actEnergyDlvd": 0.000,
"actEnergyRcvd": 59.741,
"apparentEnergy": 94.512,
"reactEnergyLagg": 14.336,
"reactEnergyLead": 0.035,
"instantaneousDemand": 0.000,
"activePower": 0.000,
"apparentPower": 0.435,
"reactivePower": -0.000,
"pwrFactor": 0.000,
"voltage": 3.308,
"current": 0.132,
"freq": 50.000
}
]
},
{
"eid": 70***,
"timestamp": 1681544341,
"actEnergyDlvd": 60008.786,
"actEnergyRcvd": 79539.115,
"apparentEnergy": 233910.345,
"reactEnergyLagg": 32.593,
"reactEnergyLead": 149246.902,
"instantaneousDemand": -1196.775,
"activePower": -1196.775,
"apparentPower": 1354.263,
"reactivePower": -440.696,
"pwrFactor": -0.881,
"voltage": 248.214,
"current": 5.458,
"freq": 50.000,
"channels": [
{
"eid": 17***,
"timestamp": 1681544341,
"actEnergyDlvd": 60008.786,
"actEnergyRcvd": 79539.115,
"apparentEnergy": 233910.345,
"reactEnergyLagg": 32.593,
"reactEnergyLead": 149246.902,
"instantaneousDemand": -1196.775,
"activePower": -1196.775,
"apparentPower": 1354.263,
"reactivePower": -440.696,
"pwrFactor": -0.881,
"voltage": 248.214,
"current": 5.458,
"freq": 50.000
},
{
"eid": 17***,
"timestamp": 1681544341,
"actEnergyDlvd": 0.000,
"actEnergyRcvd": 600.245,
"apparentEnergy": 0.790,
"reactEnergyLagg": 14.147,
"reactEnergyLead": 0.013,
"instantaneousDemand": 0.000,
"activePower": 0.000,
"apparentPower": -0.000,
"reactivePower": -0.000,
"pwrFactor": 0.000,
"voltage": 1.192,
"current": -0.000,
"freq": 50.000
},
{
"eid": 17***,
"timestamp": 1681544341,
"actEnergyDlvd": 0.000,
"actEnergyRcvd": 798.429,
"apparentEnergy": 194.534,
"reactEnergyLagg": 14.156,
"reactEnergyLead": 0.000,
"instantaneousDemand": -0.585,
"activePower": -0.585,
"apparentPower": 0.917,
"reactivePower": 0.000,
"pwrFactor": 0.000,
"voltage": 4.946,
"current": 0.186,
"freq": 50.000
}
]
}
]
Looking at various other posts I can either:
- Run the CURL command in a .rule and store the output into a STRING to be processed by JASONPATH transformation. I have so far:
rule "Solar Test Rule"
when
Item Solar_test received command ON
then
var String test = executeCommandLine(Duration.ofSeconds(5), "curl","-f","-k","-H","Accept: application/json","-H","Authorization: Bearer eyJra***","-X","-G", "https://192.168.1.***/ivp/meters/readings")
logInfo("Log", test)
end
When I run the .rule by switching the ‘Solar_test’.item to ON (auto OFF after 1 second) I get:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 183 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (22) The requested URL returned error: 500
- Another post looks to use a .thing and batch file. I have tried:
Thing exec:command:solar_readings [command='"G:"\"openHAB"\"conf"\"scripts"\"solar_readings_curl.bat", interval=900, timeout=30, autorun=true']
which has the following in the batch file:
curl -f -k -H "Accept: application/json" -H "Authorization: Bearer eyJra***" -X GET https://192.168.1.***/ivp/meters/readings
and I get:
2023-04-15 08:54:01.975 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'solar_test.things' has errors, therefore ignoring it: [1,44]: Character array is missing "e" notation exponential mark.
I don’t know if the .thing route is the best way to go?
- Most people suggest putting the CURL commands in a batch file and running that from within a .rule and running the transformation in the rule. As I’m on Windows, I’m struggling to get the .bat file to output into a temporary variable for openHAB to process.
My .bat files contains:
@echo off
SET Solar_panel_reading=curl -f -k -H "Accept: application/json" -H "Authorization: Bearer eyJra***" -X GET https://192.168.1.***/ivp/meters/readings
echo Solar_panel_reading is: %Solar_panel_reading%
but all that gets printed is the curl request, not the output.
Can anyone please help as to the best direction to take and assist in the correct syntax etc?