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

Component not starting up #11

Closed
ipodmusicman opened this issue May 6, 2021 · 9 comments
Closed

Component not starting up #11

ipodmusicman opened this issue May 6, 2021 · 9 comments

Comments

@ipodmusicman
Copy link

Version of the custom_component

1.0.3

Home Assistant Version:

2021.05

After upgrading to 2021.05, the component is just not starting up. I turned on debug logging for this component as below:

logger:
default: info
logs:
custom_components.eskom_loadshedding: debug

These are the only log lines I found whereby the component is mentioned.

2021-05-06 20:01:30 INFO (MainThread) [homeassistant.setup] Setting up eskom_loadshedding
2021-05-06 20:01:30 INFO (MainThread) [custom_components.eskom_loadshedding]

Eskom Loadshedding Interface
Version: 1.0.3
Welcome to the Eskom Loadshedding Interface!
If you have any issues with this you need to open an issue here:
https://github.com/swartjean/ha-eskom-loadshedding/issues

2021-05-06 20:02:01 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: eskom_loadshedding
2021-05-06 20:03:02 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: eskom_loadshedding
2021-05-06 20:04:02 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: eskom_loadshedding
2021-05-06 20:05:02 WARNING (MainThread) [homeassistant.bootstrap] Waiting on integrations to complete setup: eskom_loadshedding
2021-05-06 20:06:23 ERROR (MainThread) [custom_components.eskom_loadshedding] Error fetching eskom_loadshedding data: Error, invalid loadshedding stage received from API after 50 attempts
2021-05-06 20:06:23 DEBUG (MainThread) [custom_components.eskom_loadshedding] Finished fetching eskom_loadshedding data in 293.107 seconds
2021-05-06 20:06:23 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Home' for eskom_loadshedding integration not ready yet: None; Retrying in background

I uninstalled the integration, installed it back, no luck whatsoever.

I even called https://loadshedding.eskom.co.za/LoadShedding/GetStatus from within my browser and it returns a result.

I hope that you'll be able to assist.

@swartjean
Copy link
Owner

Hi @ipodmusicman,

Unfortunately this is the same issue that was raised earlier today in #10.

The Eskom API seems to be having some issues (note how it always returns a result of -1) and there isn't much that I can do on the integration side to remedy it.

I may be able to refine the startup procedure a bit, but the integration itself will still be broken until Eskom sorts their API out.

@cschutte
Copy link

cschutte commented May 6, 2021

Yes, it is not related to 2021.5 - the failure started this morning at around 5:41am, and I was then still on 2021.4.x.

@tinuva
Copy link

tinuva commented May 7, 2021

Doesn't -1 mean a loadshedding stage of 0 ?

Edit:
Sorry I realize it is the other way around. -1 would mean stage -2.

Can you set the sensor to stage 0 when we receive -1 or 0 or 1 from the Eskom API endpoint? Will fix the integration for now. I think the -1 means eskom have like a 1000MW reserve or something. It shouldn't cause the integration to stop working.

@tinuva
Copy link

tinuva commented May 7, 2021

So to explain the edit:

stage 0 = Eskom meets demand
stage 1 = Eskom needs to shed 1000MW load
stage 2 = Eskom needs to shed 2000MW load
stage -1 = Eskom has 1000MW reserve over and above demand
stage -2 = Eskom has 2000MW reserve over and above demand

So essentially, the eskom api is not currently broken, but the integration is broken for not taking this into account. The integration should set the loadshedding stage entity to 0 when the API responds with -1 or -2 or -3 etc.

@tinuva
Copy link

tinuva commented May 7, 2021

Or rather, if the -1 really mean the site is broken, at least let the integration start up, with a stage 0 or whatever the last stage was in the recorder.

@swartjean
Copy link
Owner

@tinuva I will look into this change.

I have definitely seen cases in the past where the API will return -1 while loadshedding is in fact active, so -1 is almost certainly not always a valid state.

For now I will probably still have the integration attempt to retry if a state of -1 is obtained, but if the maximum number of attempts is exceeded I will just return a state of 0.

This means that the integration will only be unavailable if the API cannot be reached or does not return anything at all.

@tinuva
Copy link

tinuva commented May 7, 2021

Yeah I think you are correct, sometimes the -1 happens while loadshedding is active. Annoying right now haha.

@ipodmusicman
Copy link
Author

@tinuva When I was still referring to the URL in a curl command, no loadshedding is 1, stage 1 is 2, etc. I agree, if it returns -1 after a couple of retires, return 0. Just a pity that there aren't any other APIs out there where you can coincide the stage with the actual schedule.

@swartjean
Copy link
Owner

I have pushed a fix and a new version with this change, please check it out and confirm that the stage goes back to 0, then we can close this issue 👍

The integration will still take a few seconds to start as it needs to run through all of the API attempts before giving up and returning 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants