Enphase Envoy with Energy Dashboard

Hello again vk2him,

I am hoping you can put me on the right track again. :neutral_face:

Back in August 2021 you helped me with my energy dashboard and it’s been working fine up until just recently when Efergy started becoming unavailable for a few weeks. This meant that I had no consumption data coming into the Energy Dashboard.

As Hildebrand, the supporters of this platform, have told me that the little Energyhive box I have was discontinued in 2017 and they aren’t allocating resources to fix it if the servers go down like they did just recently.

My thinking then was I should use something like the Home Assistant Glow and be independent of any cloud storage. I purchased the hardware and have flashed it up in ESPHome and I think I have it working as of yesterday afternoon.

This is what it looks like

However this is where I am stuck.

In my Efergy entity (sensor.power_usage_3097) I am seeing all of my current consumption in my house, both solar and grid.
image

In my Enphase Envoy entity (sensor.envoy_current_energy_production) I am seeing Solar production
Which is why you told me to do the subtractions in the code below.

However in the HA Glow for consumption I am seeing zero consumption in watts and other entities of House-Daily Energy in kWh and House-Total Energy in kWh

My Solar data source has not changed.
So I am confused as to how to change my current Energy Dashboard to use this new data???

#vk2him Configs for Energy Panel Solar, Import and Export sensors
#
  - platform: template
    sensors:
      exporting:
        friendly_name: "Current Energy Exporting"
        value_template: "{{ [0, (states('sensor.envoy_current_energy_production') | int - states('sensor.power_usage_3097') | int)] | max }}"
        unit_of_measurement: 'W'

      importing:
        friendly_name: "Current Energy Importing"
        value_template: "{{ [0, (states('sensor.power_usage_3097') | int - states('sensor.envoy_current_energy_production') | int)] | max }}"
        unit_of_measurement: 'W'
 
      solarpower:
        friendly_name: "Solar Power"
        value_template: "{{ states('sensor.envoy_current_energy_production')}}"
        unit_of_measurement: 'W'
   

sensor 10:
  - platform: integration
    source: sensor.solarpower
    name: energy_solar
    method: left
    unit_prefix: k
    unit_time: h
    round: 2

sensor 11:
  - platform: integration
    source: sensor.exporting
    name: energy_exporting
    method: left
    unit_prefix: k
    unit_time: h
    round: 2

sensor 12:
  - platform: integration
    source: sensor.importing
    name: energy_importing
    method: left
    unit_prefix: k
    unit_time: h
    round: 2
#
## End vk2him
#

This is what my Energy dash board looks like at the moment

Very Confused. If you can help I would appreciate it.
Thanks in advance!

Hi Ron,

Your Power Dashboard looks ok to me, however from your first ESPHome screenshot, somethings isn’t right in your setup as the sensor for “House - Power Consumption” is 0W while the other two Energy Sensors are correctly showing kWh values.

Do some checking into the “House - Power Consumption” sensor … what is the actual sensor name for that?

That aside, you are using sensor sensor.power_usage_3097 and from the “Current Entities” screenshot you can see it has a value, so it’s working. You’re also using that sensor in your dashboard and from what I can see, your Power Dashboard looks correct.

Thanks
Ian

This is my predicament.
The Current Energy/power Dashboard, as you say, works fine and I would not be looking to change it if Efergy was not seeming to be phased out.
I built the HA Glow from GitHub - klaasnicolaas/home-assistant-glow: ⚡ The power of energy measurements in your house as recommended from Integrating your electricity grid - Home Assistant
I have the Photodiode on LED1 as per

My understanding is that the LED only pulses when power/energy is drawn from the Grid or I am importing power.
For example I am drawing power from the grid now because I have three air Conditioners running and this is what the HA GLOW is showing

And this is what the Energy Dashboard (UNCHANGED) is showing

As you can see I am importing about 1.5 ->1.7kW of power (depending on when I take the screen shots) so that sort of gels.

According to the Integrating your electricity grid - Home Assistant I am supposed to be able to use this but I am at a loss to see how?

Ron - what’s the sensor name for the sensor “Home - Power Consumption” that in the above screenshot is consuming 1500w? It’s pretty simple to use that sensor to drive the Energy Dashboard by replacing ‘sensor.power_usage_3097’ with the name of the “Home - Power Consumption” in that snippet of code two posts up.

sensor.house_power_consumption
Is the entity from ESPHome. This I believe is only imported power.

I thought that too but sensor.power_usage_3097 seems to have different data that reflects total consumption not just imported

My brain is frazzled tonight so I will see what a fresh one will look like tomorrow.

Thanks

Has anybody try this?

I am interested in this piece, but I don’t see this being exposed in my enphase system

template:
  - sensor:
        name: Battery Export Power
        state_class: measurement
        icon: mdi:battery-charging
        unit_of_measurement: W
        device_class: power
        state: >
            {{ [0, states('sensor.envoy_<ENVOY_SERIAL>_inverter_<INVERTER_SERIAL>') | int ] | max }}
  - sensor:
        name: Battery Import Power
        state_class: measurement
        icon: mdi:battery-charging
        unit_of_measurement: W
        device_class: power
        state: >
            {{ [0, 0 - states('sensor.envoy_<ENVOY_SERIAL>_inverter_<INVERTER_SERIAL>') | int ] | max }}
