logo

Enphase - Resetting kWh Totals

25/07/2024

Imagine this situation: for several months, you've had a Daytopper account and you send your Enphase data to the Daytopper API. You use your own implementation, meaning you extract the data from your Enphase inverter and forward it to the Daytopper API. But suddenly, you notice your totals are no longer being updated in the Daytopper app, and you see this error in your API request: “Total should be greater or equal to the previous total….”

It's the nightmare of every Enphase user! But luckily, you're not alone in this.

It appears there's a bug in the firmware currently running, which occasionally surfaces (perhaps due to a reboot of the gateway) in both the IQ7 and IQ8. The total production you've achieved is no longer correctly returned by the API. Instead, you get a lower number (your kWh) back because Enphase starts counting from 0 again.

A short technical explanation

Enphase has 2 endpoints:

  • https://enphase.local/api/v1/production returns:
    {
      "wattHoursToday": 150,
      "wattHoursSevenDays": 26509,
      "wattHoursLifetime": 1193261,
      "wattsNow": 190
    }
  • https://enphase.local/production.json returns:
    {
      "production": [
        {
          "type": "inverters",
          "activeCount": 3,
          "readingTime": 1719122354,
          "wNow": 197,
          "whLifetime": 215
        }
      ],
      "storage": [
        {
          "type": "acb",
          "activeCount": 0,
          "readingTime": 0,
          "wNow": 0,
          "whNow": 0,
          "state": "idle"
        }
      ]
    }
    

Both return a total but with a slight difference in fields. It is currently unclear which API call the Enphase gateway itself uses, but it appears they don't use either in the Enphase app or account for this in some other way, possibly using a custom solution.

The issue

As a user, there are 2 scenarios we've observed with a few current Daytopper users:

      https://enphase.local/production.json no longer returns the correct value and returns 0, starting from 0 again. The other endpoint seems to have no issue, and the total is still as it should be.
      Both https://enphase.local/production.json and https://enphase.local/api/v1/production return 0 and start from 0 again. Both endpoints have been reset.

Why and how this occurs is still unclear, and Enphase has not provided clear answers. It's therefore unlikely that this will be resolved soon in newer firmware versions. It seems that somewhere in the inverter, a cache/memory is cleared/reset when the gateway experiences a reset.

The solution

Fortunately, we have a solution for this in the Daytopper module. For situation 1, we switch to the endpoint where the total has not been reset to 0. For situation 2, we use the result from the Daytopper API. When we want to send the data to the Daytopper API, the API checks if the data is sequential. This means we can only go up, not down. When the API detects that we are going down, in this case sending a 0 as the total, it gives an error message:

{
  "error": "Total should be greater or equal to the previous total. Given total: 12 must be greater than current total: 15445810 for device Solax:1",
  "code": "wrong_total",
  "givenTotal": 12,
  "currentTotal": 15445810,
  "deviceName": "Solax",
  "deviceId": 1
}

What we do here is use the currentTotal and add it to the total we receive from Enphase from now on.

If you have your own implementation, you will need to account for this. You will need to merge the total and the API total (currentTotal) and forward this to the API.