Enphase Envoy with Energy Dashboard

You can also use dev tools / templates to find out what the source sensors values are and also experiment with different calculations.

See this screenshot for example

Here is the example code to paste into the template editor

Power Production {{ states('sensor.power_production') }} W
Power Consumption {{ states('sensor.power_consumption') }} W
Power Export {{ [ 0,
  states('sensor.power_production') | int(0) -
  states('sensor.power_consumption') | int(0)
  ] | max }} W
Power Export {{ [ 0,
  states('sensor.power_production') | int(0) -
  states('sensor.power_consumption') | int(0)
  ] | max / 1000  }} kW
Power Import {{ [ 0,
  states('sensor.power_consumption') | int(0) -
  states('sensor.power_production') | int(0)
  ] | max }} W
Power Import {{ [ 0,
  states('sensor.power_consumption') | int(0) -
  states('sensor.power_production') | int(0)
  ] | max / 1000 }} kW

This code above assumes that your envoy is providing sensor values in Watts.

If you are like @mathieuruellan who claims that the envoy-S provides values in kW, then your template code will have to be like this instead.

Power Production {{ states('sensor.power_production') }} kW
Power Consumption {{ states('sensor.power_consumption') }} kW
Power Export {{ [ 0.0,
  states('sensor.power_production') | float(0) -
  states('sensor.power_consumption') | float(0)
  ] | max }} kW
Power Export {{ [ 0.0,
  states('sensor.power_production') | float(0) -
  states('sensor.power_consumption') | float(0)
  ] | max * 1000  }} W
Power Import {{ [ 0.0,
  states('sensor.power_consumption') | float(0) -
  states('sensor.power_production') | float(0)
  ] | max }} kW
Power Import {{ [ 0.0,
  states('sensor.power_consumption') | float(0) -
  states('sensor.power_production') | float(0)
  ] | max * 1000 }} W
1 Like

May I ask what model of Envoy you have?

Ways you can find this out:
Go to http://homeassistant.local:8123/config/devices/dashboard?domain=enphase_envoy

Go to https://envoy.local/home and scroll down to the part number

image

I don’t see where my mistake is
Here is My configuration.yaml:
template:

  • sensor:
    name: Grid Import Power
    state_class: measurement
    icon: mdi:transmission-tower
    unit_of_measurement: W
    device_class: power
    state: >
    {{ [0, states(‹ sensor.envoy_12230107xxxx_consommation_d_electricite_actuelle ›) | int(0) - states(‹ sensor.envoy_12230107xxxx_production_d_electricite_actuelle ›) | int(0) ] | max }}
  • sensor:
    name: Grid Export Power
    state_class: measurement
    icon: mdi:transmission-tower
    unit_of_measurement: W
    device_class: power
    state: >
    {{ [0, states(‹ sensor.envoy_122301076xxx_production_d_electricite_actuelle ›) | int(0) - states(‹ sensor.envoy_122301076xxx_consommation_d_electricite_actuelle ›) | int(0) ] | max }}

sensor:

  • platform: integration
    name: Grid Import Energy
    source: sensor.grid_import_power
    unit_prefix: k
    unit_time: h
    method: left
  • platform: integration
    name: Grid Export Energy
    source: sensor.grid_export_power
    unit_prefix: k
    unit_time: h
    method: left

Why don’t I see the sensor grid export in the energy panel?
I can see the Grid import


Hi @gregzila
Please do this step below.

Can you please post a screenshot of your equivalent “actuelle” sensor attributes so I can better help you?

I have explained this here

Also, how long have you had the sensor setup? If it’s less than 2 hours, then it probably hasn’t had time to run the statistics job yet.

This issue below might be related

I do not agree.
I do not see either of the Energy sensors in the dropdown list.
Please wait 2 hours for statistics job to run.

Also,

is it daytime there? It is possible that you may not see import statistics until night time when the sun stops shining.

Or

is it nighttime there? It is possible that you may not see export statistics until day time when the sun starts shining.

Hi @gregzila,
Just following up on how you went.
Were you eventually successful?

