Closed leonw1090 closed 1 year ago
I also have the same issue, I however also noticed that my mushroom card was showing default value as ON
So looking into the STATES
My card code i believe is correct,
type: markdown
content: >
{% set stage_sensor = "sensor.load_shedding_stage_eskom" %} {% set
area_sensor = "sensor.load_shedding_area_jhbcitypower2_2_greymont" %} {% set
start_time = state_attr(stage_sensor, "start_time") %} {% set end_time =
state_attr(stage_sensor, "end_time") %} {% set area_schedule =
state_attr(area_sensor, "forecast") %}
{% if area_schedule %}
{% set start_time = area_schedule[0].start_time %}
{% set end_time = area_schedule[0].end_time %}
{% if is_state(area_sensor, "off") %}
{% set starts_in = timedelta(minutes=state_attr(area_sensor, "starts_in")).total_seconds() | int // 60 %}
{% set mins = starts_in % 60 %}
{% set hrs = starts_in // 60 % 24 %}
{% set days = starts_in // 1440 %}
{% set alert = "Load Shedding starts in {d}d {h}h {m}m ({next})".format(d=days, m=mins, h=hrs, next=as_timestamp(start_time) | timestamp_custom("%H:%M", True)) %}
{% if is_state_attr(stage_sensor, "stage", 0) %}
<ha-alert alert-type="success">{{ states(stage_sensor) }}</ha-alert>
{% elif starts_in > 1440 %}
<ha-alert alert-type="success">{{ alert }}</ha-alert>
{% elif not is_state_attr(stage_sensor, "stage", 0) and 60 < starts_in <= 1440 %}
<ha-alert alert-type="warning">{{ alert }}</ha-alert>
{% else %}
<ha-alert alert-type="error">{{ alert }}</ha-alert>
{% endif %}
{% else %}
{% set ends_in = timedelta(minutes=state_attr(area_sensor, "ends_in")).total_seconds() | int // 60 %}
{% set mins = ends_in % 60 %}
{% set hrs = ends_in // 60 % 24 %}
{% set days = ends_in // 1440 %}
{% set alert = "Load Shedding ends in {d}d {h}h {m}m ({next})".format(d=days, m=mins, h=hrs, next=as_timestamp(end_time) | timestamp_custom("%H:%M", True)) %}
<ha-alert alert-type="error">{{ alert }}</ha-alert>
{% endif %}
{% endif %}
yet i still get the display incorrectly
After writing all this i also wonder is it has something to do with No Load Shedding that the card is not pulling the next piece of information, Will report back when the API updates to Load Shedding
Stage 2 Started, restarted HA, (as i was updating another addon, and now this Still showing the Load Shedding ends in 0d 0h 0m (18:30)
also not sure what is wrong with my top code in the mushroom chip card
Unfortunately not, I even used the whole card and only changed my area, the second i did that, it changed to the same as we are getting. My card on the left, your direct copy on the right, just with the area changed
Here is currently what i have in my STATES section I see that my default value is ON, but that should be off, as I am not currently loadshedding although Stage 2 is implemented.
I made some tweaks to the card this morning. See if this solves it.
Thank you for your time. Unfortunately the problem persists. I have noticed under the area sensor a few attributes are missing data. Could this be a reason.
Updated to dev6, still same problem :-(
Also updated. But no change đ
I made some tweaks to the card this morning. See if this solves it.
I believe this line need to change from {% if is_state(area_sensor, "off") %} to {% if is_state(area_sensor, "on") %} at least it appears to have fixed it or me.
Also updated API entity_id.
Cool, will investigate.
I believe this line need to change from {% if is_state(area_sensor, "off") %} to {% if is_state(area_sensor, "on") %} at least it appears to have fixed it or me.
This is not a fix, the State should be OFF when load shedding is off, and ON when Load Shedding is on, so the fix is only masking the actual problem
also i see that that your screen shot still shows a Load shed that happened 5 hours ago, I am pretty sure that is not meant to be there.
However now that we are actually loadshedding, this is now working, so there must be something not right when were are NOT loadshedding
i still however notice even though I am currently load shedding that this is still wonky (hoping someone can give me an if / else command in a template to fix this
Hope that the information we are providing is helping
I have made some more changes. I will test some more and see if it works as expected.
As for the last load shedding that happened 5 hours ago still showing, maybe Werner can comment on how often the calendar entity is updated, which would remove the old times, but it from my limited monitoring of it, it only seems to update once a day.
There is an option in the Atomic Calendar Revive card which can be added to hide finished events.
hideFinishedEvents: true
Edit: Code removed as it doesn't work
Ok, made some modifications. Let's see if v1.1.0-dev.7 resolves it.
Sensors refresh every minute in order for the starts_in
and ends_in
attributes to work correctly.
Data is fetched from the API as follows
When posting code use the these tags to format code.
<details>
<summary>Code</summary>
```yaml
EXAMPLE YAML GOES HERE
<details>
<summary>Code</summary>
```yml
EXAMPLE YAML GOES HERE
When including images, resize them by using the img
tag and specifying a width
.
<img src="https://path/to/image" width="25%"/>
Preview before posting.
This helps keep long issues a bit more readable.
Good Morning,
On my side (Dev 1.1.0-7) fixed my issue. The Area is turns off when there is no loadshedding. So the card is perfect. Will continue to test when there is no load shedding.
Just a sidebar comment.... LOVE the new API refresh time. It works well ! well done @wernerhp
@wernerhp All looking good on my end too, Thank you so much for all the time and effort you dedicated to this project, for me this is not just information, I have it set for warnings when load shedding is going to start, and i have started to set up automations for my watering system to postpone the waterting till the evening if load shedding occurred in the morning (obviously when it has not been raining that day too). I am looking into switchbot to physically push the buttons on UPS systems that are not in use (eg PC is not on, but still connected to mains power) so the batteries dont die when there is Load Shedding so for me these are just some of the things that this integration does and will do to make my life easier "automatically." so again, a big thank you
@leonw1090
Just a sidebar comment.... LOVE the new API refresh time. It works well
did i miss something? I know i hashed together and 90 minute refresh time since the last time the API updated, is there something else that is more sturdy or reliable? or did i totally misread what you were saying? (i like all the bells and whistles) :-)
Thanks for the feedback.
Just a sidebar comment.... LOVE the new API refresh time. It works well ! well done
This makes better use of the API quota. Previously used around 32 from the API quota per day (16 for Stage and 16 for Area) every 90 minutes. Now uses 25 per day (24 for Stage updated hourly and 1 for Area updated daily). Future work will be to support multiple Area sensors, which should add just 1 API call.
I have it set for warnings when load shedding is going to start, and i have started to set up automations for my watering system to postpone the waterting till the evening if load shedding occurred in the morning (obviously when it has not been raining that day too).
That sounds neat. Please feel free to share your automations here.
Please consider buying me a coffee to support my work.
That sounds neat. Please feel free to share your automations https://github.com/wernerhp/ha.integration.load_shedding/issues/5.
I will do, I dont mind sharing
Please consider buying me a coffee to support my work.
Done, have a coffee break or two..... until next time :-)
Thanks for the coffee đ
Looks like there was a little bug causing the area sensor to get stuck on off. Fixed in dev.8
.
Looks like there was a little bug causing the area sensor to get stuck on off. Fixed in
dev.8
.
unfortunately i don't see a dev 8,
Just as well. Issue was not fixed. Hopefully I got it now. đ You can try to Update information or Redownload
Looks like I botched it trying to make the sensor restore it's state after a restart. I need to take some time to dig into the HA code to better understand how this work.
We have faith in you
v1.1.0-dev.9 seems to work great. my load shedding just ended and the timer changed to count down to the next load shedding tomorrow and the forecast (markdown card) also updated.
@gregcsw Awesome! Thanks for the feedback. đ
Everything is working fantastically, Wit the announcement of stage 3 , even the Next Stage section is working.
I believe this is the answer. Also love the way that Stage 2 and Stage 3 overlap each other, makes it very clear to read. Thanks for all the effort again. My card is full of relevant information. Lets hope that they dont go changing things for a while. (Lets hope Load Shedding ends)
Hi,
Thank you for the amazing work being done!
I have the following error. (running dev 1.1.0-5) when copying the card without changing the data (so area is still sensor.load_shedding_area_eskde_14_milnertoncityofcapetownwesterncape) the card shows the correct info on when is the next stage of load shedding etc. is. But obviously it does not show anything when load shedding starts because I do not have sensor.load_shedding_area_eskde_14_milnertoncityofcapetownwesterncape listed anywhere. I then fix it to set area to sensor.load_shedding_area_tshwane_2_faerieglenext7 then the stage prediction breaks of when the next load shedding change will be but my schedule is fixed.
Please find the 2 examples attached.
Am I missing something? all the data is correct when looking under the sensors. and the calender.
Regards