sensor:
  - platform: integration
    name: Battery Export Energy
    source: sensor.battery_export_power
    unit_prefix: k
    unit_time: h
    method: left
  - platform: integration
    name: Battery Import Energy
    source: sensor.battery_import_power
    unit_prefix: k
    unit_time: h
    method: left

Ian,
Thanks for you input. I have been out and about this morning with chores.

To compound things more we had a power outage last night from about 10 → 11PM. On generator for the hour!
Anyway …
This is the Entity list that Home Assistant Glow creates from GitHub - klaasnicolaas/home-assistant-glow: ⚡ The power of energy measurements in your house
You can see his code in this link.


As you can see the sensor “sensor.house_power_consumption” is zero. This is telling me that I am not importing any power from the grid, that is, the LED1 is not flashing. The LED1 only flashes every 1watt hour when I am importing power.

However, "sensor.power_usage_3097"derived from the Efergy Integration and this sensor is actually a CT clamp on the consumption cable(s) in my Switchboard (uploaded to my Energyhive device via 433MHZ and stored in the UK) and this is what it is currently showing, 2915 W. This I believe is Total consumption of the house at time of screen dump.

image

This is today’s Solar production in wh
image

I cannot make sense of it just yet!
Hoping you can shed some light. My yaml skills are not good. I can sort of read and understand but that’s about it.

Ian,
In my efforts to try an understand what is happening I came across this in discussions on the project in github

The last comment I think explains it all from klaasnicolaas the maintainer
“It will not really work with 1 LED, your meter will probably calculate what goes in and out and determines the behavior of your pulse LED based on that”

From the documentation on my meter

• LED1: 1 pulse = 1 watt hour export (to customer)
• LED2: 1 pulse = 1 watt hour import (from customer)

This said I think that this project will not work on a house with PV(Solar.)
I have LED2 but the code supplied does not cater for PV in it’s current form.
In my opinion, to read LED2 would require a 2nd setup and a different set of code.

I have completely misunderstood this project.
I have opened an issue on GitHub

Hi, before I installed solar, I used to have a retail sold device called powerpal. See https://www.powerpal.net/
This device gave great visibility of consumption by reading how much energy my house was pulling from the grid by reading the flashing light on my smart meter. When solar was installed, this device became useless for me when the sun was shining so I removed it. My solar solution replaced the functionality of this led reader.

Since there hasn’t been any action with the core component in quite a while, I’ve submitted a PR to the popular custom component (the one that supports firmware 7+) briancmpbll/home_assistant_custom_envoy which adds these calculations that @del13r has been showing us - right into the component so we don’t have to use template sensors. :+1:

What are others using for Battery Discharge and charge?
I just got me an Emporia Vue to see if I cna monitor the battery that way.

Hi @vk2him,

Thanks for the work done :wink:

Is it just me or the Add-on to stream to MQTT is not working anymore with recent HA update ?
I had messages in HA about deprecated sensor :

The mqtt platform for the sensor integration does not support platform setup. Please remove it from your config.
December 20, 2022 at 10:12:16 AM – (ERROR) Sensor - message first occurred at December 20, 2022 at 10:12:16 AM and shows up 4 times
Manually configured MQTT sensor(s) found under platform key 'sensor', please move to the mqtt integration key, see https://www.home-assistant.io/integrations/sensor.mqtt/#new_format
December 20, 2022 at 10:12:10 AM – (ERROR) MQTT

@batkite ,

The add-on still works fine however you need to now use the new method of formatting the mqtt integration key within your configuration.yaml.

The old method that no longer works is :


sensor 24:
  - platform: mqtt
    state_topic: "/envoy/json"
    name: "mqtt_production"
    qos: 0
    unit_of_measurement: "W"
    value_template: '{% if is_state("sun.sun", "below_horizon")%}0{%else%}{{ value_json["production"]["ph-a"]["p"]  | float }}{%endif%}'
    state_class: measurement
    device_class: power

  - platform: mqtt
    state_topic: "/envoy/json"
    value_template: '{{ value_json["total-consumption"]["ph-a"]["p"] }}'
    name: "mqtt_consumption"
    qos: 0
    unit_of_measurement: "W"
    state_class: measurement
    device_class: power

  - platform: mqtt
    state_topic: "/envoy/json"
    name: "mqtt_power_factor"
    qos: 0
    unit_of_measurement: "%"
    value_template: '{{ value_json["total-consumption"]["ph-a"]["pf"] }}'
    state_class: measurement
    device_class: power_factor

  - platform: mqtt
    state_topic: "/envoy/json"
    name: "mqtt_voltage"
    qos: 0
    unit_of_measurement: "V"
    value_template: '{{ value_json["total-consumption"]["ph-a"]["v"] }}'
    state_class: measurement
    device_class: voltage

The above needs to be replaced with the new mqtt intgration method :