This looks great, thanks for the effort @Maart84.
I am trying to use this, but it looks like the associated javascipt is missing for this custom card from under <config>/www/bar-card.js
Do you know @Maart84 and @shanelord what could be causing the issue?
Thank you!

Hey all.

Is this information from the original post still current? It’s a couple years old.

Context: I got the Enphase integration working with Home Assistant, and it’s great, BUT I don’t think all the correct information I need is in the integration. I have Enphase batteries + solar.

For example, there is a sensor called

sensor.envoy_12210203XXXX_current_power_consumption

It looks like this isn’t actual power consumption, but consumption of my home PLUS the batteries filling up when solar is producing. Should I just create a helper that is the sum of all my battery inverters and subtract that from the sensor above?

Or… Should I just go to the first post and start doing everything in there? I’m just a bit nervous because it’s a couple years old, well before Enphase made their API changes w/ the token, etc.

Thanks!

Hi @hungarianhc, I do not have batteries myself but if I was to make an assumption, it would be that due to where the CT clamp is commonly installed, it is possible that when your battery is filling up, it is counted as house consumption due to the battery being no different to any other appliance in your house that consumes electricity, with the obvious exception that batteries can also supply electricity like your solar panels do. I would expect that the battery consuming the excess solar would be counted as part of the load/consumption.

For example, if I had a battery that needed topping up, I would expect the yellow highlighted part of the image below to go to the battery and show as orange/consumption rather than be exported shown as grey/export.

I’m guessing that you want to seperate the battery consumption from the rest of your house consumption?

@del13r , thank you for that. The only reason I think you may not be correct is that everything shows perfectly in the Enphase app, and that reads from the same CT clamps. I can see home consumption versus battery versus export, etc. It has been accurate and matched what my utility bill shows for a couple years. It’s really just the sensors themselves in Home Assistant that just don’t seem to be exact matches, with the exception of the solar production. That’s an exact match.

For example, at this very moment, it’s a bit cloudy outside, and my solar is only producing 2.9kW, and that’s accurately reflected in the Enphase app as well as in Home Assistant. Then when I look at my consumption in the Enphase app, I see that 1.2kW is going to my house, and 1.7kW is charging my batteries. However, sensor.envoy_1221020XXXXX_current_power_consumption in Home Assistant is showing the sum of house + battery.

I COULD manually create a helper that takes home consumption and subtracts battery inverter numbers, but that will get complicated when I’m running off battery, and not solar, in the evenings.

I assume that the enphase app might be showing information from multiple enphase devices that upload data to enphase in the cloud.
My understanding is that the enphase envoy only looks after solar and there might be another box that looks after your battery. You have not specifically said exactly which battery you have so I have to assume it might be the Enphase IQ gateway located inside the IQ system controller 3 INT?

Here is what that box does.

As the name of the sensor has the word envoy in it, could it be that it is only showing what the solar focussed envoy sees?

To confirm this, you can login to https://envoy.local and see what information is available there as that is pretty much the same place that the integration gets its information from.

I have Enphase batteries + Enphase solar. They all go into the same controller. I just logged into envoy.local (thanks for telling me about this!), and it’s showing the same information as I’m seeing on the Enphase app. Screenshot 2023-11-06 at 2.15.00 PM

There’s an exporting number it shows. There’s no “exporting” entity I can see in Home Assistant, so I wonder where it gets that, as an example. Do I need to calculate it manually?

Hi @hungarianhc,

I inspected the https://envoy.local/home using browser tools and found the json data source is [“consumption”][0][wNow] in the json tree at https://envoy.local/production.json?details=1

I then look at the code for the Native Enphase Integration at
https://github.com/home-assistant/core/blob/9c0bfc1b582e965ce236e2a02274a091f72e0be6/homeassistant/components/enphase_envoy/sensor.py

and it references pyenphase

from pyenphase import (
    EnvoyEncharge,
    EnvoyEnchargeAggregate,
    EnvoyEnchargePower,
    EnvoyEnpower,
    EnvoyInverter,
    EnvoySystemConsumption,
    EnvoySystemProduction,
)

Next I go to
https://github.com/pyenphase/pyenphase/blob/943204d96f268f3c4ec525612daae98aff35109d/src/pyenphase/models/system_consumption.py
and see the following references

