home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.12k stars 30.18k forks source link

Not often, but generally every 10 days, my Energy usage meters say I consumed 20,183.7 kWh in one hour, and sent 4,953.8 kWh back to the grid. #119825

Closed wptracy closed 2 months ago

wptracy commented 3 months ago

The problem

Not often, but generally every 10 days, my Energy usage meters say I consumed 20,183.7 kWh in one hour, and sent 4,953.8 kWh back to the grid.

For example, the June 5th screenshot shows I consumed 20,183.7 kWh The screenshot for Jun 14th shows I sent 4,953.8 kWh back to the grid.

These numbers are actually my total lifetime Electric Meter Consumption and total lifetime Envoy Production sensor readings for that time period.

The previous hour readings are wiped out because the new consumption/production reading is way off scale to the previous hours.

Screenshot 2024-06-17 at 05-10-32 Overview – Home Assistant Screenshot 2024-06-17 at 05-04-17 Energy – Home Assistant Screenshot 2024-06-17 at 05-03-55 Energy – Home Assistant Screenshot 2024-06-17 at 05-03-34 Energy – Home Assistant

What version of Home Assistant Core has the issue?

core-2024.6.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

No response

Link to integration documentation on our website

https://www.home-assistant.io/integrations/enphase_envoy/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 3 months ago

Hey there @bdraco, @cgarwood, @dgomes, @joostlek, @catsmanac, mind taking a look at this issue as it has been labeled with an integration (enphase_envoy) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `enphase_envoy` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign enphase_envoy` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


enphase_envoy documentation enphase_envoy source (message by IssueLinks)

catsmanac commented 3 months ago

Hi @wptracy , are you using the lifetime energy production value or the daily energy production for the energy dashboard. Day values have been reported as less reliable and prone to peaks as you describe so best use the lifetime value if not yet.

wptracy commented 3 months ago

@catsmanac ,

I'm using lifetime in the Solar panels section of http://10.0.0.213:8123/config/energy

But I see in the Electricity Grid, Return to Grid section I have Smart Electric Meter Production, which is my lifetime sensor for envoy. So I think I have it right.

Screenshot 2024-06-18 at 09-03-37 Settings – Home Assistant

catsmanac commented 3 months ago

Can you upload the HA Enphase Envoy diagnostics file here? Download it from HA and then drag it to afbeelding below a new comment.

afbeelding

wptracy commented 3 months ago

config_entry-enphase_envoy-40d720e4c6bb6a1b7af1119669175316.json

catsmanac commented 3 months ago

Thanks, @wptracy. I guess this is the same system as the other issue reported.

So it's a Envoy-metered without any connected/configured Current Transformers (CT). When you look at a long-term history plot, like 3-4 weeks (2 or 3 of these 10 day periods) of the Lifetime Energy Production Entity do you see an ever increasing trend or a saw-tooth like shape as below? afbeelding

wptracy commented 3 months ago

When you look at a long-term history plot, like 3-4 weeks (2 or 3 of these 10 day periods) of the Lifetime Energy Production Entity do you see an ever increasing trend or a saw-tooth like shape as below?

Yes, I do see saw-tooth. But my graphs are not as sharp as yours.

Here are the screenshots. June 12 and 14 are the days it says I sent 5000kWh to the grid Screenshot 2024-06-19 at 13-50-57 History – Home Assistant Screenshot 2024-06-19 at 13-56-15 Energy – Home Assistant Screenshot 2024-06-19 at 13-53-57 History – Home Assistant Screenshot 2024-06-19 at 13-52-43 History – Home Assistant Screenshot 2024-06-19 at 13-51-55 History – Home Assistant Screenshot 2024-06-19 at 13-51-27 History – Home Assistant

catsmanac commented 3 months ago

Those trends are the smart electric meter production and not the Envoy <serial> Lifetime energy production from the Envoy. And since you mentioned the issue also happens with the consumption number, I'm wondering if the issue comes from the `smart electric meter' data collection returning 0 values at those 2 moments.

wptracy commented 3 months ago

Here are the smart electric meter production history charts. It's hard to see the saw-tooth, but the saw-tooth is there.

I'll enable the logger: default: debug in configuration.yaml when the sun come up, so we do event correlation with other modules. That's at 5:32, about 2.5 hours from now. Screenshot 2024-06-20 at 03-04-05 History – Home Assistant Screenshot 2024-06-20 at 03-03-10 History – Home Assistant Screenshot 2024-06-20 at 03-15-35 History – Home Assistant

