Enphase Envoy with Energy Dashboard

@alexeiw123 - you can limit or exclude entities from being recorded in your database - this is the file that stores your data and it can grow very big with one second updates from the mqtt sensors - mine grew to over 2Gb before I took action. Following is an extract from my configuration.yaml -

Notes -
purge_keep_days limits how many days of history your database holds
auto_purge will automatically delete history older than purge_keep_days
the Exclude section won’t record any history for those entities (although they are still recorded in the Energy graph section)


recorder:
  purge_keep_days: 10
  auto_purge: true
  exclude:
    entities:
      - sensor.consumption_electricity_counter
      - sensor.consumption_electricity_gauge
      - sensor.exporting
      - sensor.exporting_mqtt
      - sensor.importing
      - sensor.importing_mqtt
      - sensor.mqtt_consumption
      - sensor.mqtt_production
      - sensor.solar_electricity_counter
      - sensor.solar_electricity_gauge
      - sensor.solarpower
      - sensor.solarpower_mqtt
      - sensor.import_delta
      - sensor.mqtt_voltage
      - sensor.mqtt_power_factor

Hope that helps?

3 Likes

Yes, this helps immensely - I’m learning a lot. It lead me to read Recorder - Home Assistant which also had a tonne of useful information. It may be worth adding this as an important consideration in your add-on documentation?

It’s very interesting that the energy dashboard can plot data that isn’t recorded in the database. It must be storing the sensor data as 1 hour averages somehow seperately. Quite handy.

Yes I’m planning to update the documentation shortly

1 Like

I spent some time sorting out my entities that need to be recorded and those that don’t.
I’m getting 1m data using the built in enphase integration and using that for the energy dashboard and historicals. I’m also using your add on to calculate 1s ‘real-time’ costs, but also to plot my 3 phase voltages. I’ve minised the entities I’m recording and keeping an eye on my database size. Thanks for your help.

is there any way to obtain hourly net balancing energy?

Has anyone figured out how to make it work with more recent software versions which I think require a JWT token that’s obtained through https://entrez.enphaseenergy.com ? (Which by the way only seem to last an hour though Enphase says they last 6 months)

That’s the only way I have of accessing the local API, AFAIK with a gateway running D7.0.85 (e269f2) (20 Oct, 2021 1:44 PM)

Example of where to get 6 month token.
Just need to replace SERIALNUMBER with your serial number https://enlighten.enphaseenergy.com/entrez-auth-token?serial_num=SERIALNUMBER

That’s awesome, I didn’t know of that. Sure enough, @del13r, 6 months token. Where would you use that in the Enlighten integration with HomeAssistant?

BTW, when I use it with curl, I still get a 401, any idea why?

curl -f -k -H 'Accept: application/json' -H 'Authorization: Bearer eyJr[...]3Xnsg' -X GET https://10.0.0.149/api/v1/production/inverters

Hi, sadly that is the limit of my knowledge with this as I am lucky enough to be on the old v5 firmware. There is a bit of a long running thread here regarding it https://support.enphase.com/s/question/0D53m00006ySLuRCAW/unimpressed-with-loss-of-local-api-connectivity-to-envoys

I’ve noticed recently that my Solar Forecast has a super high peak at the end of the day when using Solar Energy Corrected. I can fix this by using a damping factor of 0.25 in the Forecast.solar integration, but this makes the forecast shift a bit. I’m just being too nitpicky, but was wondering if other’s are seeing this.

Mine looks ok

Hi everybody, i need help for my poor skill in templating.
I have an enphase integration for the production/consume side and a Huawei solar integration for the battery (in Italy enphase batteries are not imported yet so i installed as retrofit a huawei inverter with its batteries). The huawei inverter is linked to enphase in AC and act only for charge/discharge the batteries.
From huawei integration i have a sensor.charge_discharge_power with positive values when charges and negative on discharges, it’s a power sensor in W
From enphase integration:

  1. sensor.envoy_XXXXXXXXX_current_power_consumption, power sensor in W

  2. sensor.envoy_XXXXXXXXXXXX_current_power_production, also in W

My idea is creat a chart with over 0 in Y there are the sources of power so import, solar production and battery discharge; below 0 there are the uses of power so export, home consumption, battery charge.
I think need these sensors:

  • a sensor like sensor.envoy_XXXXXXXXX_current_power_consumption but negative because i’d like see consumption below 0 in a Y axis in the chart.

  • a sensor like sensor.charge_discharge_power but inverted, with charge value positive and discharge negative.

  • a sensor.import_from_grid. it should be = sensor.envoy_XXXXXXXXX_current_power_consumption - sensor.envoy_XXXXXXXXXXXX_current_power_production + sensor.charge_discharge (remember that it is negative when battery discharges so sum to a negative value will be a minus). This value should be only positive.

  • a sensor.export_to_grid. it should be = sensor.envoy_XXXXXXXXXXXX_current_power_production - sensor.envoy_XXXXXXXXX_current_power_consumption - sensor.charge_discharge (remember that it is positive when battery charges). This value should be only negative.

