Enphase Envoy with Energy Dashboard

I have started another topic for the costings as it is very large and still a work in progress

see

Wow - great work! You have a real knack in explaining things logically and as simply as possible. I’ll have to decide whether to go the whole hog with your new stuff for more future-proofing, or use the existing stuff in this thread (because it is very similar to my current plan).

Any chance you could address the other two minor queries in my previous reply to you?

1 Like

Hi @Sddawson, Thanks for the compliment. I guess we have all been there when you need to solve a problem and the available information is vague. I try to not be so vague in order to help people :slight_smile:

Was it these questions you meant?

The customize.yaml just changes how its displayed to the user.
Behind the scenes, its all still based on the actual name.
This way, the exclusions in recorder are still respected and any other sensors that reference the original name are not upset.

Correct, its the same formula for the per minute sensor as it is for the per second sensor. The only difference is that im not recording and graphing the per second results. I am purely using the per second results for real time dashboard.

For reference here is my per minute sensor that is recorded and graphed per minute

  - sensor:
        name: Instant Cost Per Hour
        state_class: measurement
        unit_of_measurement: AUD
        device_class: monetary
        state: >
            {% set hourly = 0.7400 / 24 %}
            {% set gridout = states('sensor.grid_export_power') | int %}
            {% set gridin = states('sensor.grid_import_power') | int %}
            {% if gridout > 0 %}
              {{ ((gridout/1000) * states('sensor.tariff_price_export') | float + hourly) | round(2) }}
            {% else %}
              {{ ((gridin/1000) * states('sensor.tariff_price') | float + hourly) | round(2) }}
            {% endif %}

Here is my per second sensor that is not recorded or graphed at all

  - sensor:
        name: mqtt_Instant Cost Per Hour
        state_class: measurement
        unit_of_measurement: AUD
        device_class: monetary
        state: >
            {% set hourly = 0.7400 / 24 %}
            {% set gridout = states('sensor.MQTT_Export_Power') | int %}
            {% set gridin = states('sensor.MQTT_Import_Power') | int %}
            {% if gridout > 0 %}
              {{ ((gridout/1000) * states('sensor.tariff_price_export') | float + hourly) | round(2) }}
            {% else %}
              {{ ((gridin/1000) * states('sensor.tariff_price') | float + hourly) | round(2) }}
            {% endif %}

Perfect, thanks for that @del13r. Really looking forward to implementing the costings!

1 Like

Not sure if it was mentioned. I just set this up and I had to use | abs to get absolute values on my consumption, otherwise it added consumption and production together with this:

{{ [0, states('sensor.envoy_xxxx_current_power_production') | int - states('sensor.envoy_xxxx_current_power_consumption') | int ] | max }}

Lets break down the formulas to their most basic point.

You will notice the minus symbol in the middle of the 3 lines of template code in the images below.
This is meant to subtract production from consumption to calculate grid export.

This positive result on the right shows that I am producing 727 W more than what I am consuming and therefore exporting 727 W of excess power TO the grid.

This negative result on the right shows that I am consuming more than I am producing and therefore pulling 23 W of power FROM the grid.

I don’t want this negative number to be recorded in my grid export sensor as I have a different grid import sensor to record that.

The images above have the same formula in each screenshot.

{{
states('sensor.envoy_SERIALNUMBER_current_power_production') | int
-
states('sensor.envoy_SERIALNUMBER_current_power_consumption') | int
}}

All I have done is added this extra formula below to ignore any negative number below 0.

{{
[0, 
states('sensor.envoy_SERIALNUMBER_current_power_production') | int
-
states('sensor.envoy_SERIALNUMBER_current_power_consumption') | int
] | max
}}

In plain english, the first bit of the code is saying here are 2 numbers [0 and 727] for example.
The last bit of the code is saying only record the bigger number between [0 and 727].
If the number is -23 for example, then it will only record 0 instead as that is the bigger number (max).

This code is what make it possible for me to have 1 sensor for grid export and another separate sensor for grid import.

If you want ‘consumption’ you are focusing on the wrong sensor.

This is the grid import ONLY (excess consumption) sensor.
Only this sensor will show grid consumption.

The code you have posted …

… is from my export ONLY (excess production) and therefore you will see 0 instead of the actual consumption amount. This is by design and intentional in order to separate grid import and grid export into 2 different sensors.

I’m just saying, in my envoy installation, current power consumption is a negative number, so you are subtracting a negative number, minus and minus is plus, so it got added. Which is why I had to take the absolute value to make the subtraction work.

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_xxx_current_power_consumption') | int | abs - states('sensor.envoy_xxx_current_power_production') | int | abs ] | 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_xxx_current_power_production') | int | abs - states('sensor.envoy_xxx_current_power_consumption') | int | abs ] | max }}

Interesting, I’ve been following this thread for a bit, and just got my enphase envoy activated this week.

When using the provided templates + sensors as-is from #1, I always get 0 values.

