Enphase Envoy with Energy Dashboard

Energy Dashboard updates once every hour.
Enphase enlighten cloud updates every 15 mins.
Your sensors in home assistant update every minute if using the native enphase integration.
I use the sensors to create power and energy graphs like this

Oh interesting. Is this Apex charts?

No, just history graph built into home assistant. I put them all into the same history graph and home assistant draws a different graph for each metric type (W, kW, kWh, $)

Oh right. I have only one rate, no peak or off peak. I just added this.
Any way to define what the start time?
Also would have loved to see ability to do on the fly change of view to see breakdown last 2 to 8 hours progressively.

I did something like this.

While in dasboard, go to pencil icon,

image

then … / raw configuration editor

image

title: ''
views:
  - theme: Backend-selected
    title: 3H
    path: 3H
    type: panel
    icon: ''
    badges: []
    cards:
      - type: history-graph
        entities:
          - entity: sensor.power_consumption
          - entity: sensor.power_production
          - entity: sensor.power_import
          - entity: sensor.power_export
        refresh_interval: 60
        hours_to_show: 3
  - theme: Backend-selected
    title: 6H
    path: 6H
    type: panel
    icon: ''
    badges: []
    cards:
      - type: history-graph
        entities:
          - entity: sensor.power_consumption
          - entity: sensor.power_production
          - entity: sensor.power_import
          - entity: sensor.power_export
        refresh_interval: 60
        hours_to_show: 6

That gives me tabs for different durations

image

1 Like

Thanks. I am currently having issues with Apex chart and memory leak in firefox. Dam thing crashes, so using Edge which is also blowing up in memory usage.

I finally got this working and here is my automation for the water tank. Works like a charm.
Parameters that I can change are:
time to switch over to element and back
temperature limit for heat pump and element operation.

All four targets I am thinking of using helpers to setup if I want a front dash interface instead of accessing the automation settings. Depends on how frequently I am doing it I guess.

Update: I changed it to accommodate if export is below 1w.

Thanks for your help again.

alias: Water Heater
description: ""
trigger:
  - platform: numeric_state
    above: 1400
    for:
      hours: 0
      minutes: 2
      seconds: 0
    entity_id:
      - sensor.grid_export_power
    id: Overproduced Energy
  - platform: numeric_state
    for:
      hours: 0
      minutes: 0
      seconds: 10
    entity_id:
      - sensor.grid_export_power
    id: Underproduced Energy
    below: 1
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - Overproduced Energy
          - condition: state
            state: "off"
            entity_id: binary_sensor.dynamic_x8_heat_pump_element
          - condition: sun
            before: sunset
            after: sunrise
        sequence:
          - service: water_heater.set_operation_mode
            metadata: {}
            data:
              operation_mode: electric
            target:
              entity_id: water_heater.dynamic_x8_heat_pump
          - service: water_heater.set_temperature
            metadata: {}
            data:
              temperature: 70
            target:
              entity_id: water_heater.dynamic_x8_heat_pump
            enabled: true
          - service: notify.notify
            data_template:
              message: Water Heater Element On
      - conditions:
          - condition: trigger
            id:
              - Underproduced Energy
          - condition: state
            state: "on"
            entity_id: binary_sensor.dynamic_x8_heat_pump_element
            enabled: true
          - condition: sun
            before: sunset
            after: sunrise
            enabled: true
        sequence:
          - service: water_heater.set_operation_mode
            metadata: {}
            data:
              operation_mode: heat_pump
            target:
              entity_id: water_heater.dynamic_x8_heat_pump
          - service: water_heater.set_temperature
            metadata: {}
            data:
              temperature: 60
              operation_mode: heat_pump
            target:
              entity_id: water_heater.dynamic_x8_heat_pump
            enabled: true
          - service: notify.notify
            data_template:
              message: Water Heater Element Off
mode: single

1 Like

After reading most of the 700-odd messages in this thread I’ve got a question of my own: How are people adding the Enphase batteries to the energy dashboard? I’ve got an IQ Systems Controller 3 and some 5P batteries, with the HASS integration I can see the battery power, charge state, and a bunch of related states (apparent power, temperature), with some of the data also available from the IQ Gateway alongside directly from the battery.