Import and export sensors should have a treshold somewhere around 50 w because the readings of production and consumption are simultaneous instead of the value of charge_discharge sensor that has a different timing. So, for example, in night when the power is supply only from the buttery and it should be equal to consumption, there is always a little difference that should be readed as an importation or exportation of power.

My skill with templates are too poor for the tasks so i beg for an help. Sorry also for my english
Thank

Hi @dragorex71

Checkout my part here and also the entire thread from beginning gives you a lot of information for seeing up EnPhase and the home assistant energy dashboard: Enhpase Envoy on 2021.8 with new Energy feature - #492 by angusc

Edit: Sorry I used wrong link, now corrected.

Here is an example where I had a sensor reporting a positive number but I wanted it t obe a negative and also the opposite:

sensor:
# Corrected from MQTT 485 data
    - name: "Sofar Charge/Discharge Power 485 MQTT corrected"
      value_template: >
        {{ (states('sensor.battery_power_mqtt') | float(0) * -1) }}
      unit_of_measurement: W

# Corrected from SolarmanPV data
    - name: "Sofar Battery Power Corrected"
      value_template: >
        {{ (states('sensor.sofar_battery_power') | float(0) * -1) }}
      unit_of_measurement: W
1 Like

Thanks @angusc, i was able to write almost all the sensor except this function: “Import and export sensors should have a treshold somewhere around 50 w”.
My sensor now are:

      - name: Import potenza
        unit_of_measurement: W
        device_class: power
        state: >-
          {{ [0, states('sensor.envoy_XXXXXXXXXX_current_power_consumption') | float - states('sensor.envoy_XXXXXXXXXX_current_power_production') | float + states('sensor.charge_discharge_power') | float] | max }}
      - name: Export potenza
        unit_of_measurement: W
        device_class: power
        state: >
          {{ [0, states('sensor.envoy_XXXXXXXXXX_current_power_production') | float - states('sensor.envoy_XXXXXXXXXX_current_power_consumption') | float - states('sensor.charge_discharge_power') | float] | max }}

What is missing is that if the value is below 50 the value is 0.
I tried to inspiring from @del13r configuration

- 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_SERIALNUMBER_current_power_production') | int %}
            {% if value  <= 4 -%}
              0
            {% elif is_state('sun.sun','below_horizon') %}
              0
            {%- else -%}
              {{ value }}
            {%- endif %}

deleting the elif part but in my sensor the value is the result of an operation and i am unable to write it correctly.

Hi @dragorex71

I plays with the templates in the Developer template section of my HA, are you sure your envot production sensor is called “power” and not “energy”?

{% set value = states('sensor.envoy_12201xxxxxxx_current_energy_production') | int(default=0) %}
            {% if value  <= 4 -%}
              0
            {% elif is_state('sun.sun','below_horizon') %}
              0
            {%- else -%}
              {{ value }}
            {%- endif %}

For me this Energy Difference Sensor works well, it is reading + value when importing power from the grid and a - value when Exporting from the grid… Also the icon is templated to change with Grid import or export

sensor:
- platform: template
  sensors:
      inst_energy_difference:
        friendly_name: Instant Energy Difference
        icon_template: >
          {% if (states("sensor.inst_energy_difference") | int(default=0) > 0) -%} 
            mdi:solar-panel
          {%- elif (states("sensor.inst_energy_difference") | int(default=0) < 0) -%}
            mdi:transmission-tower
          {%- else -%}
            mdi:power-off
          {%- endif %}
        friendly_name_template: >
          {% if (states("sensor.inst_energy_difference") | int(default=0) > 0) -%} 
            Currently Exporting
          {%- elif (states("sensor.inst_energy_difference") | int(default=0) < 0) -%}
           Currently Importing
          {%- else -%}
            Balanced
          {%- endif %}
        unit_of_measurement: "W"
        device_class: power
        value_template: >
          {{ '%0.1f' | format(states('sensor.envoy_xxxxxxxxxxxx_current_energy_production') | float(default=0) - states('sensor.envoy_xxxxxxxxxxxx_current_energy_consumption') | float(default=0)) }}

This is the output from the above three templates for “Instant Energy Difference” for me right now:
image

What is the purpose for that 50w threshold? I see up a sensor for solar “awake” and solar “sleeping” and set that to operate when production was below 30w. Then I can use that sensor in certain automatons that I only want to trigger when the solar is awake.

