Enphase - Envoy V7 local API to CURL-JSON on Windows

The final decision, with thanks to all who have had an input and @LORDUDE for his specific Enphase information, was to go down the HTTP Binding route. The two current transformers (CTs) in my system record production from the solar PV and net-consumption. The net-consumption is a negative value when power is being exported to the grid and positive when being imported from the grid. Both CTs report 3 phase values but only phase one has any real data and is not needed in my setup.

The URLs I have found to be most useful are:

  • Below gives EID of the (CTs) that are connected to the system
curl -f -k -H "Accept: application/json" -H "Authorization: Bearer YOUR TOKEN HERE" -X GET https://ENVOY IP HERE/ivp/meters
  • Below gives all values for enabled CT channels listed in previous request
curl -f -k -H "Accept: application/json" -H "Authorization: Bearer YOUR TOKEN HERE" -X GET https://ENVOY IP HERE/ivp/meters/readings
  • Below gives today, 7 days, lifetime, now Watt Hours production
curl -f -k -H "Accept: application/json" -H "Authorization: Bearer YOUR TOKEN HERE" -X GET https://ENVOY IP HERE/api/v1/production
  • Below gives today, 7 days, lifetime, now Watt Hours consumption
curl -f -k -H "Accept: application/json" -H "Authorization: Bearer YOUR TOKEN HERE" -X GET https://ENVOY IP HERE/api/v1/consumption
  • Gives cumulative production in WHs plus current production values
curl -f -k -H "Accept: application/json" -H "Authorization: Bearer YOUR TOKEN HERE" -X GET https://ENVOY IP HERE/ivp/meters/reports/production
  • Gives cumulative consumption in WHs plus current consumption values that the house load is using.
curl -f -k -H "Accept: application/json" -H "Authorization: Bearer YOUR TOKEN HERE" -X GET https://ENVOY IP HERE/ivp/meters/reports/consumption

Using the following Things, Items and Sitemap I think I have all the useful data I need. I will look to create some Rules to convert consumption values into cost and another to take production values away from net-consumtion (power to/from the grid) to give a house consumption value.

Although parts of the Enphase manual say that most data is updated every 5 minutes, using a refresh rate of 10 seconds to the binding gives new values that match the ‘live’ data in the Enphase app when querying /ivp/meters/readings. The data when querying api/v1/production doesn’t seem to change often so probably doesn’t get updated until each 5 minute cycle.

Solar_http.things

Thing http:url:sol_http "Solar HTTP" [
    baseURL="https://192.168.1.xxx/ivp/meters/readings",
    headers="Accept=application/json", "Authorization=Bearer eyJraxxx",
	refresh = "10",
	delay = "10",
	ignoreSSLErrors = "true",
	stateMethod = "GET",
	authMode = "BASIC" ]  {

	Channels:
		Type number : ACTPWR0 "ActivePower - Production" [ stateTransformation="JSONPATH:$.[0].activePower" ] 				
		Type number : VOLT0 "Voltage - Production" [ stateTransformation="JSONPATH:$.[0].voltage" ] 
		Type number : AMP0 "Current - Production" [ stateTransformation="JSONPATH:$.[0].current" ] 
		Type number : FREQ0 "Freq - Production" [ stateTransformation="JSONPATH:$.[0].freq" ]
		Type number : ACTPWR1 "ActivePower - Net-Consumption (GRID)" [ stateTransformation="JSONPATH:$.[1].activePower" ]
		Type number : VOLT1 "Voltage - Net-Consumption" [ stateTransformation="JSONPATH:$.[1].voltage" ]
		Type number : AMP1 "Current - Net-Consumption" [ stateTransformation="JSONPATH:$.[1].current" ]
		Type number : FREQ1 "Freq - Net-Consumption" [ stateTransformation="JSONPATH:$.[1].freq" ]
		Type number : ACTPWR00 "ActivePower - Prod PH 1" [ stateTransformation="JSONPATH:$.[0].channels[0].activePower" ]
		Type number : ACTPWR01 "ActivePower - Prod PH 2" [ stateTransformation="JSONPATH:$.[0].channels[1].activePower" ]
		Type number : ACTPWR02 "ActivePower - Prod PH 3" [ stateTransformation="JSONPATH:$.[0].channels[2].activePower" ]
}

Solar_http.items

