Simple way to get loadshedding schedule into HASS

I am slowly migrating to HASS from OpenHAB and was wondering how to get the loadshedding into Home Assistant. Was thinking of migrating my solution from OpenHAB or installing the integration when I discovered this quite simple way:

https://eskomcalendar.co.za/ publishes calendars for loadshedding schedules which are quite handy.

At the bottom of the page you can get the link to the ICS feed for example:
https://github.com/beyarkay/eskom-calendar/releases/download/latest/city-of-cape-town-area-7.ics

I’ve then created a config package called loadshedding.yaml (included below) that brings the calendar into Home Assistant. It should appear as a calendar tab on your interface:

.
(obviously you need to change the URL in the file to match your area).

This creates calendar.loadshedding which is mainly a binary sensor whether it’s currently loadshedding. Plus it has attributes.

I then create the following:

  • sensor.loadshedding_start_time the start time of the next (or the current loadshedding when in loadshedding). This is extracted from the calendar attributes.
  • sensor.loadshedding_end_time the end time of the next (or the current loadshedding)
  • I also added an entity for stats purposes called sensor.loadshedding_time which tracks the total time in loadshedding for interest only. Basically would allow you to make stats graphs of how many hours you had each day, week, month etc.

My dashboard looks like this then:

homeassistant:
  customize:
    sensor.loadshedding_start_time:
      friendly_name: "Loadshedding Start"
    sensor.loadshedding_end_time:
      friendly_name: "Loadshedding End"
    sensor.loadshedding_time:
      icon: mdi:timer-outline
      friendly_name: "Loadshedding Time"
      state_class: total_increasing

calendar:
- platform: ics_calendar
  calendars:
      - name: "Loadshedding"
        url: "https://github.com/beyarkay/eskom-calendar/releases/download/latest/city-of-cape-town-area-7.ics"
        # exclude the end of schedule entry in the calendar
        exclude: "['End of schedule']"
        
template:
  - sensor:
      - name: "loadshedding_start_time"
        unique_id: "loadshedding_start_time"
        device_class: timestamp
        state: >
          {{ (state_attr('calendar.loadshedding', 'start_time') | as_datetime | as_local).isoformat()}}
  - sensor:
      - name: "loadshedding_end_time"
        unique_id: "loadshedding_end_time"
        device_class: timestamp
        state: >
          {{ (state_attr('calendar.loadshedding', 'end_time') | as_datetime | as_local).isoformat()}}

sensor:
  - platform: history_stats
    name: loadshedding_time
    entity_id: calendar.loadshedding
    unique_id: loadshedding_time
    state: "on"
    type: time
    start: "{{ 0 }}"
    end: "{{ now() }}"
1 Like

Have you looked at the Eskom se Push API and the custom components around it?

Yes wrote something for OpenHAB using API.

However this approach requires no custom components nor an API key. And it exposes the calendar nicely. For me it seems simpler and more elegant, but everyone has different ideas. Hadn’t seen anyone doing it this way. Obviously your existing solution is fine too. Just sharing as I found it an easy approach.

Using GitHub - wernerhp/ha.integration.load_shedding: A Home Assistant integration to track your load schedding schedule. (sure it uses an api key), you get a calendar that is dynamically updated with actual slots you will have instead of a calendar with all slots. You also get all the stages, including the cape town changes.

Screenshot 2023-09-11 at 13.11.51

1 Like

Thanks I saw that one and I think what I put down above is the same. I.e. it’s dynamic and area specific.

It doesn’t tell you the current stage though.

Hi @lrossouw
I did a video on setting up ESP in HASSIO as well as one to automatically adjust your inverter settings based on the level of load shedding (keep extra battery in reserve when at higher levels for example)

and

I hope you find them useful :slight_smile: