Enphase Envoy with Energy Dashboard

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!

Hi @mvana, Which specific HASS integration are you referring to?
There are many to choose from:

briancmpbll/home_assistant_custom_envoy
posixx/home_assistant_custom_envoy (archived on Jul 14, 2023)
jrutski/home_assistant_envoy_d7_fw
DanBeard/enphase_envoy
jesserizzo/envoy_reader
vincentwolsink/home_assistant_enphase_envoy_installer

Also, please advise what type of CT clamp setup you have.

Here is mine for example.
image

Mine is net-consumption = Load with solar production.

image

There are subtle differences behind the scenes about how this works

net-consumption = Load with solar production example:

total-consumption = Load only example:

Regardless of your CT clamp location and setting, the integrations that I have tried to understand the code of, all appear to get their data from:
https://envoy.local/production.json
which indicates to me that the Envoy does the required calculations every time that production.json file is requested and also provides a universal total-consumption figure regardless of your ct clamp setting.
For that reason, I can see why this data source is attractive for the developers of Enphase Integrations as it is 1 less variable to worry about.

In the above example, my house is consuming 1604 W and exporting 4482 W to the grid which is indicated by the - in front of the net-consumption number.

Hi @del13r Thank you for the questions and pointers.
Regarding “what integration I have”: I didn’t install any specific integration so I assume this is a native HASS instance. The “documentation” link in the ‘Settings’ page sends me to

so that may be the answer(?)

The configuration seems to be almost identical to what you have:

[
    {
        "eid": 704643328,
        "state": "enabled",
        "measurementType": "production",
        "phaseMode": "split",
        "phaseCount": 2,
        "meteringStatus": "normal",
        "statusFlags": []
    },
    {
        "eid": 704643584,
        "state": "enabled",
        "measurementType": "net-consumption",
        "phaseMode": "split",
        "phaseCount": 2,
        "meteringStatus": "normal",
        "statusFlags": []
    }
]

==> net consumption as expected
As far as the production.json is concerned it may not be telling much as it is pitch black in California (after a gloomy day).
But I even had my Python running for about a year collecting data (prior Enphase pushing the Rev.7 that broke things).
Speaking of which: I didn’t figure out how to harvest the token out from HASS. Hass got the token behind the scenes and I never saw it. Now I requested a token manually and not sure if the token got refreshed - meaning the one HASS used got nixed, I git mine and next HASS will pull another one? (Once I will learn where is the configuration kept I can re-use the same token).
The production.json is below - but perhaps I should abandon this integration and jump to one (you are using?) that may be more configurable?

"varhLagToday":2005.339}],
    "consumption":[
        {
            "type":"eim",
            "activeCount":1,
            "measurementType":"total-consumption",
            "readingTime":1701660810,
            "wNow":732.977,
            "whLifetime":6552246.659,
            "varhLeadLifetime":4330031.39,
            "varhLagLifetime":1734763.269,
            "vahLifetime":14992275.247,
            "rmsCurrent":8.679,
            "rmsVoltage":233.239,
            "reactPwr":-458.684,
            "apprntPwr":2024.218,
            "pwrFactor":0.36,
            "whToday":11385.659,
            "whLastSevenDays":85490.659,
            "vahToday":14755.247,
            "varhLeadToday":5863.39,
            "varhLagToday":2015.269
        },{
            "type":"eim",
            "activeCount":1,
            "measurementType":"net-consumption",
            "readingTime":1701660810,
            "wNow":732.977,
            "whLifetime":3474246.404,
            "varhLeadLifetime":4245132.533,
            "varhLagLifetime":57212.93,
            "vahLifetime":14992275.247,
            "rmsCurrent":7.228,
            "rmsVoltage":233.31,
            "reactPwr":-297.737,
            "apprntPwr":838.929,
            "pwrFactor":0.87,
            "whToday":0,
            "whLastSevenDays":0,
            "vahToday":0,
            "varhLeadToday":0,
            "varhLagToday":0
        }
    ],

Thanks!

Hi @mvana, ah yes, you are correct, my apologies for the mix up

I was easily confused by HASS and I wrongly assumed you meant HACS.
HASS = Home Assistant (Native Integrations)
HACS = Home Assistant Community Store (3rd party repositories)