Number   SolarHTTPACTPWR0    "Active power - Production [%d W]"     {channel="http:url:sol_http:ACTPWR0"}
Number   SolarHTTPVOLT0      "Voltage - Production [%d V]"          {channel="http:url:sol_http:VOLT0"}
Number   SolarHTTPAMP0       "Current - Production [%.2f A]"          {channel="http:url:sol_http:AMP0"}
Number   SolarHTTPFREQ0      "Freq - Production [%d Hz]"             {channel="http:url:sol_http:FREQ0"}
Number   SolarHTTPACTPWR1    "Active power - Net-Consumption (GRID) [%d W]"     {channel="http:url:sol_http:ACTPWR1"}
Number   SolarHTTPVOLT1      "Voltage - Net-Consumption [%d V]"          {channel="http:url:sol_http:VOLT1"}
Number   SolarHTTPAMP1       "Current - Net-Consumption [%.2f A]"          {channel="http:url:sol_http:AMP1"}
Number   SolarHTTPFREQ1      "Freq - Net-Consumption [%d Hz]"             {channel="http:url:sol_http:FREQ1"}
Number   SolarHTTPACTPWR00   "Active power - Prod PH01 [%d W]"     {channel="http:url:sol_http:ACTPWR00"}
Number   SolarHTTPACTPWR01   "Active power - Prod PH02 [%d W]"     {channel="http:url:sol_http:ACTPWR01"}
Number   SolarHTTPACTPWR02   "Active power - Prod PH03 [%d W]"     {channel="http:url:sol_http:ACTPWR02"}

Solar_apiv1_http.things

Thing http:url:sol_http_apiv1_prod "Solar HTTP API Production" [
    baseURL="https://192.168.1.xxx/api/v1/production",
    headers="Accept=application/json", "Authorization=Bearer eyJraxxx",
	refresh = "10",
	delay = "10",
	ignoreSSLErrors = "true",
	stateMethod = "GET",
	authMode = "BASIC" ]  {

	Channels:
		Type number : PROD_WH_DAY "WATT HOURS TODAY - Production" [ stateTransformation="JSONPATH:$.wattHoursToday" ] 			
		Type number : PROD_WH_7DAY "WATT HOURS LAST 7 DAYS - Production" [ stateTransformation="JSONPATH:$.wattHoursSevenDays" ]
		Type number : PROD_WH_LTIME "WATT HOURS LIFETIME - Production" [ stateTransformation="JSONPATH:$.wattHoursLifetime" ]
		Type number : PROD_WH_NOW "WATT HOURS NOW - Production" [ stateTransformation="JSONPATH:$.wattsNow" ]
}

Thing http:url:sol_http_apiv1_consum "Solar HTTP API Consumption" [
    baseURL="https://192.168.1.xxx/api/v1/consumption",
    headers="Accept=application/json", "Authorization=Bearer eyJraxxx",
	refresh = "10",
	delay = "10",
	ignoreSSLErrors = "true",
	stateMethod = "GET",
	authMode = "BASIC" ]  {

	Channels:
		Type number : CONSUM_WH_DAY "WATT HOURS TODAY - Consumption" [ stateTransformation="JSONPATH:$.wattHoursToday" ] 			
		Type number : CONSUM_WH_7DAY "WATT HOURS LAST 7 DAYS - Consumption" [ stateTransformation="JSONPATH:$.wattHoursSevenDays" ]
		Type number : CONSUM_WH_LTIME "WATT HOURS LIFETIME - Consumption" [ stateTransformation="JSONPATH:$.wattHoursLifetime" ]
		Type number : CONSUM_WH_NOW "WATT HOURS NOW - Consumption" [ stateTransformation="JSONPATH:$.wattsNow" ]
}

Solar_apiv1_http.items

Number   SolarPROD_WH_DAY    "WATT HOURS TODAY- Production [%d WH]"     {channel="http:url:sol_http_apiv1_prod:PROD_WH_DAY"}
Number   SolarPROD_WH_7DAY    "WATT HOURS LAST 7 DAYS - Production [%d WH]"   {channel="http:url:sol_http_apiv1_prod:PROD_WH_7DAY"}
Number   SolarPROD_WH_LTIME    "WATT HOURS LIFETIME - Production [%d WH]"   {channel="http:url:sol_http_apiv1_prod:PROD_WH_LTIME"}
Number   SolarPROD_WH_NOW     "WATT HOURS NOW - Production [%d WH]"          {channel="http:url:sol_http_apiv1_prod:PROD_WH_NOW"}

