Need testers for updated Enphase Envoy sensor

Can anyone confirm that the ‘current_energy_consumed’ is the sum of energy from all inputs? Grid, solar (and battery if you have one) and therefore total grid energy used is that figure - the figure from the current_energy_production sensor?

@Stubbs From what I’ve seen the Consumption data that is retrieved from the Envoy is the sum of all energy that is flowing into panel. Though there are two different configurations I have seen on Envoys, as you can read below.

EDIT: I found this document I guess the Consumption CTs can be installed differently which can effect what total means to your system. Enphase Consumption Monitoring

Net Consumption versus Total Consumption
....
• Net - If the solar production CT is installed on the load side of the consumption CTs, then you can leave the consumption meter set as Net.
• Total - If the solar array is line side connected or if the solar production CT is installed on a separate circuit from the consumption CTs, then select Total.

I don’t have an Envoy that supports Consumption but looking into the code and seeing what is returned by various Envoys from http://x.x.x.x/production.json I have seen two different data structures being returned. One structure was only one consumption value
{"production":[{"type":"inverters","wNow":59,"whLifetime":25137952.8325,"readingTime":1608318607,"activeCount":35},{"type":"eim","activeCount":1,"whLifetime":47578.252,"whLastSevenDays":351.252,"whToday":30.252,"wNow":-0.049,"rmsCurrent":0.28,"rmsVoltage":248.877,"reactPwr":0.899,"apprntPwr":34.795,"pwrFactor":-0.0,"readingTime":1608318607}],"consumption":[{"type":"eim","activeCount":0,"whLifetime":0,"whLastSevenDays":0,"whToday":0,"wNow":0,"varhLeadToday":0,"varhLagToday":0,"vahToday":0,"varhLeadLifetime":0,"varhLagLifetime":0,"vahLifetime":0,"rmsCurrent":0,"rmsVoltage":0,"reactPwr":0,"apprntPwr":0,"pwrFactor":0}]}