catsmanac commented 3 months ago

Okay, that last picture is the one I expected, it's resetting to zero when it reaches roughly 1.2MWh. This is a known behavior of the Envoy metered without CT installed. This seems to happen roughly every month in your case, so not the 10 days you refer to.

wptracy commented 3 months ago

Here are the meter history reports for "Smart Electric Meter Production" and " Envoy 202321168106 Lifetime Energy production"

The production spikes only come from "Smart Electric Meter Production"

This is my configuration.yaml entry for "Smart Electric Meter"

command_line:
  - sensor:
      unique_id: xcel_meter_power
      name: "Smart Electric Meter Power"
      #command: "OPENSSL_CONF=/config/xcelcerts/myown/openssl.cnf /usr/bin/curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure --url https://10.0.0.226:8081/upt/1/mr/1/r --cert /config/xcelcerts/myown/cert.pem --key /config/xcelcerts/myown/key.pem 2>&1 | grep -o '<value>.*</value>' | grep -Eo '[0-9]+'"
      command: "OPENSSL_CONF=/config/xcelcerts/myown/openssl.cnf /usr/bin/curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure --url https://10.0.0.226:8081/upt/1/mr/1/r --cert /config/xcelcerts/myown/cert.pem --key /config/xcelcerts/myown/key.pem 2>&1 | grep -o '<value>.*</value>' | grep -Eo '([+-]?[0-9]+)'"
      unit_of_measurement: "W"
      device_class: "power"
      scan_interval: 5
      command_timeout: 5

  - sensor:
      unique_id: xcel_meter_consumption
      name: "Smart Electric Meter Consumption"
      command: "OPENSSL_CONF=/config/xcelcerts/myown/openssl.cnf /usr/bin/curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure --url https://10.0.0.226:8081/upt/1/mr/3/r --cert /config/xcelcerts/myown/cert.pem --key /config/xcelcerts/myown/key.pem 2>&1 | grep -o '<value>.*</value>' | grep -Eo '[0-9]+'"
      unit_of_measurement: "kWh"
      value_template: "{{ value | multiply(0.001) | round(3)}}"
      device_class: "energy"
      state_class: "total_increasing"
      #scan_interval: 86400
      scan_interval: 5
      command_timeout: 5

  - sensor:
      unique_id: xcel_meter_productiion
      name: "Smart Electric Meter Production"
      command: "OPENSSL_CONF=/config/xcelcerts/myown/openssl.cnf /usr/bin/curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure --url https://10.0.0.226:8081/upt/1/mr/2/r --cert /config/xcelcerts/myown/cert.pem --key /config/xcelcerts/myown/key.pem 2>&1 | grep -o '<value>.*</value>' | grep -Eo '[0-9]+'"
      unit_of_measurement: "kWh"
      value_template: "{{ value | multiply(0.001) | round(3)}}"
      device_class: "energy"
      state_class: "total_increasing"
      #scan_interval: 86400
      scan_interval: 5
      command_timeout: 5
  • (Get some sleep first as it seems awfully early or late over there)

These are my normal hours. I get up between midnight and 3AM.

Screenshot 2024-06-20 at 04-34-37 History – Home Assistant Screenshot 2024-06-20 at 04-33-23 History – Home Assistant

wptracy commented 3 months ago
  • You can check if the reset to zero of Envoy <serial> Lifetime energy production coincides with the peaks in the consumption or production

I don't know how to do this.

Oh wait a minute, I do see what you mean.

No, the reset to zero is not on the 12th or 14th.

Reset to zero occurs and on the 2nd, the spikes occurred on June 14 between 1-2PM and on the June 12 between 6-7AM

My monthly reset is on the 9th of each month.

Here is my configuration.yaml entry for the reset.

utility_meter:
  daily_energy:
    source: sensor.smart_electric_meter_consumption
    name: daily energy
    cycle: daily
    #cron: "* * 9 * *"
    tariffs:
      - offpeak
      - midpeak
      - peak
  monthly_energy:
    source: sensor.smart_electric_meter_consumption
    name: monthly energy
    #cycle: monthly
    cron: "* * 9 * *"
    tariffs:
      - offpeak
      - midpeak
      - peak

Screenshot 2024-06-20 at 05-01-07 Energy – Home Assistant Screenshot 2024-06-20 at 05-01-21 Energy – Home Assistant

