wernerhp / ha.integration.load_shedding

A Home Assistant integration to track your load schedding schedule.
MIT License
118 stars 21 forks source link

Error with City Power load reductions #96

Open meegeetee opened 2 months ago

meegeetee commented 2 months ago

I needed to change my loadshedding area to Linksfield Ridge (13) in Johannesburg which is subject to City Power load reductions, which is not Eskom load shedding. The ESP app shows the correct information, but I am getting an error in Home Assistant which says

Needs attention Load Shedding No devices or entities Failed setup, will retry: invalid literal for int() with base 10: 'Reduction'

wernerhp commented 2 months ago

I'llll have to check out the API response. It looks like it's returning something unexpected.

This error originated from a custom integration.

Logger: custom_components.load_shedding
Source: helpers/update_coordinator.py:354
integration: Load Shedding (documentation, issues)
First occurred: 21:46:39 (3 occurrences)
Last logged: 21:47:03

Unexpected error fetching load_shedding data
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 354, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/load_shedding/__init__.py", line 304, in _async_update_data
    area = await self.async_update_area()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/load_shedding/__init__.py", line 330, in async_update_area
    stage = Stage(int(parts[1]))
                  ^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'Reduction'
wernerhp commented 2 months ago
{
  "events": [
    {
      "end": "2024-09-15T09:00:00+02:00",
      "note": "Load Reduction",
      "start": "2024-09-15T06:30:00+02:00"
    },
    {
      "end": "2024-09-16T23:00:00+02:00",
      "note": "Load Reduction",
      "start": "2024-09-16T20:30:00+02:00"
    },
    {
      "end": "2024-09-17T21:00:00+02:00",
      "note": "Load Reduction",
      "start": "2024-09-17T18:30:00+02:00"
    }
  ],
  "info": {
    "name": "Linksfield Ridge (13)",
    "region": "JHB City Power"
  },
  "schedule": {
    "days": [
      {
        "date": "2024-09-15",
        "name": "Sunday",
        "stages": [
          [],
          [
            "08:00-10:30"
          ],
          [
            "00:00-02:30",
            "08:00-10:30"
          ],
          [
            "00:00-02:30",
            "08:00-10:30",
            "16:00-18:30"
          ],
          [
            "00:00-04:30",
            "08:00-10:30",
            "16:00-18:30"
          ],
          [
            "00:00-04:30",
            "08:00-10:30",
            "16:00-20:30"
          ],
          [
            "00:00-04:30",
            "08:00-12:30",
            "16:00-20:30"
          ],
          [
            "00:00-04:30",
            "08:00-12:30",
            "16:00-20:30"
          ]
        ]
      },
      {
        "date": "2024-09-16",
        "name": "Monday",
        "stages": [
          [
            "10:00-12:30"
          ],
          [
            "10:00-12:30"
          ],
          [
            "10:00-12:30",
            "18:00-20:30"
          ],
          [
            "02:00-04:30",
            "10:00-12:30",
            "18:00-20:30"
          ],
          [
            "02:00-04:30",
            "10:00-12:30",
            "16:00-20:30"
          ],
          [
            "00:00-04:30",
            "10:00-12:30",
            "16:00-20:30"
          ],
          [
            "00:00-04:30",
            "10:00-12:30",
            "16:00-20:30"
          ],
          [
            "00:00-04:30",
            "08:00-12:30",
            "16:00-20:30"
          ]
        ]
      },
      {
        "date": "2024-09-17",
        "name": "Tuesday",
        "stages": [
          [
            "08:00-10:30"
          ],
          [
            "08:00-10:30"
          ],
          [
            "08:00-10:30",
            "16:00-18:30"
          ],
          [
            "00:00-02:30",
            "08:00-10:30",
            "16:00-18:30"
          ],
          [
            "00:00-02:30",
            "08:00-10:30",
            "16:00-20:30"
          ],
          [
            "00:00-04:30",
            "08:00-10:30",
            "16:00-20:30"
          ],
          [
            "00:00-04:30",
            "08:00-10:30",
            "16:00-20:30"
          ],
          [
            "00:00-04:30",
            "08:00-12:30",
            "16:00-20:30"
          ]
        ]
      },
      {
        "date": "2024-09-18",
        "name": "Wednesday",
        "stages": [
          [
            "14:00-16:30"
          ],
          [
            "14:00-16:30"
          ],
          [
            "14:00-16:30",
            "22:00-00:30"
          ],
          [
            "06:00-08:30",
            "14:00-16:30",
            "22:00-00:30"
          ],
          [
            "06:00-08:30",
            "14:00-16:30",
            "20:00-00:30"
          ],
          [
            "04:00-08:30",
            "14:00-16:30",
            "20:00-00:30"
          ],
          [
            "04:00-08:30",
            "14:00-16:30",
            "20:00-00:30"
          ],
          [
            "04:00-08:30",
            "12:00-16:30",
            "20:00-00:30"
          ]
        ]
      },
      {
        "date": "2024-09-19",
        "name": "Thursday",
        "stages": [
          [
            "12:00-14:30"
          ],
          [
            "12:00-14:30"
          ],
          [
            "12:00-14:30",
            "20:00-22:30"
          ],
          [
            "04:00-06:30",
            "12:00-14:30",
            "20:00-22:30"
          ],
          [
            "04:00-06:30",
            "12:00-14:30",
            "20:00-00:30"
          ],
          [
            "04:00-08:30",
            "12:00-14:30",
            "20:00-00:30"
          ],
          [
            "04:00-08:30",
            "12:00-14:30",
            "20:00-00:30"
          ],
          [
            "04:00-08:30",
            "12:00-16:30",
            "20:00-00:30"
          ]
        ]
      },
      {
        "date": "2024-09-20",
        "name": "Friday",
        "stages": [
          [],
          [
            "14:00-16:30"
          ],
          [
            "06:00-08:30",
            "14:00-16:30"
          ],
          [
            "06:00-08:30",
            "14:00-16:30",
            "22:00-00:30"
          ],
          [
            "04:00-08:30",
            "14:00-16:30",
            "22:00-00:30"
          ],
          [
            "04:00-08:30",
            "14:00-16:30",
            "20:00-00:30"
          ],
          [
            "04:00-08:30",
            "12:00-16:30",
            "20:00-00:30"
          ],
          [
            "04:00-08:30",
            "12:00-16:30",
            "20:00-00:30"
          ]
        ]
      },
      {
        "date": "2024-09-21",
        "name": "Saturday",
        "stages": [
          [],
          [
            "12:00-14:30"
          ],
          [
            "04:00-06:30",
            "12:00-14:30"
          ],
          [
            "04:00-06:30",
            "12:00-14:30",
            "20:00-22:30"
          ],
          [
            "04:00-08:30",
            "12:00-14:30",
            "20:00-22:30"
          ],
          [
            "04:00-08:30",
            "12:00-14:30",
            "20:00-00:30"
          ],
          [
            "04:00-08:30",
            "12:00-16:30",
            "20:00-00:30"
          ],
          [
            "04:00-08:30",
            "12:00-16:30",
            "20:00-00:30"
          ]
        ]
      }
    ],
    "source": "https://www.citypower.co.za/customers/Pages/Load_Shedding_Downloads.aspx"
  }
}