mqtt:
  sensor:
    - name: "mqtt_production"
      state_topic: "/envoy/json"
      qos: 0
      unit_of_measurement: "W"
      value_template: '{% if is_state("sun.sun", "below_horizon")%}0{%else%}{{ value_json["production"]["ph-a"]["p"]  | float }}{%endif%}'
      state_class: measurement
      device_class: power

    - name: "mqtt_consumption"
      state_topic: "/envoy/json"
      value_template: '{{ value_json["total-consumption"]["ph-a"]["p"] }}'
      qos: 0
      unit_of_measurement: "W"
      state_class: measurement
      device_class: power

    - name: "mqtt_power_factor"
      state_topic: "/envoy/json"
      qos: 0
      unit_of_measurement: "%"
      value_template: '{{ value_json["total-consumption"]["ph-a"]["pf"] }}'
      state_class: measurement
      device_class: power_factor

    - name: "mqtt_voltage"
      state_topic: "/envoy/json"
      qos: 0
      unit_of_measurement: "V"
      value_template: '{{ value_json["total-consumption"]["ph-a"]["v"] }}'
      state_class: measurement
      device_class: voltage

I’ll update the add-in documentation with this - thanks

I am using your PR and I see the sensors but my grid energy import and export are showing a constant 0.01 kWh, I don’t understand what I did wrong, its possible I am reading the wrong sensors, could you or someone running this PR show me what the proper sensors are in the dashboard settings section?
Edit: on second look i could not find the sensors you mentioned would be in there, I added the code from the first few posts but the sensors show unknown states

Hi,

I made the change and everything is back to normal.

Thanks a lot.

How do I edit metering configuration for Envoy in HASS?
The current meter clamps might (in principle) be installed to measure the

  • current at the load (solar attached at the utility side of the CT)
    or
  • current on the utility side (solar attached at the consumption node)
    It appears (looking at the power levels displayed in the Energy dashboard) that the solar power is added to the power displayed as the Grid and this isn’t my case.

Question: Where do I edit the configuration? I vaguely remember there was an “interview” during the initial set-up (where I apparently made a mistake). I would prefer editing the configuration rather than deleting and starting over. Thanks!

Hi Martin,

I am not aware that you can make any changes like that in HA to affect EnPhase. Those metering changes are all done in the Installers toolkit (which is freely available from the playstore) but you need the installer to grant you access to that, which he may not want to do without relinquishing his warranty to you…



Hi Chris,
Thanks for your reply. I have full access to Envoy - since I self installed and I am also running some py scripts off-line to hog data with something like 30 second granularity. Enphase is doing it’s thing and reporting believable data.


The issue is that the metering current transformers may be installed on either side: On the utility side (where it measures net delivery from/to utility (distinguished by the sign)) or on the consumption side where it reports what is consumed from both utility and solar (always in one direction)).
Either option is fine wit Envoy, you just tell it during initial configuration what is the metering scheme. However, HASS integration seems to assume the later and there seem to be no configuration option.
I spent few hours searching and found this was actually reported while back so I am not the only one facing this.
Issue link below.
Thanks - Martin

1 Like

Ok after stuffing around two days with this post which is awesome by the way I have decided to ask for help please.
Issues:

The error in the screenshots below. Code shows some array expected error but HA has no issues using it.
There is a statistics not defined error in second screenshot not sure what thats about
The total consumption is off 2-3 KW right now. Shows 6 ish and I have 8 something on the app
Like you I have daily supply charge and 1 rate for usage. May need assistance with it if you can guide me.

thanks

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_SN_current_power_consumption') | int - states('sensor.envoy_SN_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_SN_current_power_production') | int - states('sensor.envoy_SN_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_SN_current_power_consumption') | int %}
            {% if value  <= 5 %}
              0
            {% elif is_state("sun.sun","below_horizon") %} 
              0
            {%- else -%}
              {{ value }}
            {%- endif %}
                        
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
            
utility_meter:
  daily_energy:
    source: sensor.grid_import_energy
    name: Daily Import Meter
    cycle: daily
    tariffs:
      - offpeak
      - shoulder
      - peak
  daily_energy_export:
    source: sensor.grid_export_energy
    name: Daily Export Meter
    cycle: daily
    tariffs:
      - buyback


Screenshot 2023-02-22 093955
Screenshot 2023-02-22 094031

Try changing int to int(0)

That might happen if you are attempting this for the first time at night as the grid export value will be 0 until the sun comes up and your panels start making more power than your house needs. Once the value goes above 0, it should correctly format accordingly and statistics should follow over an hour later.

Total consumption since when?
Since midnight or since the solar panels were installed?
Have the integration/energy sensors been setup less than 24 hours ago? If so, then that would explain the difference as the integration/energy sensor will only start recording from when it was setup onwards.

Here are 2 screenshots.

First one shows the native sensors from enphase. These are the daily figures from the ct clamp on the panels (production) and ct clamp on the house (consumption)

This screenshot will show the grid import and grid export for the day.

As oversimplified example, If your house is consuming the exact same amount of power that your panels are producing, then the grid in and out figures will be 0.