wptracy commented 3 months ago

Okay, that last picture is the one I expected, it's resetting to zero when it reaches roughly 1.2MWh.

My inverters clip a 330watts.

With 20 panels I can only generate a maximum of 6.6MWh

Tracy_Layout

catsmanac commented 3 months ago

Looking at all the data I see no other conclusion as that on June 12 and June 14 the xcel_meter_production/Smart Electric Meter Production either had a failure resulting in a zero value, did not find a value resulting in a zero value or found a zero value.

The Energy dashboard can handle a reset to zero and counting up from zero again, but in this case it went to zero and right back again. And that step from zero back to original value is then interpreted as production.

If there's no way to solve the issue at the xcel source you could filter zero values from the input in the value template or additional template sensor. Maybe something like below.

 value_template: >
          {% set new_value = value | multiply(0.001) | round(3) %}
          {{ new_value if new_value else states('sensor.smart_electric_meter_production') }}

Not well versed in these templates so you may want to try with a test sensor first. This will also prevent it from a legitimate zero as well and hold previous value in that case. If zero can be legitimate you need to devise some other logic.

wptracy commented 3 months ago

The energy calculation only occurs for a 1 hour period, for both production and consumption.

I don't know how the calculation is made. Somehow it's using the lifetime counters to calculate this.

The following hour is back normal. I can barely see the previous hour and past hour readings because the lifetime peak production and consumption number push the previous and past reading completely off scale.

My daily and monthly register don't include these counts.

Screenshot 2024-06-20 at 07-05-30 Overview – Home Assistant

catsmanac commented 3 months ago

The energy calculation only occurs for a 1 hour period, for both production and consumption.

So these are calculated by the xcel source and only updated 1/hour?

The following hour is back normal. I can barely see the previous hour and past hour readings because the lifetime peak production and consumption number push the previous and past reading completely off scale.

That is indeed the effect if there's a zero right in the middle of the data.

My daily and monthly register don't include these counts.

So these come from the xcel source as well?

wptracy commented 3 months ago

Today, it happened again. This time on the Envoy production energy usage.

I think this might be an Energy App problem, not an Envoy App problem.

I didn't have debug turned on.

The false power company consumption reading happened once last November, twice in May, and twice this month. with readings from the power company lifetime consumption meter instead of the power company current consumption meter.

The false Envoy production reading happened 4 times this month. with the readings from envoy lifetime instead of current power production meter. I think the energy app is supposed to get it's hourly readings from the power company current meter reading and not the lifetime reading.

Today, the envoy lifetime meter is reading 1095 kWh

Screenshot 2024-06-25 at 07-04-39 Energy – Home Assistant Screenshot 2024-06-25 at 07-04-23 Energy – Home Assistant Screenshot 2024-06-25 at 07-02-19 Energy – Home Assistant Screenshot 2024-06-25 at 07-02-06 Overview – Home Assistant

catsmanac commented 3 months ago

The false Envoy production reading happened 4 times this month.

I have to disagree with this, in my opinion it is: The false power company production reading

afbeelding

The problem lies in the xcel power production data. That shows a huge step. You will have to solve that to get rid of the problem. Look back in history for the values and you see what came in.

It's not the Envoy solar production . In the your pictures,

afbeelding

the value in the solar bubble is solar energy calculated for that day using envoy lifetime energy production. It is 0.3 kWh, even though the bar seems huge, check the scale, it's just 0.3 kWh. If you check history for this there won't be a step.

The values in the grid bubble are the values calculated from the xcel data and these show the huge numbers when the issue happens.

This is no Envoy integration problem and without any debug log file I can't do much more. Even though I expect a debug log to not show any Envoy anomalies I'll be happy to analyze it when you provide it.

As for the energy dashboard, when you find the timestamps of the wrong values and know what the values should be (value from right before it I guess) you can correct these one by one. You can do that in developers tools / statistics, set it to the previous or next value and the Energy dashboard will clean up. At the bottom the correct panel has a outliers button. If you use that it searches for unexpected values. This may find your issue times and value. It does not solve the root cause, but makes your energy dashboard report correctly again. (See HA Community 493558)

341944174-f71660ff-15c1-4a42-bf48-850a1384263a

wptracy commented 3 months ago

The values in the grid bubble are the values calculated from the xcel data and these show the huge numbers when the issue happens.

I agree with you and that's why I'm saying I think this is an Energy app problem not an Envoy problem.