Problem is I can’t add anything battery-related on the energy dashboard, the sensors available are IQ Gateway energy production and consumption but nothing battery-related. I assume this is because there’s no storage CT exposed to HA, although there’s definitely one installed because the Enphase app shows the charge and discharge info, and the HASS integration says I should be seeing a Envoy Lifetime battery energy charged and Envoy Lifetime battery energy discharged. Does anyone have any ideas on how to get the battery stats to add to the energy dashboard?

If you run the HASS integration then check the HA Enphase_Envoy integration diagnostic report if the Envoy has Storage CT or not.In the report look for the section envoy_properties and in there for ct_storage_meter. If that shows as null then no storage CT is detected or configured.

The Enphase App gets its data in some magical ways we have no access to. It probably uses the battery communication to collect these values.

If not installed you have to use Riemann on the summed individual battery power and then split the result in 2 entities, one for positive changes and one for negative changes. Or use changes in Envoy available battery energy, again split in positive and negative changes.

I have a Victron inverter with pylontech batteries added to my enphase setup. I would like to graph the whole system “as” enphase is doing it with their own battery. I think their way to graph in green battery charge and discharge is really cool.

No one have worked on that?

Job done:
There is a bug during the night, my helper with my house consumption was wrong
2024-07-05 - HA enphase graph

1 Like

And a v2 with my solar router (in Red) and EV charging (in Purple)
2024-07-05 - HA enphase graph

2 Likes

[Edit: I was responding to one of the early posts in this looooong thread. After reading most of the subsequent 793 messages, it’s clear that @del13r understands power vs energy. Instead, it looks like the Enphase integration code misuses the terms. So some entities with “energy” in their name are probably representing power instead. And it looks like @del13r figured this out and uses the mis-named values in a mathematically correct way. So I suppose my comment below should be addressed to the Enphase programmers. Hopefully this is all fixed now in 2024.]

@del13r - I notice that the code you posted here seems to be confused about the difference between power and energy.

A reminder that power is measured in Watts (often represented by the single letter W). Energy is power integrated over time, so energy is measured in Watt-hours (typically represented in thousands of Watt-hours: kWh).

Thus it’s not meaningful to represent energy using the letter W. Watts are a measurement of power, not energy. They are two different things.

This mistake is common among non-engineers. Ironically, it seems to be especially common among folks who sell solar systems.

Hello, good observation.
The energy/power sensor naming issue was actually incorrectly coded in the enphase integration before July 29th in 2021.
I wrote this guide 2 weeks later and wanted to make it clear to anyone on the old version of the enphase integration that there may be some confusion.
I addressed this previously in the quote below.

I am so frustrated. I installed all the available scripts to get my Enphase Production in my Victron Cerbo but the only way I got this to work was using Shelly 1pm.

Please help to get is directly from my Envoy sensors in Home assistant.

@broekieman, I assume you are asking how to do this using the Envoy available battery energy as a source?

This describes a way of using the Envoy available battery energy as a source to calculate Charged and Discharged battery energy in 2 separate sensors for use with the Energy dashboard. It’s the most recent version after some iterations, some recipes out there may have some errors which are removed later. And still subject to my typing errors…

It is a way of calculating it. Its not the only way to calculate it. As we all know and love about HA is it’s flexibility and multiple ways to achieve results. If this way fits your needs, great, if not then no issue either. @del13r original write-up shows an excellent other way of calculating these.

This calculation does not fully match values in the Enphase App as it does not include conversion losses in and out of the storage. So there’s correction factor to compensate for this.

1. Add number helper to hold last good value

In Settings / Devices & services / Helpers add a new helper of type number and give it some meaningful name (this example uses literally some_meaningful_name). Make sure the set the Maximum value to the battery capacity.

352227330-70b4bc5e-3137-488f-b9f8-3e33b710759e

The number helper will be used to hold last good value of the Available battery Energy. As input_number.<some_meaningful_name> is a Number, you can change the value from the user interface manually. Do NOT do that. Each change will result in energy charged/discharged values and will result in wrong values.

2. Add number helper for correction factor

