Sensor to show if electricity is on/off, by looking at current loadshedding schedule

Hi, I want to make a sensor template to show me if my electricity is on/off at my house. I plan to use the Loadshedding Status Integration which gives me a value if there is currently loadshedding.

The integration makes the attribute ‘Currently Loadshedding’ from the entity: ‘sensor.loadshedding_local_status’ true/false depending on if there is currently loadshedding or not.

My current configuration.yaml file:

      home_electricity:
        friendly_name: "Home Electricity"
        value_template: >-
          {% if stateattr(('sensor.loadshedding_local_status', 'Currently Loadshedding') == "false") %}
            On
          {% if stateattr(('sensor.loadshedding_local_status', 'Currently Loadshedding') == "true") %}
            Off
          {% else %}
            Unavailable
          {% endif %}
        icon_template: >-
          {% if stateattr(('sensor.loadshedding_local_status', 'Currently Loadshedding') == "false") %}
            mdi:home-lightning-bolt
          {% if stateattr(('sensor.loadshedding_local_status', 'Currently Loadshedding') == "true") %}
            mdi:home-lightning-bolt-outline
          {% else %}
            mdi:alert
          {% endif %}

The error Home Assistant gives me:

Invalid config for [sensor.template]: invalid template (TemplateSyntaxError: Unexpected end of template. Jinja was looking for the following tags: 'elif' or 'else' or 'endif'. The innermost block that needs to be closed is 'if'.) for dictionary value @ data['sensors']['home_electricity']['icon_template']. Got '{% if stateattr((\'sensor.loadshedding_local_status\', \'Currently Loadshedding\') == "false") %}\n mdi:home-lightning-bolt\n{% if stateattr((\'sensor.loadshedding_local_status\', \'Currently Loadshedding\') == "true") %}\n mdi:home-lightning-bolt-outline\n{% else %}\n mdi:alert\n{% endif %}' invalid template (TemplateSyntaxError: Unexpected end of template. Jinja was looking for the following tags: 'elif' or 'else' or 'endif'. The innermost block that needs to be closed is 'if'.) for dictionary value @ data['sensors']['home_electricity']['value_template']. Got '{% if stateattr((\'sensor.loadshedding_local_status\', \'Currently Loadshedding\') == "false") %}\n On\n{% if stateattr((\'sensor.loadshedding_local_status\', \'Currently Loadshedding\') == "true") %}\n Off\n{% else %}\n Unavailable\n{% endif %}'. (See ?, line ?).

I think the error said the second “if” need to be “else if” … try this

        value_template: >-
          {% if stateattr(('sensor.loadshedding_local_status', 'Currently Loadshedding') == "false") %}
            On
          {% elif stateattr(('sensor.loadshedding_local_status', 'Currently Loadshedding') == "true") %}
            Off
          {% else %}
            Unavailable
          {% endif %}

Thanks, it worked.