In debugging further, it seems the raw data I am getting from the envoy is incorrect, as my consumption and production values are always identical, which explains the zeroing out values.

Template Editor

{% set production_life = states('sensor.envoy_SERIAL_lifetime_energy_production') | int %}
{% set consumption_life = states('sensor.envoy_SERIAL_lifetime_energy_consumption') | int %}
Production Life = {{ production_life }}
Consumption Life = {{ consumption_life }}
Net Life = {{ production_life - consumption_life }}

{% set production_current = states('sensor.envoy_SERIAL_current_power_production') | int %}
{% set consumption_current = states('sensor.envoy_SERIAL_current_power_consumption') | int %}
Production Current = {{ production_current }}
Consumption Current = {{ consumption_current }}
Net Current = {{ production_current - consumption_current }}

{% set production_today = states('sensor.envoy_SERIAL_today_s_power_production') | int %}
{% set consumption_today = states('sensor.envoy_SERIAL_today__power_consumption') | int %}
Production Today = {{ production_today }}
Consumption Today = {{ consumption_today }}
Net Today = {{ production_today - consumption_today }}

Results:

Production Life = 101059
Consumption Life = 101059
Net Life = 0

Production Current = 1010
Consumption Current = 1010
Net Current = 0

Production Today = 0
Consumption Today = 0
Net Today = 0

I’m now wondering if our system was installed incorrectly. Also when browsing http://envoy.local I do see a warning that consumption metering is not enabled (only production metering is enabled) but I called and asked my solar installer and they said to ignore that. Perhaps I need to reach out to enphase support?

Edit - sorry my bad Consumption is negative and production positive …

Your installer doesn’t know what they are doing. You have to have that saying it’s enabled otherwise it’s not doing anything. Use the installer password generator from my GitHub and enable it yourself.

Enphase dashboard looks fine, I guess they just correct the data to make sense on their backend?

The absolute value tweak is good enough for me :wink:

Also, these values make sense to me, right now at night

image

I have 938W consumption, and a negative production (they always draw 1W at night)

And during the day, the dashboard shows a nice positive production when the sun is shining.

What does this page show when you login? https://enlighten.enphaseenergy.com/

Is your production blue and above the line?

If you have it like that; it meant that your consumption metering was not enabled. That is the same issue i’m having and i called my installer about that, he told me in order to have that enable, he will charge me $500.00 US.

If you paid for consumption monitoring then you don’t need to pay for it again …

You’re a bit confused about the templates - one measures how much you export - for that you subtract consumption from production - you only export if you generate more than you consume. If you apply ABS to that calculation, it will never calculate export correctly. The templates as suppled are correct and don’t need ABS … I did modify mine though as I removed INT since INT rounds to nearest whole number and I want mine to be more accurate.

Can’t find the exact same view, but it looks like this:

In the iOS app I have bars:

Does this sensor ever go positive in the day?

image

I only ask because the other 3 production sensors show a positive number

image

As for production figures and night time, mine show +4 Watts at night which is simply not possible.
Your system is appears to be doing a very similar thing, but is instead showing a negative 1 at night.
Personally, I felt this skewed my figures and I went out of my way to correct this in this post Enhpase Envoy on 2021.8 with new Energy feature - #3 by del13r

Yes, right now it is positive (296W). And Power Consuption is also positive (916W).

So with the | abs my sensors read:
Grid Import Power 620W
Grid Export Power 0W

Other than your production showing -1W only at night time, what is the exact problem that abs is supposed to fix?

If you are concerned that you can no longer see any negative production at night time, then I don’t understand why that would be a concern or why you would want to see and keep that erroneous information.

Also, if the panels were ‘drawing’ power at night time, shouldn’t that just be counted as consumption?

In theory, if you are measuring production with let’s say an odometer, odometers are only meant to increase. Your production going minus at night is the equivalent to trying to drive a car in reverse to wind the odometer back. This is why I wrote post 3 to zero out any erroneous figures at night when the sun isn’t shining so I can record more accurate figures.

My position is that production should not be anything other than 0 at night time. If the panels were drawing power, the only place they can get power is from the grid and therefore that would be represented as house consumption.

I have done a test with dev tools and my code still works even when your production is -1W.

template:
  - sensor:
        name: Grid Import Power
        state_class: measurement
        icon: mdi:transmission-tower
        unit_of_measurement: W
        device_class: power
        state: >
            {{ [0,
              500 | int
              -
              -1 | int
              ] | max }}

In the test above, to simulate your situation, I have replaced the house consumption sensor with 500W and the solar panel production sensor with -1W.
My code has seen your -1W and added it to the 500W to make 501W (see result on right of image below).
So essentially, it has seen what you think is the panels drawing 1W of power and counted it as grid consumption. I see no problem here.

If this extra watt being added to your grid import at night time is bothering you, then I suggest you go and look at post 3 of this thread and zero out your night time production figures.

See Enhpase Envoy on 2021.8 with new Energy feature - #3 by del13r