In Settings / Devices & services / Helpers add a new helper of type number and give it some meaningful name (this example uses litterally correction_factor). Set the Minimum value to 100 and the Maximum value to 200.

The number helper will be used to apply a correction for conversion losses. After adding it, it should have the value of 100, which will result in a correction factor of 1. In practice you probably need to set it to somewhere between 110 and 120 to get same values as Enphase App.

If you want a different correction factor for charge and discharge, create another number for it, same process, different name.

3. Create automation to copy the Available battery Energy to the number helper

  • In Settings / Automations & scenes / Automations add a new automation.
  • Use the ⋮ at the right hand top and open the automation yaml editor and insert
description: Track Battery Energy Change
trigger:
  - platform: state
    entity_id:
      - sensor.envoy_<your_envoy_serial_number>_available_battery_energy
    not_to:
      - unknown
      - unavailable
condition: []
action:
  - service: input_number.set_value
    target:
      entity_id: input_number.<some_meaningful_name>
    data:
      value: "{{trigger.to_state.state | int(0)}}"
mode: single
  • Replace <your_envoy_serial_number> with the serial number of your envoy.
  • Replace <some_meaningful_name> by the name you assigned to the Number helper.
  • Save the automation.

This should now start copying the values of the Available battery Energy into the some_meaningful_name Number, but only when the value updates, so may be a while when in stable battery condition.

3. Create template sensors to track battery charge and discharge.

If you have already templates defined in your configuration.yaml or a separate file, edit that file. If not yet edit configuration.yaml in the Home Assistant configuration folder. In there add:

template: !include templates.yaml

Then edit a new templates.yaml file in your configuration folder.

Paste the template below:

- trigger:
    - platform: state
      entity_id: input_number.<some_meaningful_name>
      not_to:
        - unknown
        - unavailable
  sensor:
    - name: "Battery Lifetime Discharge"
      unique_id: battery_lifetime_discharge
      unit_of_measurement: "Wh" 
      icon: mdi:battery 
      state: "{{ this.state | int(0) + ([0, (trigger.to_state.state | int(0) - trigger.from_state.state | int(0))] | min * (states('input_number.correction_factor') | int(0)) / -100.0)}}" 
      device_class: energy 
      state_class: total_increasing 
    - name: "Battery Lifetime Charge"
      unique_id: battery_lifetime_charge
      unit_of_measurement: "Wh" 
      icon: mdi:battery 
      state: "{{ this.state | int(0) + ([0, (trigger.to_state.state | int(0) - trigger.from_state.state | int(0))] | max * (states('input_number.correction_factor') | int(0)) / 100.0)}}" 
      device_class: energy 
      state_class: total_increasing
  • Replace <some_meaningful_name> by the name you assigned to the Number helper.
  • Change the name: and unique_id: fields to your preferred names.
  • Replace input_number.correction_factor by the ones you want to use.
  • Save the changed files.

4. Cycle Home assistant

To make the new templates active restarts Home Assistant after first verifying its a valid configuration in Developers Tools / Yaml.

This should start building lifetime charge and discharge data.

5. Tune conversion loss corrections

With an initial value of 100 for the input_number.correction_factor the correction factor is 1.0. After some initial runtime you may note the the Enphase App reports different, probably higher, values. This is most probably caused by conversion losses. Tune the input_number.correction_factor as needed.

1 Like

Sorry for the miscommunication. I don’t have a enphase battery. I have a system with Eve calls and Seplos bms anda Victron inverter in the garage. My solar system is Enphase and I would like to use Mqtt broker on the Victron or Home assistant to send my production by Mqtt so I get a PV Inverter on my victron dashboard. I have an integration in Home assistant already to read all the data.

You might be able to try my mqtt addon GitHub - vk2him/Enphase-Envoy-mqtt-json: Takes real time stream from Enphase Envoy and publishes to mqtt broker

Thanks for these developments, it works !

I wonder if it’s possible to compute an average power in Watt that would be approximated by P(Watt)=dW/dt ?

Each state also has a state.last_changed. So with as_timestamp like:

(as_timestamp(trigger.to_state.last_changed) - (as_timestamp(this.state.last_changed)

you’ll get the time in seconds to previous value.