and another was two sets of values; total and net.
{"production":[{"type":"inverters","activeCount":26,"readingTime":1608317131,"wNow":6,"whLifetime":7998977},{"type":"eim","activeCount":0,"measurementType":"production","readingTime":1608317143,"wNow":0.0,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":4.312,"rmsVoltage":242.022,"reactPwr":-506.461,"apprntPwr":521.678,"pwrFactor":0.0,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0}],"consumption":[{"type":"eim","activeCount":0,"measurementType":"total-consumption","readingTime":1608317143,"wNow":0.0,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":4.566,"rmsVoltage":242.05,"reactPwr":506.461,"apprntPwr":1105.183,"pwrFactor":0.0,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0},{"type":"eim","activeCount":0,"measurementType":"net-consumption","readingTime":1608317143,"wNow":0.0,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":0.254,"rmsVoltage":242.077,"reactPwr":0.0,"apprntPwr":30.767,"pwrFactor":0.0,"whToday":0,"whLastSevenDays":0,"vahToday":0,"varhLeadToday":0,"varhLagToday":0}],"storage":[{"type":"acb","activeCount":0,"readingTime":0,"wNow":0,"whNow":0,"state":"idle"}]}

I don’t know if the difference is configuration, hardware, or firmware. On your Envoy if you open a browser to the URL I mentioned above (replacing x.x.x.x with your IP Address) you will see the data being returned. If you have two Consumption parts then they should have a measurementType of total-consumption for the first and net-consumption for the second. Though if you only have one Consumption section then I do not know if it’s total or net, but it would be helpful to let me know what if it’s total or net in your installation. To easily read JSON data, I copy and paste it into http://jsonviewer.stack.hu/

I have seen a request to have the integration in Home Assistant give total and net consumption data. That is being worked on in an indirect way, moving the setup and configuration from text configuration (configuration.yaml) to the Home Assistant UI (Config Flow) which should give the user the option to select what conditions they want to monitor.

I know long answer!

One more update, hopefully the last one. Than PR #42857 should be approved and merged maybe at some point after the holidays.

The change made should be background operations and no functional change. It was to make sure no HTTP requests were made when updating Home Assistant entity info. The only HTTP requests that should be made are in different methods

The updated files are located here: sensor.py and manifest.json

Last changes working fine here. :slight_smile:

Looking at my production.json I’m getting both total & net, I guess I need to wait for daylight to go & see if I can work out what the CTs are attached to.

Just wanted to give an update on the progress of the changes.

The main PR #42857 as well PR #44600 have been merged into the dev branch in Home Assistant. I don’t know when they will get released, but I suspect being so close to the 2021.1 release, that it probably won’t be until the 2021.2 release. The changes will be released in the 2021.1 release.

PR #42857 - Reduces HTTP calls made to the Envoy devices
PR #44600 - Fixes an issue seen when retrieving inverter data from firmware <3.9 that don’t support inverter data gathering

The updated files are located at sensor.py and manifest.json

3 Likes

Just installed this. Awesome work. I’ve been wanting to get my inverter data into HA for a while now, but haven’t been bothered to do anything about it. I’m currently using REST sensors to get the data on production, total consumption, and net consumption.

I noticed some chat above about the net consumption data. So, this is being worked on, and will be available when it’s merged for the next release?

@cjsimmons Thank you!

The next step is to migrate from the configuration.yaml to Configuration Flow UI configuration. Once that is done than adding new sensors such as net consumption, 3phase info, battery info, etc… shouldn’t be too hard as long as the data is available from the Envoy device.

I was hoping to have something for the Configuration Flow by next weekend. :crossed_fingers:

1 Like

No worries. Keep up the good work. Good to see someone updating the Enphase intergration. I haven’t ever used it and just used REST sensors. Your update seems to be doing a good job over the last few hours.

Sorry for such a rookie question…but I’m a rookie…where do I paste this code? I’d much rather read my envoy data in kW. Thank you.

@robschwandt No problem! Paste the code into your configuration.yaml. Then from Home Assistant >> Configuration >> Server Controls click on the button to make sure your yaml file is valid. Than restart the server and you’ll have a sensor with kW.

1 Like

So I have the standard code from the home assistant page for envoy(ip address and the variables I want to track). So delete all that and paste this instead?

Oh no. No this is in addition. What you are doing is creating another sensor using a template.

If your configuration.yaml file does not have a sensor: section you can paste it at the bottom of your file.

If you do have a sensor: section than you’ll have to paste in that area omitting sensor: as your file already has it

Just tried it…this is what happens when I check the yaml:
image

Here’s my whole yaml file:


# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

#sensors
sensor:
  - platform: enphase_envoy
    ip_address: 192.168.86.187
    monitored_conditions:
      - production
      - daily_production
      - consumption
      - daily_consumption
  - platform: template
      sensors:
        envoy_current_energy_production_kw:
          friendly_name_template: 'Envoy Current Energy Production (kW)'
          unit_of_measurement: 'kW'
          value_template: "{{ (states('sensor.envoy_current_energy_production')| float / 1000| round(2)) }} "

I think the spacing is a bit off, sensors and the rest below looks to be indented a few spaces too much. Should be like this

  - platform: template
    sensors:
      envoy_current_energy_production_kw:
        friendly_name_template: 'Envoy Current Energy Production (kW)'
        unit_of_measurement: 'kW'
        value_template: "{{ (states('sensor.envoy_current_energy_production')| float / 1000| round(2)) }}"

EDIT: My original post had spacing issues too. Fixed now!

It worked! And now I’ve learned spacing is important! Thank you.

I’d love to use this! Where do I copy and paste this code? I’m a noob to HA and Lovelace. Thank you for your help.

Hi there,

Maybe start by reading the opening thread, it is possible to get everything working from there. Once you copy the code in to your configuration.yaml file and have installed the Enphase integration it will work.

I really set up a new page on my dab board and then added the inverters and other Enphase data as per the below:

Have a go and then come back with any questions…


Thank you very much!
I now have 3 more questions! :upside_down_face:

  1. I’d like to add a “Net Energy Value” as an entity in my lovelace card. I tried writing my own yaml math, but it’s not working. YAML attached.
  2. I’d like to make that “Net Energy Value” either red or green based on if it’s positive or negative value
  3. I’d like to use the gauge card for my “Net Energy Value” that sits in the middle of the gauge to represent 0, move left and make it red for negative values, move right and green for a positive number.
  - platform: template
    sensors:
      envoy_current_energy_production_kw:
        friendly_name_template: 'Envoy Current Energy Production (kW)'
        unit_of_measurement: 'kW'
        icon_template: mdi:lightning-bolt
        value_template: "{{ (states('sensor.envoy_current_energy_production')| float / 1000| round(2)) }}"
      envoy_current_energy_consumption_kw:
        friendly_name_template: 'Envoy Current Energy Consumption (kW)'
        unit_of_measurement: 'kW'
        icon_template: mdi:battery-medium
        value_template: "{{ (states('sensor.envoy_current_energy_consumption')| float / 1000| round(2)) }}"
      envoy_today_s_energy_production_kw:
        friendly_name_template: 'Envoy All Day Energy Production (kW)'
        unit_of_measurement: 'kW'
        icon_template: mdi:lightning-bolt-outline
        value_template: "{{ (states('sensor.envoy_today_s_energy_production')| float / 1000| round(2)) }}"
      envoy_today_s_energy_consumption_kw:
        friendly_name_template: 'Envoy All Day Energy Consumption (kW)'
        unit_of_measurement: 'kW'
        icon_template: mdi:battery-medium
        value_template: "{{ (states('sensor.envoy_today_s_energy_consumption')| float / 1000| round(2)) }}"
      envoy_net_energy_value_kw:
        friendly_name_template: 'Envoy Net Energy Value (kW)'
        unit_of_measurement: 'kW'
        icon_template: mdi:battery-heart-variant
        value_template: "{{ (states('envoy_today_s_energy_production_kw') - states('envoy_today_s_energy_consumption_kw')| float / 1000)| round(2) }}"

Thank you all for your help!

Hi there,

I’m new to HA too so I can’t help with the coding and any non standard dashboard cards…but I can help with the icon:

icon_template: hass:flash

It will be interesting to see the code required for the “swing o meter”

If you select a gauge card from the dash board editor then set a minus number range up to 0 you can choose the green, then for 0 to xxxx you can choose either yellow our red range. See below:

1 Like