These readings of 20,000kWh and 5,000kWh are the lifetime register readings that it gets from Xcel Energy smart meter, from my configuration.yaml

How does the energy app calculate each hour on the Energy Bar Graph?

How do Envoy readings figure into the Energy App Bar Graph Calculation?

How does it do the math?

Here is my configuration.yaml

command_line:
  - sensor:
      unique_id: xcel_meter_power
      name: "Smart Electric Meter Power"
      #command: "OPENSSL_CONF=/config/xcelcerts/myown/openssl.cnf /usr/bin/curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure --url https://10.0.0.226:8081/upt/1/mr/1/r --cert /config/xcelcerts/myown/cert.pem --key /config/xcelcerts/myown/key.pem 2>&1 | grep -o '<value>.*</value>' | grep -Eo '[0-9]+'"
      command: "OPENSSL_CONF=/config/xcelcerts/myown/openssl.cnf /usr/bin/curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure --url https://10.0.0.226:8081/upt/1/mr/1/r --cert /config/xcelcerts/myown/cert.pem --key /config/xcelcerts/myown/key.pem 2>&1 | grep -o '<value>.*</value>' | grep -Eo '([+-]?[0-9]+)'"
      unit_of_measurement: "W"
      device_class: "power"
      scan_interval: 15
      command_timeout: 15

  - sensor:
      unique_id: xcel_meter_consumption
      name: "Smart Electric Meter Consumption"
      command: "OPENSSL_CONF=/config/xcelcerts/myown/openssl.cnf /usr/bin/curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure --url https://10.0.0.226:8081/upt/1/mr/3/r --cert /config/xcelcerts/myown/cert.pem --key /config/xcelcerts/myown/key.pem 2>&1 | grep -o '<value>.*</value>' | grep -Eo '[0-9]+'"
      unit_of_measurement: "kWh"
      value_template: "{{ value | multiply(0.001) | round(3)}}"
      device_class: "energy"
      state_class: "total_increasing"
      #scan_interval: 86400
      scan_interval: 15
      command_timeout: 15

  - sensor:
      unique_id: xcel_meter_productiion
      name: "Smart Electric Meter Production"
      command: "OPENSSL_CONF=/config/xcelcerts/myown/openssl.cnf /usr/bin/curl --ciphers ECDHE-ECDSA-AES128-CCM8 --insecure --url https://10.0.0.226:8081/upt/1/mr/2/r --cert /config/xcelcerts/myown/cert.pem --key /config/xcelcerts/myown/key.pem 2>&1 | grep -o '<value>.*</value>' | grep -Eo '[0-9]+'"
      unit_of_measurement: "kWh"
      value_template: "{{ value | multiply(0.001) | round(3)}}"
      device_class: "energy"
      state_class: "total_increasing"
      #scan_interval: 86400
      scan_interval: 15
      command_timeout: 15

342742993-d4792be5-f1a7-4752-b598-2ffca6a79232n

catsmanac commented 3 months ago

How does the energy app calculate each hour on the Energy Bar Graph?

The Energy app, when opened, first determines what sensors are configured for solar production and grid im/export.

Then for the period specified e.g. yesterday, it will lookup in history the values for these sensors at the start of the period. Then hour-by-hour it will get the values at the end of the hour, subtract the values at the start of the hour and assign the difference that to that hour.

The value for each hour is then plotted in the bars as well as added to the running change since start of day and shown in the bubbles.

If a value resets to zero inside an hour it will use the value change from start of hour till moment it goes to zero as well as the change from zero to the value of the end of the hour. In this way it can handle sensors that reset to zero every now and then, like monthly or so. Left picture.

afbeelding

If the value resets to zero inside an hour and returns to the original value right after that the energy dashboard assumes a reset and adds the change from zero to the original value as change. The right picture.

It will actually decide it's a meter reset if the new value is less then 90% of the previous one, obviously a change to zero qualifies for that.

How do Envoy readings figure into the Energy App Bar Graph Calculation?

Envoy reading is just a reading as any other. The energy dashboard processes these as described above.

How does it do the math?

The Energy app does the math. The Envoy data is collected from the Envoy and written to the sensor values as received.

Here is my configuration.yaml

I understand that you are reading a value using curl. Many things can happen. What happens if an error occurs, is a zero returned? What happens if the value is being updated when you try to read it? Is the source that creates the value reliable?

catsmanac commented 2 months ago

@home-assistant close