Enphase Envoy with Energy Dashboard

Fantastic, thank you for sharing!

Nice, but why does it require an installer account ? The regular Envoy integration (Briancmpbell version at least) exposes sensor.envoy_xxx_inverter_yyy already, and there is a sensor for power production sensor too. So, no installer account needed.

Ah I did not know that. Thanks for the addition.

Thanks to @Maart84 for this code - awesome stuff and appreciate you sharing.

With the newest firmware and official integration for Enphase Envoy, this code will work for the dashboard without an installer account. I’ve also split mine into East and West Panel sections - you can obtain this info from Enlighten/System/Devices if your installer labelled them in different arrays.

  • Make sure you insert your specific sensors.
  • Adjust your system max production (mine below is max: ‘10.4’) and I have my UoM as kW
  • Adjust your individual panel max output (mine below is max: ‘400’)
  • I’ve set columns to 7 & removed the fixed width to allow it to resize correctly on mobile
type: vertical-stack
cards:
  - type: custom:bar-card
    entities:
      - entity: sensor.envoy_12212204xxxx_current_power_production
    title: Enphase Panels
    max: '10.4'
    decimal: '2'
    unit_of_measurement: kW
    positions:
      name: 'off'
      indicator: inside
      icon: 'off'
    animation:
      speed: '5'
    style: |
      bar-card-currentbar, bar-card-backgroundbar { border-radius:5px; }
  - type: custom:bar-card
    title: East Panels
    entities:
      - entity: sensor.inverter_12213301xxxx
      - entity: sensor.inverter_12213301xxxx
      - entity: sensor.inverter_12213301xxxx
      - entity: sensor.inverter_12213301xxxx
      - entity: sensor.inverter_12213301xxxx
      - entity: sensor.inverter_12213302xxxx
      - entity: sensor.inverter_12213302xxxx
      - entity: sensor.inverter_12213302xxxx
      - entity: sensor.inverter_12213302xxxx
      - entity: sensor.inverter_12213302xxxx
      - entity: sensor.inverter_12213302xxxx
      - entity: sensor.inverter_12213302xxxx
      - entity: sensor.inverter_12213302xxxx
    positions:
      name: 'off'
      indicator: inside
    columns: 5
    direction: up
    max: '400'
    min: '0'
    animation:
      speed: '5'
    decimal: '0'
    icon: 'off'
    height: 100
#    width: 45px
    style: |
      bar-card-currentbar, bar-card-backgroundbar { border-radius:5px; }
  - type: custom:bar-card
    title: West Panels
    entities:
      - entity: sensor.inverter_12212304xxxx
      - entity: sensor.inverter_12212305xxxx
      - entity: sensor.inverter_12212305xxxx
      - entity: sensor.inverter_12212305xxxx
      - entity: sensor.inverter_12212306xxxx
      - entity: sensor.inverter_12212306xxxx
      - entity: sensor.inverter_12212306xxxx
      - entity: sensor.inverter_12212306xxxx
      - entity: sensor.inverter_12213301xxxx
      - entity: sensor.inverter_12213301xxxx
      - entity: sensor.inverter_12213301xxxx
      - entity: sensor.inverter_12213301xxxx
      - entity: sensor.inverter_12213301xxxx
    positions:
      name: 'off'
      indicator: inside
    columns: 5
    direction: up
    max: '400'
    min: '0'
    animation:
      speed: '5'
    decimal: '0'
    icon: 'off'
    height: 100
#    width: 45px
    style: |
      bar-card-currentbar, bar-card-backgroundbar { border-radius:5px; }
3 Likes

I’m having issues with this integration lately. The energy dashboard isn’t showing values correctly.

A second issue is that I tried to add the “corrected solar production” sensor, but I cannot add it to the “solar production” sensor in the dashboard. The “corrected solar production” sensor is appearing in the entities list, but is not seen by the dashboard.