Ah, looks like the Note field is different. I think it usually indicates the stge, e.g. Stage 2, which is used to get the 2 and generate a longer forecast for the area. Now that it says Load Reduction, it fails to parse the Stage number.

Thanks for reporting.

wernerhp commented 1 week ago

Please try this beta release https://github.com/wernerhp/ha.integration.load_shedding/releases/tag/v1.5.0-beta

meegeetee commented 1 week ago

Thanks, tried this, but got an error:

Error Config flow could not be loaded: {"message":"Invalid handler specified"}

when trying to install. Will try again during the week by deleting the old version completely and loading the new one

regards Graham


From: "Werner Pieterson" @.> Sent: 17/11/2024 17:30 To: "wernerhp/ha.integration.load_shedding" @.> Cc: meegeetee @.>, Author @.> Subject: Re: [wernerhp/ha.integration.load_shedding] Error with City Power load reductions (Issue #96)

Please try this beta release https://github.com/wernerhp/ha.integration.load_shedding/releases/tag/v1.5.0-beta — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

wernerhp commented 1 week ago

There was a little bug. Pushed a new beta.1. Pkease have a look. https://github.com/wernerhp/ha.integration.load_shedding/releases/tag/v1.5.0-beta.1

Screenshot_20241118-145446

Since Load Reduction doesn't have a Stage, I'm using the events provided by ESP as the forecast instead of calculating the forecast, so the forecast isn't that far into the future. The sensor will turn on and off and you can use the forecast in automations.

Dashboard cards may need some adjustments. Screenshot_20241118-145944

meegeetee commented 1 week ago

Thanks, seems to be working now. Appreciate the effort to remediate this

regards


From: "Werner Pieterson" @.> Sent: 18/11/2024 14:55 To: "wernerhp/ha.integration.load_shedding" @.> Cc: meegeetee @.>, Author @.> Subject: Re: [wernerhp/ha.integration.load_shedding] Error with City Power load reductions (Issue #96)

There was a little bug. Pushed a new beta.1. Pkease have a look. https://github.com/wernerhp/ha.integration.load_shedding/releases/tag/v1.5.0-beta.1 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.

wernerhp commented 5 days ago

Made some more changes and hopefully fixed a bug that prevented the sensor from updating correctly. There's a v1.5.0-beta.2