Skip to content

Commit

Permalink
Merge pull request #25 from swartjean/issue-22
Browse files Browse the repository at this point in the history
Fixed API key validation (#22)
  • Loading branch information
swartjean authored Oct 12, 2022
2 parents e899dbc + 7dba352 commit a8f9d9a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions custom_components/eskom_loadshedding/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,11 @@ async def validate_key(self, api_key: str) -> bool:
try:
session = async_create_clientsession(self.hass)
interface = EskomInterface(session=session, api_key=api_key)
await interface.async_query_api("/api_allowance")
return True
data = await interface.async_query_api("/api_allowance")
if "error" in data:
return False
else:
return True
except Exception: # pylint: disable=broad-except
pass
return False
Expand Down

0 comments on commit a8f9d9a

Please sign in to comment.