Number   SolarCONSUM_WH_DAY    "WATT HOURS TODAY- Consumption [%d WH]"     {channel="http:url:sol_http_apiv1_consum:CONSUM_WH_DAY"}
Number   SolarCONSUM_WH_7DAY    "WATT HOURS LAST 7 DAYS - Consumption [%d WH]"   {channel="http:url:sol_http_apiv1_consum:CONSUM_WH_7DAY"}
Number   SolarCONSUM_WH_LTIME    "WATT HOURS LIFETIME - Consumption [%d WH]"   {channel="http:url:sol_http_apiv1_consum:CONSUM_WH_LTIME"}
Number   SolarCONSUM_WH_NOW     "WATT HOURS NOW - Consumption [%d WH]"          {channel="http:url:sol_http_apiv1_consum:CONSUM_WH_NOW"}

solar_http.sitemap

sitemap solar_http label="Solar Values From Envoy"
{
Frame label="Solar - Grid Power Values" { 	
	Default item=SolarHTTPACTPWR0
	Default item=SolarHTTPVOLT0
	Default item=SolarHTTPAMP0
	Default item=SolarHTTPFREQ0
	Default item=SolarHTTPACTPWR1
	Default item=SolarHTTPVOLT1
	Default item=SolarHTTPAMP1
	Default item=SolarHTTPFREQ1
	Default item=SolarHTTPACTPWR00
	Default item=SolarHTTPACTPWR01
	Default item=SolarHTTPACTPWR02
}
Frame label="Solar - API V1 Values" { 
	Default item=SolarPROD_WH_DAY
	Default item=SolarPROD_WH_7DAY
	Default item=SolarPROD_WH_LTIME
	Default item=SolarPROD_WH_NOW
	Default item=SolarCONSUM_WH_DAY
	Default item=SolarCONSUM_WH_7DAY
	Default item=SolarCONSUM_WH_LTIME
	Default item=SolarCONSUM_WH_NOW	
}
}

solar_report_http.things

Thing http:url:sol_http_report_prod "Solar HTTP Report Production" [
    baseURL="https://192.168.1.xxx/ivp/meters/reports/production",
    headers="Accept=application/json", "Authorization=Bearer eyJraxxx",
	refresh = "10",
	delay = "10",
	ignoreSSLErrors = "true",
	stateMethod = "GET",
	authMode = "BASIC" ]  {

	Channels:
		Type number : PRODREP_CURRW "CURRENT WATTS - Production" [ stateTransformation="JSONPATH:$.cumulative.currW" ]		
		Type number : PRODREP_WHDLVDCUM "WATT HOURS CUMLATIVE - Production" [ stateTransformation="JSONPATH:$.cumulative.whDlvdCum" ]
}

Thing http:url:sol_http_report_consum "Solar HTTP Report Consumption" [
    baseURL="https://192.168.1.xxx/ivp/meters/reports/consumption",
    headers="Accept=application/json", "Authorization=Bearer eyJraxxx",
	refresh = "10",
	delay = "10",
	ignoreSSLErrors = "true",
	stateMethod = "GET",
	authMode = "BASIC" ]  {

	Channels:
		Type number  : CONSUMREP_AT_TIME "Report Created At - Consumption" [ stateTransformation="JSONPATH:$.[0].createdAt" ]
		Type number : CONSUMREP_CURRW "CURRENT WATTS - Consumption" [ stateTransformation="JSONPATH:$.[0].cumulative.currW" ]		
		Type number : CONSUMREP_WHDLVDCUM "WATT HOURS CUMLATIVE - Consumption" [ stateTransformation="JSONPATH:$.[0].cumulative.whDlvdCum" ]
}

solar_report_http.items

Number   SolarPRODREP_CURRW    "Report Current W - Production [%d W]"     {channel="http:url:sol_http_report_prod:PRODREP_CURRW"}
Number   SolarPRODREP_WHDLVDCUM "WATT HOURS CUMLATIVE - Production [%d WH]"     {channel="http:url:sol_http_report_prod:PRODREP_WHDLVDCUM"}

DateTime   SolarCONSUMREP_AT_TIME "Time report was taken - Consumption [%1$ta %1$tF %1$tT]"     {channel="http:url:sol_http_report_consum:CONSUMREP_AT_TIME"}
Number   SolarCONSUMREP_CURRW    "Report Current W - Consumption [%d W]"     {channel="http:url:sol_http_report_consum:CONSUMREP_CURRW"}
Number   SolarCONSUMREP_WHDLVDCUM "WATT HOURS CUMLATIVE - Consumption [%d WH]"     {channel="http:url:sol_http_report_consum:CONSUMREP_WHDLVDCUM"}
3 Likes