In answer to your question, the code for the native integration is found here.
homeassistant/components/enphase_envoy

I’m quite novice on python code, so unfortunately I can’t help you find where the token is stored.

At the moment, I am using my own solution via the rest sensor, originally because the native integration didn’t support d7 at the time, but now mainly so I can have efficient 10 second updates instead of 60 second updates. The downside is that it is slightly more complicated to setup than the native implementation and I have to manually refresh my token once a year.
Now that the native implementation supports token authentication, I recommend my solution less than the native one for general use.
I still also use the native Enphase integration for recording sensors like “today_s_energy_production” and “today_s_energy_consumption” so I can verify my figures against what the Envoy reports and also check in on the functionality of the native implementation.

One thing that I notice is that your Grid doesnt have an export sensor.
Is this on purpose?

Here is my config for comparison at https://homeassistant.local/config/energy

Mine is a bit more complicated as I have different costs at different times of the day but I recommend having at least an import (grid consumption) and export (return to grid) sensor as well as a production sensor.

I found where it might be stored in the code here

1 Like

The underlying issue I am fighting with is that I do not see the
https://homeassistant.local/config/energy you have shown.

What I have related in the '“config” is http://homeassistant.local:8123/config/entities
and I can see Envoy in integrations or devices
but I didn’t find any configurable properties.
Either I do not know where to look or it isn’t there(?)
May be the time to delete this (native?) integration and install the custom one.
Thanks!

Thanks for the Python pointer. Will look how to dump the key into the log file.

1 Like

Have you tried
http://homeassistant.local:8123/config/energy

Is there anything there that looks like my screenshot?

I recommend you stick with the native integration, because none of the enphase integrations will automatically provide you with import and export sensors because the envoy doesn’t supply import and export readings. This is a gap that home assistant needs to fill using calculations.

The only exception to this statement is
my own solution via the rest sensor which is not an integration, but simply a rest sensor that targets a different source of information than what the enphase integrations use.

For every enphase integration, native or hacs, the following needs to be done.

What you have to do is go to the first post at top of this article and follow the instructions using:

Step1. Template sensors to calculate power import and power export.

Step2. The integration sensor to convert instant power to energy over time.

Once you do those 2 steps, you should be able to choose the new energy sensors in the energy dashboard here

http://homeassistant.local:8123/config/energy

Hi @del13r , thank your for this awesome guide. Quick Question, I’m on latest everything. When I check my unit of measurement for _current_power_consumption and production, it is in kW by default.

Do I need to then change the unit_of_measurement in your template sensor to “kW”.?
If so, then do I also need to remove the unit_prefix of “k” in sensor platform?

Please if you can help / update?

Hmm, that is different to what I get.

My model is an envoy-s-metered-eu (env-s-wm-230). May I ask what model of envoy you have?

Also, are you using the native (built in) enphase integration or a home assistant community store repository (HACS)?

Yes, so they just installed mine 2 months ago and mine is env-iq-am1-240.
And I’m using the native built in new enphase integration.

I changed my YAML to say kW, and remove the prefix, but not sure if that is correct, hence asking you.

here is a screenshot

Was that via the GUI
image

Or via /homeassistant/customize.yaml
image

or did you have to write a new template sensor to divide by 1000W to get 1KW?

no sorry, I meant your code, where you have

unit_of_measurement: W
I changed it to
unit_of_measurement: kW

AND

where you had
unit_prefix: k
I removed that line.

So I don’t know if it will work correctly?

Let me rephrase question.
How should I re-write your code to support my situation, while keeping my defaults?

This code:

Looking at this screenshot, the W to kW conversion appears to be correct.

I would say yes to changing the unit_of_measurement in your template sensor to “kW".

looking at this link:
https://www.home-assistant.io/integrations/integration/#unit_prefix

It says the following:

unit_prefix string (optional, default: None)

Metric unit to prefix the integration result. Available units are k, M, G and T.

Given that statement, I would leave that line as it was with k as the unit_prefix.

Thanks, so that’s what I originally did.
Which is changed W to kW and left the prefix = k.
But then in the chart (graph), it would show kkW (it was adding that prefix).

So now, I just want to make sure I get correct calculus.
I can see the correct on enphase app.

ah ok, in that case, then remove the unit_prefix line