Open w1tw0lf opened 2 years ago
Some of the sensor we created that might benefit here as well.
https://github.com/w1tw0lf/homeassitant/blob/main/eskomsepush.yaml
Thanks @w1tw0lf, I will try take a look this evening and give some feedback.
Also maybe a sensor to show the eskomsepush status, like we had on the forums
Can you please point me to an example of this?
The code shared in the yaml is a mix of code from mybb, https://mybroadband.co.za/forum/threads/anyone-figured-how-to-use-eskomsepush-to-control-switches-on-ha.1195256/
Looking at it now, the first rest sensor was a value template, that had static status of ok... think it might have gotten confused and used as a way of checking eskomsepush status. Sorry, my mistake... just thinking it can be something like add to existing sensor to check if their is a valid response when doing an update check.
+1 for this - Even just the Next_Loadshedding_Event would be helpful.
I want to show how long to go before the next Load Shedding
That part is easy with a value template sensor.
{%if is_state('sensor.loadshedding_local_status', '0') %}none{%else%} In {{ ((as_timestamp(state_attr('calendar.loadshedding_local_schedule', 'start_time') | as_datetime)-as_timestamp(now())) | int /60) | round(0) }} mins {%endif%}
Wouldn´t mind splitting it in to hours and minutes, but haven´t been able to get that part right.
Thanks @w1tw0lf - I only saw your reply this morning.
Got a little carried away, but I made this:
The chip is dynamic, when load_shedding_countdown is none
, it will not show.
When you are NOT load shedding, but there is an upcoming schedule, it will do a countdown until Load Shedding will START.
When you ARE load shedding, it will then adjust the icon, and countdown until Load Shedding will END.
Also, when there is less than 1 hour remaining, it will only show minutes
- sensor:
- name: Load shedding start time
unique_id: "load_shedding_start_time"
state: >
{{ (((as_timestamp(state_attr('calendar.loadshedding_local_schedule', 'start_time') | as_datetime) - as_timestamp(now()))) | round(0)) }}
- sensor:
- name: Load shedding end time
unique_id: "load_shedding_end_time"
state: >
{{ (((as_timestamp(state_attr('calendar.loadshedding_local_schedule', 'end_time') | as_datetime) - as_timestamp(now()))) | round(0)) }}
- sensor:
- name: Load shedding countdown
unique_id: "load_shedding_countdown"
state: >
{% if is_state('sensor.loadshedding_local_status', '0') %}
none
{% elif is_state('calendar.loadshedding_local_events', 'off') %}
{% if states('sensor.load_shedding_start_time') | int > 0 %}
{% if states('sensor.load_shedding_start_time') | int < 3600 %}
{% if is_state('sensor.loadshedding_local_status', '0') %}none{%else%}in {{ states('sensor.load_shedding_start_time') | int | timestamp_custom('%-M min', false) }}{%endif%}
{% else%}
{% if is_state('sensor.loadshedding_local_status', '0') %}none{%else%}in {{ states('sensor.load_shedding_start_time') | int | timestamp_custom('%-H hrs & %-M min', false) }}{%endif%}
{% endif %}
{% else%}
none
{% endif %}
{% else%}
{% if states('sensor.load_shedding_end_time') | int > 0 %}
{% if states('sensor.load_shedding_end_time') | int < 3600 %}
{% if is_state('sensor.loadshedding_local_status', '0') %}none{%else%}in {{ states('sensor.load_shedding_end_time') | int | timestamp_custom('%-M min', false) }}{%endif%}
{% else%}
{% if is_state('sensor.loadshedding_local_status', '0') %}none{%else%}in {{ states('sensor.load_shedding_end_time') | int | timestamp_custom('%-H hrs & %-M min', false) }}{%endif%}
{% endif %}
{% else%}
none
{% endif %}
{% endif %}
icon: >
{% if is_state("calendar.loadshedding_local_events", "off") %}
mdi:home-lightning-bolt
{% else %}
mdi:home-lightning-bolt-outline
{% endif %}
@swartjean How often or when does the Attributes change for calendar.loadshedding_local_events?
I have another event coming up later today:
This event ended 13 minutes ago, how long before it changes to the next event in the Calendar?
Thanks
NVM - Seems to be 15 minutes after the previous event ended...
Hey @louispires, sorry for the delay. See this comment in #24.
The calendar state updates every 30 seconds, which means that you should see calendar.loadshedding_local_events
change from true to false within 30 seconds of an event ending.
The upcoming calendar events are updated every 15 minutes, so you should see old events removed from the calendar within 15 minutes of them ending. It's not tied to the event itself ending - I think you must have just gotten a bit unlucky with the timing of the previous update being just before the end of the event.
I seem to remember the 15 minute update period for event being a home assistant core thing. I will investigate a bit to see whether it can be made configurable.
Thanks @w1tw0lf - I only saw your reply this morning.
Got a little carried away, but I made this:
The chip is dynamic, when load_shedding_countdown is
none
, it will not show.When you are NOT load shedding, but there is an upcoming schedule, it will do a countdown until Load Shedding will START.
When you ARE load shedding, it will then adjust the icon, and countdown until Load Shedding will END.
Also, when there is less than 1 hour remaining, it will only show minutes
- sensor: - name: Load shedding start time unique_id: "load_shedding_start_time" state: > {{ (((as_timestamp(state_attr('calendar.loadshedding_local_schedule', 'start_time') | as_datetime) - as_timestamp(now()))) | round(0)) }} - sensor: - name: Load shedding end time unique_id: "load_shedding_end_time" state: > {{ (((as_timestamp(state_attr('calendar.loadshedding_local_schedule', 'end_time') | as_datetime) - as_timestamp(now()))) | round(0)) }} - sensor: - name: Load shedding countdown unique_id: "load_shedding_countdown" state: > {% if is_state('sensor.loadshedding_local_status', '0') %} none {% elif is_state('calendar.loadshedding_local_events', 'off') %} {% if states('sensor.load_shedding_start_time') | int > 0 %} {% if states('sensor.load_shedding_start_time') | int < 3600 %} {% if is_state('sensor.loadshedding_local_status', '0') %}none{%else%}in {{ states('sensor.load_shedding_start_time') | int | timestamp_custom('%-M min', false) }}{%endif%} {% else%} {% if is_state('sensor.loadshedding_local_status', '0') %}none{%else%}in {{ states('sensor.load_shedding_start_time') | int | timestamp_custom('%-H hrs & %-M min', false) }}{%endif%} {% endif %} {% else%} none {% endif %} {% else%} {% if states('sensor.load_shedding_end_time') | int > 0 %} {% if states('sensor.load_shedding_end_time') | int < 3600 %} {% if is_state('sensor.loadshedding_local_status', '0') %}none{%else%}in {{ states('sensor.load_shedding_end_time') | int | timestamp_custom('%-M min', false) }}{%endif%} {% else%} {% if is_state('sensor.loadshedding_local_status', '0') %}none{%else%}in {{ states('sensor.load_shedding_end_time') | int | timestamp_custom('%-H hrs & %-M min', false) }}{%endif%} {% endif %} {% else%} none {% endif %} {% endif %} icon: > {% if is_state("calendar.loadshedding_local_events", "off") %} mdi:home-lightning-bolt {% else %} mdi:home-lightning-bolt-outline {% endif %}
This is amazing - exactly what I was trying to figure out how to do. I am a newby - where does this code go? Into the configuration.yaml, or directly to a chip card? Or something else?
This is amazing - exactly what I was trying to figure out how to do. I am a newby - where does this code go? Into the configuration.yaml, or directly to a chip card? Or something else?
Yeah, simply add a Template section to your configuration.yaml
and add these sensors underneath.
Hey @louispires, sorry for the delay. See this comment in #24.
The calendar state updates every 30 seconds, which means that you should see
calendar.loadshedding_local_events
change from true to false within 30 seconds of an event ending.The upcoming calendar events are updated every 15 minutes, so you should see old events removed from the calendar within 15 minutes of them ending. It's not tied to the event itself ending - I think you must have just gotten a bit unlucky with the timing of the previous update being just before the end of the event.
I seem to remember the 15 minute update period for event being a home assistant core thing. I will investigate a bit to see whether it can be made configurable.
BTW, this kind of got more noticeable...
These attributes take up to 1 hour to update after load shedding ends, for instance today after 14:30, these will all stay the same up to like 15:30...
I manually reload the integration to force the update.
It seems we need the ability to force an API update. From my experience local events status will not change until an API call is made to ESP.
@swartjean any chance you can add a service so that we can force an API update? I find that I need to reloasd the integration to get an update on the calendar for the next LS time in the day for instance instead of waiting for it to happen automatically. I want to be able to do an update after power has been restored to ensure that everything is up-to-date.
As per mybroadband.
Small suggesttion, the 2 calendar entries feels like a duplication of each other. Can you perhaps look at changing one to a national schedule ? As an example, where loadsheding in active, like today, 16:00 till 00:00.
Also maybe make Cape Town an option when adding the intergration.
Also maybe a sensor to show the eskomsepush status, like we had on the forums