sensor:
- platform: template
  sensors:
      enphase_status:
        friendly_name: EnPhase Status
        value_template: >
          {% if (states("sensor.envoy_12201xxxxxxxx_current_energy_production") | int(default=0) < 30) -%} 
            Sleep
          {% elif (states("sensor.envoy_12201xxxxxxx_current_energy_production") | int(default=0) > 29) -%} 
            Wake     
          {%- endif %}
        icon_template: >
          {% if (states("sensor.envoy_1220xxxxxxx_current_energy_production") | int(default=0) < 30) -%} 
            mdi:weather-night
          {% else %}
            mdi:solar-power
          {%- endif %}

Yes, my sensors are ‘power’.
I need two different sensors for Energy dashboard that has two entries.
For the purpose make an example:
Import= consumption-production-discharge_battery
During night of course production=0 and the battery_discharge = consumption so import should be 0.
But battery_discharge value is supplied from a different integration (Huawei solar) then consumption (enphase integration) so there is almost always a little (few W) difference.
But few W for days became kW so now my import sensor reports kWh of value when in this period i am totally self-sufficient.
So the idea to set a threshold

@dragorex71

Here are my HA Energy Dashboard settings and sensors that can then appear in the Energy dashboard:

import_export_meters.yaml

utility_meter:
  daily_energy:
    source: sensor.grid_import_energy
    name: Daily Import Meter
    cycle: daily
    tariffs:
      - peak
      - go

  daily_energy_export:
    source: sensor.grid_export_energy
    name: Daily Export Meter
    cycle: daily
    tariffs:
      - export

sensors_home_assistant_energy.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_12201xxxxxxx_current_energy_consumption') | int(default=0) - states('sensor.envoy_12201xxxxxxx_current_energy_production') | int(default=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_12201xxxxxxx_current_energy_production') | int(default=0) - states('sensor.envoy_12201xxxxxxx_current_energy_consumption') | int(default=0) ] | max }}

  - sensor:
        name: Solar Power Corrected
        state_class: measurement
        icon: mdi:solar-panel
        unit_of_measurement: "kW"
        device_class: power
        state: >
            {% set value = (states('sensor.envoy_12201xxxxxxx_current_energy_production') | float(default=0) /1000) | round(2)  %}
            {% if is_state('sensor.enphase_status', "Sleep")%}0{%else%}{{ value}}{%endif%}

import_export_sensors.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_12201xxxxxxx_current_energy_consumption') | int(default=0) - states('sensor.envoy_12201xxxxxxx_current_energy_production') | int(default=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_12201xxxxxxx_current_energy_production') | int(default=0) - states('sensor.envoy_12201xxxxxxx_current_energy_consumption') | int(default=0) ] | max }}

  - sensor:
        name: Solar Power Corrected
        state_class: measurement
        icon: mdi:solar-panel
        unit_of_measurement: "kW"
        device_class: power
        state: >
            {% set value = (states('sensor.envoy_12201xxxxxxx_current_energy_production') | float(default=0) /1000) | round(2)  %}
            {% if is_state('sensor.enphase_status', "Sleep")%}0{%else%}{{ value}}{%endif%}

enphase_status_sensor.yaml

sensor:
- platform: template
  sensors:
      enphase_status:
        friendly_name: EnPhase Status
        value_template: >
          {% if (states("sensor.envoy_12201xxxxxxxx_current_energy_production") | int(default=0) < 30) -%} 
            Sleep
          {% elif (states("sensor.envoy_12201xxxxxxx_current_energy_production") | int(default=0) > 29) -%} 
            Wake     
          {%- endif %}
        icon_template: >
          {% if (states("sensor.envoy_1220xxxxxxx_current_energy_production") | int(default=0) < 30) -%} 
            mdi:weather-night
          {% else %}
            mdi:solar-power
          {%- endif %}

My power generation threshold is set at 30w in the “enpase_status.yaml”

1 Like

In your case the threshold is set on the “single” sensor.envoy_1220xxxxxxx_current_energy_production. In my case the variable under the condition is a result of an algebric sum.
What i’m not able to write is:
if (sensor.envoy_122122047974_current_power_production - sensor.envoy_122122047974_current_power_consumption - sensor.charge_discharge_power) <50)
the value is 0
else
the value
endif

So i need to change this:

      - name: Export potenza
        unit_of_measurement: W
        device_class: power
        state: >
          {{ [0, states('sensor.envoy_XXXXXXXXXX_current_power_production') | float - states('sensor.envoy_XXXXXXXXXX_current_power_consumption') | float - states('sensor.charge_discharge_power') | float] | max }}

adding the condition if … else

I am setting up the Energy integration to work with my Enphase system and I have looked at the instructions at the top of this thread.

The question I have is why an integrator of instantaneous power is used to determine grid import/export instead of using the delta in the lifetime energy consumption - lifetime energy production?
My assumption is that using the actual energy figures would end up with a more accurate result and I assume the biggest source of error would be when flipping from import to export.

Also is there documentation on the yaml configuration options that I can look at?
I get the feeling that because my system is in a container that I don’t have the same editor options available to me