# Data Source: URL_PRODUCTION
        """Initialize from the production API."""
      consumption = data["consumption"][0]
watts_now=int(round(consumption["wNow"]

So then I go to
https://github.com/pyenphase/pyenphase/blob/943204d96f268f3c4ec525612daae98aff35109d/src/pyenphase/const.py
which says

URL_PRODUCTION_JSON = "/production.json"
URL_PRODUCTION = "/production"

For me, this confirms that https://envoy.local/production.json is being used as a data source by the native enphase integration for sensors like house consumption and solar production.

I might be completely wrong as I am not that familiar with python programming, but I think I am on the right track at least.

I have a Tesla battery with Enphase micro inverters. This is my energy map. Right now the battery is at 50% and charging to 100%. But the system overall is in balance. No export to the grid as all power from solar is being used to run the house load and also charging the power wall battery.

Durring the night time I had minimal grid import to maintain the battery at 50% SOC and that was based on the Solcast forecast for my location today

Solcast:

1 Like

Hi @angusc,
Thanks for confirming that Telsa AC coupled batteries consume excess solar and this contributes to house load.

On another note, i’ve moved away from the
https://github.com/reptilex/tesla-style-solar-power-card
and am now using
https://github.com/flixlix/power-flow-card-plus
image

Yes ! it’s working

1 Like

Hi @hungarianhc,
The native Enphase integration still only provides 4 x consumption and 4 x production sensors named:
watt_hours_lifetime
watt_hours_last_7_days
watt_hours_today
watts_now

WattHours being Energy over time (like an odometer) and Watts being instantaneous Power (like a multi-meter).

In order to get the equivalent import and export sensors, you will still need to follow the now 2 years old instructions to get home assistant to calculate import and export by calculating the difference between consumption and production, and then also use the Riemann sum integral integration to record and convert Power/Watts to Energy/WattHours.

The only thing that has changed over those 2 years was the enforcement of the default values. For example, there may be times where I might have used int() or float() in my code and now have to use int(0) or float(0). That’s all I remember being different.

Another observation I noticed was that the screenshot that @angusc posted, his dashboard uses https://github.com/reptilex/tesla-style-solar-power-card which appears to subtract the 1.7 kW (battery charging) and 1.4 kW (car charging) from the 3.5 kW (solar production) leaving only 0.4 kW (house consumption), which appears to do exactly what you are asking for.

Meanwhile, his consumption graph above specifically reports consumption at 3.5 kW shown in orange which indicates both the battery, car and house load are all counted as consumption.

As I don’t have batteries, I am not sure if the native integration gives you an entity for the sum of your battery inverters. That may be the only thing you need to do if there is no native entity to represent your batteries.

The point I am trying to make here is, you may not need to make helper and subtract that from the consumption if there are lovelace cards that appear to be able to do that for you.

All you really need to do is have an entity for house consumption and another entity for the battery charging and reference them in of the HACS lovelace card addons below.

@angusc is using
https://github.com/reptilex/tesla-style-solar-power-card

whereas I am using
https://github.com/flixlix/power-flow-card-plus

Please bear with me: I am probably missing something fundamental:
I do not see any configuration options. I did roam through the main HASS .yaml file nd didn’t find anything relevant and do not see there a specific Enphase integration yaml(?) would be located.

Envoy let’s one install the consumption CT’s either on the

  1. “utility side” (measuring the actual difference between the house consumption and solar production -or-

  2. “load side” (measuring only the house consumption while the solar production has an independent path)

The design of the specific panel may - as it is in my case - preclude installation as per b) but Envoy get’s configured, does the math and all is fine.

Until the point when I start using the HASS integration that does the arithmetic in a way that assumes the load consumed both what Envoy reported as consumed by the load and wrongly adds the solar production to it.
In my actual example below:
Consumed = Produced + Imported
8.8 = 6.5 + 2.3 [kWh] (as correctly reported in Enphase app)

What the HASS integration shows is different (wrong):
15 = 8.6 + 6.4 [kWh] (taking the consumed power reported by Envoy as if it was all coming from the grid).
image

How do I fix the configuration? Thanks!