Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with City Power load reductions #96

Open
meegeetee opened this issue Sep 12, 2024 · 7 comments
Open

Error with City Power load reductions #96

meegeetee opened this issue Sep 12, 2024 · 7 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@meegeetee
Copy link

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
Copy link
Owner

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
Copy link
Owner

wernerhp commented Sep 15, 2024

{
  "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 wernerhp self-assigned this Sep 15, 2024
@wernerhp wernerhp added the bug Something isn't working label Sep 15, 2024
@wernerhp wernerhp added this to the 1.3.3 milestone Sep 15, 2024
@wernerhp
Copy link
Owner

@meegeetee
Copy link
Author

meegeetee commented Nov 17, 2024 via email

@wernerhp
Copy link
Owner

wernerhp commented Nov 18, 2024

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
Copy link
Author

meegeetee commented Nov 18, 2024 via email

@wernerhp
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants