Enphase Envoy JSON reading issue

I’ve added my Enphase Envoy solar system to my HA installation, but it seems the readings are not correct. My JSON file is not what HA expects I believe. Today’s power consumption is negative (-5.29), production is negative, and total production is o. If I add all inverters as sensors separately then all sensors show the correct production readings.

In the JSON file under “production” there are two headers:
0: type “ïnverters” (wNow 109, whLifetime 3081204)
1: type “EIM” (wNow -5.29, whLifetime 0)

So it seems HA is reading the wrong production field. Anybody else having these issues? Or any ideas as to what I’m doing wrong? Any help is much appreciated! JSON attached below.

{"production":[{"type":"inverters","activeCount":12,"readingTime":1572881147,"wNow":109,"whLifetime":3081204},{"type":"eim","activeCount":0,"measurementType":"production","readingTime":1572881198,"wNow":-5.29,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":0.285,"rmsVoltage":242.249,"reactPwr":0.162,"apprntPwr":36.847,"pwrFactor":-0.19,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0}],"consumption":[{"type":"eim","activeCount":0,"measurementType":"total-consumption","readingTime":1572881198,"wNow":-16.119,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":-0.067,"rmsVoltage":242.651,"reactPwr":-0.162,"apprntPwr":-16.243,"pwrFactor":-1.0,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0},{"type":"eim","activeCount":0,"measurementType":"net-consumption","readingTime":1572881198,"wNow":-10.829,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":0.352,"rmsVoltage":243.052,"reactPwr":0.0,"apprntPwr":45.295,"pwrFactor":-0.35,"whToday":0,"whLastSevenDays":0,"vahToday":0,"varhLeadToday":0,"varhLagToday":0}],"storage":[{"type":"acb","activeCount":0,"readingTime":0,"wNow":0,"whNow":0,"state":"idle"}]}

In order to access those two fields, depending on how you’re receiving them, it would be something like

{%- set value_json = '{"production":[{"type":"inverters","activeCount":12,"readingTime":1572881147,"wNow":109,"whLifetime":3081204},{"type":"eim","activeCount":0,"measurementType":"production","readingTime":1572881198,"wNow":-5.29,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":0.285,"rmsVoltage":242.249,"reactPwr":0.162,"apprntPwr":36.847,"pwrFactor":-0.19,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0}],"consumption":[{"type":"eim","activeCount":0,"measurementType":"total-consumption","readingTime":1572881198,"wNow":-16.119,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":-0.067,"rmsVoltage":242.651,"reactPwr":-0.162,"apprntPwr":-16.243,"pwrFactor":-1.0,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0},{"type":"eim","activeCount":0,"measurementType":"net-consumption","readingTime":1572881198,"wNow":-10.829,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":0.352,"rmsVoltage":243.052,"reactPwr":0.0,"apprntPwr":45.295,"pwrFactor":-0.35,"whToday":0,"whLastSevenDays":0,"vahToday":0,"varhLeadToday":0,"varhLagToday":0}],"storage":[{"type":"acb","activeCount":0,"readingTime":0,"wNow":0,"whNow":0,"state":"idle"}]}' |from_json -%}

{% set inverters = value_json.production[0] %}
{% set eim = value_json.production[1] %}

inverters - wNow = {{ inverters.wNow }}, whLifetime = {{ inverters.whLifetime }}
EIM - wNow = {{ eim.wNow }}, whLifetime = {{ eim.whLifetime }}

Ignore the first line, that’s just to set up the JSON that you would have normally received in your automation or sensor, typically as value_json.

Also, could you post the YAML for your sensor or automation?

The YAML for the sensors is as follows:

# Enphase Envoy
sensor:
  - platform: enphase_envoy
    name: Zonnepanelen
    ip_address: 192.168.0.174
    monitored_conditions:
      - production
      - inverters
      - consumption
      - daily_consumption

Thanks for that @SteveDinn that really helps me on my way. Will continue playing around with this tomorrow but I think this should do the trick!

The enphase_envoy library retrieves data about inverters from a different JSON source (http://envoy/api/v1/production/inverters), not from the JSON you posted above.

Looking at your data, it is strange that the lifetime values are zero. Mine only go up and up. Also, negative values in current consumption (wNow) sound strange.

Do you have access to the Enphase web portal? If so, do the aggregated values for production and consumption make sense in there?

Thanks for the reply @exxamalte. http://envoy/api/v1/production/inverters is not accessible for me, login required. However http://envoy/api/v1/production is, returning the following data:

{
  "wattHoursToday": 207,
  "wattHoursSevenDays": 32088,
  "wattHoursLifetime": 3081431,
  "wattsNow": 126
} 

I don’t have acces to the Enphase webportal but I do have access via the android app, and all values look fine I can see production per day, week, livetime, etc. both total numbers as production per inverter. No cosumption values to be foudn however…

Username: envoy
Password: last 6 digits of serial number, found on the bottom of the device

Well what do you know…learned another thing today. Thanks! But how can the enphase_envoy library access that information without the password? Guess the serial number is retreived somewhere else.

I do have access to the envoy webpage turns out. Only production reports there, no comsumption and they look fine. Perhaps it’s an idea to use the Rest platform and the GET method to retreive the data, so I can specify with something like

value_template: '{{ "%.1f" | format(value_json.consumption[0].wNow) }}'

in order to retreive the correct values from the production.json file. Or even specify the http://envoy/api/v1/production file and retreive the data there.
Will check tonight if that works…

Yes, sorry, forgot to mention that there is a http://envoy/info.xml that contains the serial number that the integration uses to access that information.

I originally used rest sensors to retrieve the data: Electricity consumption and production – neon.ninja

@exxamalte or @SteveDinn Do either of you know what the difference is between an inverter and eim?

Looking at /production.json the values appear close but not the same.

For instance, the front html web page of Envoy-S running D5.0.34 firmware says Currently generating 3.69 kW, the /production.json shows inverters wNow at 3695 and eim wNow at 3629.987 and the /api/v1/production page shows wattsNow at 3695.

It seems the enphase_envoy library should be pulling the watts info from the inverter section of /production.json, but before making a change to the code I’m trying to understand what the difference between the inverter and eim are?

BTW, I don’t have direct access to an Envoy-S :disappointed: I only have access to the older oval Envoy running 3.x firmware.

Thanks for any input into this!
Greg

Not a clue :slight_smile: I can help you with your template, but I have no idea what the values mean.

After poking around I’m thinking the eim are the production and consumption CTs. Reading the Envoy-S documentation it appears there could be installed 3 CTs, one for monitoring the line going to the PV system and two for each of the 120V mains.

This could account for the slight difference between what the inverters are saying they are generating and what the production CT is reading.

Any thoughts?

@Oboema I think you are seeing negative values from wNow becase the Envoy-S system does not recognize some connection. Notice the activeCount is 0.

Edit: Nevermind, it appears the Envoy-S shows 0 for activeCount when the production/consumption meter is not configured through the device’s interface. It appears even when the activeCount is 0 it will still read from the CTs. Still unsure why a negative value would occur for the production CT, it should go from 0 to whatever the system is producing. The only thing I can think of would be the CT is on the wrong phase of the breaker, though if that was the case the value should just change from postive to negative and it should roughly match the inverter wNow measurement

Do you have CTs monitoring the breaker that is fed by the PV system and around the mains power? Is the eim for the production wNow value always a negative value, even after rebooting the Envoy-S?

Sorry, I haven’t really analysed all those values in details. I was just trying to reproduce what the built-in web UI shows.

Here is another interesting source where someone has been delving into the details:

Great! Thank you, I’ll take a look.

I have the exact same situation here with the Envoy, was there any solution in the end? :slight_smile:

@Flight777 This is what my code looks like. I used another file in the end, as suggested by @exxamalte

#se Envoy - Rest
sensor:
  - platform: rest
    name: solar production
    json_attributes:
      - wattHoursToday
      - wattHoursSevenDays
      - wattHoursLifetime
      - wattsNow
    resource: http://192.168.0.XXX/api/v1/production
  - platform: template
    sensors:
      solar_now_kw:
        friendly_name: "Solar current production"
        value_template: "{{ (states.sensor.solar_production.attributes['wattsNow'] | float / 1000 ) | round(3) }}"
        unit_of_measurement: 'kW'
      solar_today_kwh:
        friendly_name: "Solar Today"
        value_template: "{{ (states.sensor.solar_production.attributes['wattHoursToday'] | float / 1000 ) | round(1) }}"
        unit_of_measurement: 'kWh'
      solar_week_kwh:
        friendly_name: "Solar last 7 days"
        value_template: "{{ (states.sensor.solar_production.attributes['wattHoursSevenDays'] | float / 1000 ) | round(1) }}"
        unit_of_measurement: 'kWh'
      solar_lifetime_mwh:
        friendly_name: "Solar Lifetime"
        value_template: "{{ (states.sensor.solar_production.attributes['wattHoursLifetime'] | float / 1000000 ) | round(2) }}"
        unit_of_measurement: 'mWh'

That works for me, All values show up correctly now.

2 Likes

Hi Guys,

Just wanted to add a suggestion in this topic.
Does anyone tried to use this URL http://@IPEnvoy/stream/meter. to fetch the data from the counters in real time ?

This url is streaming each 1s a bloc of text with realtime production and consumption (even de ratio imported / exported) from the CT counters that comes with the Envoy Metered-s.

I will try to do it by my side under Nodered but I thought it would be great to have this in the Enphase Integration. Be glad to help too if a setup is needed for testing.

1 Like

I have tried the source above, but I get a login screen. I have Envoy-S Metered-EU with firmware R4.10.35. I am seeking access to the more detailed data through the local web interface. I have working:
http://ip/production.json
http://ip/production.json/details=1
http://ip/inventory.json
Do you know of any other local addresses that provide access to data, for instance per inverter: lifetime production, last seven days, today and now?

Have you tried http://<ip>/api/v1/production or http://<ip>/api/v1/production/inverters ?

Username: envoy
Password: last 6 digits of serial number, found on the bottom of the device