- sensor:
    - name: Grid Import Power
      state_class: measurement
      icon: mdi:transmission-tower
      unit_of_measurement: W
      device_class: power
      state: >
        {{ [0, states('sensor.envoy_REDACTED1234_current_power_consumption') | int - states('sensor.envoy_REDACTED1234_current_power_production') | int ] | 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_REDACTED1234_current_power_production') | int - states('sensor.envoy_REDACTED1234_current_power_consumption') | int ] | max }}

- sensor:
  - name: Solar Power Corrected
    state_class: measurement
    icon: mdi:solar-panel
    unit_of_measurement: W
    device_class: power
    state: >
      {% set value = states('sensor.envoy_REDACTED1234_current_power_production') | int %}
      {% if value  <= 4 -%} 
        0
      {%- else -%}
        {{ value }}
      {%- endif %}

sensor:
  - platform: integration
    name: Grid Import Energy
    source: sensor.grid_import_power
    unique_id: grid_import_power
    unit_prefix: k
    unit_time: h
    method: left

  - platform: integration
    name: Grid Export Energy
    source: sensor.grid_export_power
    unique_id: grid_export_power
    unit_prefix: k
    unit_time: h
    method: left

  - platform: integration
    name: Solar Energy Corrected
    source: sensor.solar_power_corrected
    unique_id: solar_power_corrected
    unit_prefix: k
    unit_time: h
    method: left

As soon as my panels start producing, the consumption seems to track the production. Prior to the panels producing power, the consumption is accurate. So it seems there may be an issue with the calculations?

I also do not understand why the corrected solar production value isn’t able to be seen as an entity to enter into the energy dashboard.

Any help would be appreciated with understanding these two issues.

Just in case - when I moved from this integration GitHub - posixx/home_assistant_custom_envoy to HA’s official one, I had to modify the units for a couple of the Envoy entities to fix inaccurate calculations. I think it was megawatts instead of kilowatts or smth like that, which was causing weirdness in the Energy dashboard. A simple switch of the units in the UI helped.

1 Like

Do you happen to remember which entities? I’ve been struggling with this since I updated to the official HA integration for envoy. My solar production seems accurate, but my import and export energy is very wrong.

Could be the same issue, yep.
Check the measurements (in the UI) for sensors that are used by “Grid Import/Export Power” templates, for me those are:
sensor.envoy_xxxxx_current_power_consumption
sensor.envoy_xxxxx_current_power_production

both should be in watts, e.g.:

Also, sensor.envoy_xxxxx_lifetime_energy_production should be in MWh

Hello everyone
I have recently integrated my installation and I would like to know the value that I reinject into the network
but there is no attribute or sensor for that in enphase integration
I saw grid exports on this topic but I can’t find how to create this sensor without using configuration.yaml
I tell myself that I must be able to calculate it but I can’t do it
I went through all the forums and got help from chat-gpt but it was impossible
a kind soul to help me do this through a model?

I don’t know what this means.
Template sensors only exist within Home Assistant.

It sort of feels like the whole post has been written by chat-gpt to be honest. Your questions and phrasing do not make sense.

I don’t understand this statement either. Are you asking for help to do this via a large language model?

You could try adding a template helper via the GUI at http://homeassistant.local:8123/config/helpers

I just tried and got a result in the preview so it is possible to do via GUI.

First off, thanks for all your work!

I think I did this right (I am no stranger to sys admin, just to HA) but I am not seeing the entities upon restart. no errors I can find, just no visibility.

I have the following in enphase.yaml file…

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_202220131537_current_power_consumption') | int - states('sensor.envoy_202220131537_current_power_production') | int ] | 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_202220131537_current_power_production') | int - states('sensor.envoy_202220131537_current_power_consumption') | int ] | 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

This is in my main configuration.yaml


# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

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

enophase: !include enphase.yaml

Thanks for that @SenseiKen

Paste this into developer tools / template and see if you get anything there.

Here is what I get for example.

Note: you will only either be exporting or importing, but never both at the same time.

I am not familiar with this approach. I did notice a potential typo at the start being “enophase”

I checked the documentation at Splitting up the configuration - Home Assistant (but have not tested myself) and it would appear that template sensors can be defined in a split up configuration.

If i use this template :
template:

  • sensor:
    name: Grid Import Power
    state_class: measurement
    icon: mdi:transmission-tower
    unit_of_measurement: kW
    device_class: power
    state: >
    {{ [0, states(‘sensor.envoy_122301xxxxx_consommation_d_electricite_actuelle’) | int(0) - states(‘sensor.envoy_122301xxxxx_production_d_electricite_actuelle’) | int(0) ] | max }}
  • sensor:
    name: Grid Export Power
    state_class: measurement
    icon: mdi:transmission-tower
    unit_of_measurement: kW
    device_class: power
    state: >
    {{ [0, states(‘sensor.envoy_122301xxxxx_production_d_electricite_actuelle’) | int(0) - states(‘sensor.envoy_122301xxxxx_consommation_d_electricite_actuelle’) | int(0) ] | max }}

I have this result
template:

  • sensor:
    name: Grid Import Power
    state_class: measurement
    icon: mdi:transmission-tower
    unit_of_measurement: kW
    device_class: power
    state: >
    0
  • sensor:
    name: Grid Export Power
    state_class: measurement
    icon: mdi:transmission-tower
    unit_of_measurement: kW
    device_class: power
    state: >
    1

But is not ok the result of this templates is not good because the apps enphase give me 9.5kwh to production and 7.2kWh exported
have you any idea please ?

Thank you, I’m just discovering home assistant with my new enphase installation.
With envoy-S, Values are floats in kW. i had to adapt the initial template:

template:
  - sensor:
        name: Grid Import Power
        state_class: measurement
        icon: mdi:transmission-tower
        unit_of_measurement: W
        device_class: power
        state: >
             {{ [0.0, states('sensor.envoy_SN_current_power_consumption') | float(0) -  states('sensor.envoy_SN_current_power_production') | float(0)] | max * 1000 }}
  
  - sensor:
        name: Grid Export Power
        state_class: measurement
        icon: mdi:transmission-tower
        unit_of_measurement: W
        device_class: power
        state: >
            {{ [0.0, states('sensor.envoy_SN_current_power_production') | float(0) -  states('sensor.envoy_SN_current_power_consumption') | float(0)] | max * 1000 }}


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

Hello @gregzila

As @mathieuruellan has pointed out, either your choice to use kW instead of W for the unit of measurement is potentially causing home assistant to divide your output by 1000, or you may also have an envoy-S that allegedly provides values in kW.

Please go to developer tools / states and if you are French, type the following word into the Filter entities search bar:
actuelle
You will see the attributes of the sensor.

Here is what I see in English

Please take note of my “unit of measurement: W”.
Does the number in the state column have a decimal point?
Is your unit of measurement attribute the same as mine (W) or different (kW)?

In your calculations, if I take an integer/whole number (no decimal point/no floating point) like 1388 W and I choose to change the unit of measurement to kW, I would either get:
1.388 kW (floating point number with a decimal point)
or
1 kW (integer/whole number with no decimal point).

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