Skip to content

Commit

Permalink
Address corrections in related PRs
Browse files Browse the repository at this point in the history
Address corrections in PR #42, #43, #44
  • Loading branch information
Snuffy2 committed Oct 9, 2023
1 parent f472026 commit 0d407df
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
13 changes: 5 additions & 8 deletions custom_components/healthchecksio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ async def async_unload_entry(
curr_plat,
)
if unload_ok:
hass.data[DOMAIN_DATA].pop(DATA_CLIENT, None)
hass.data[DOMAIN_DATA].pop(DATA_DATA, None)
hass.data.pop(DOMAIN_DATA, None)
_LOGGER.info("Successfully removed the HealthChecks.io integration")

return unload_ok
Expand Down Expand Up @@ -166,12 +165,10 @@ async def update_data(self):
else:
_LOGGER.debug("Send Check is not defined")
try:
async with session.get(
f"{self.site_root}/api/v1/checks/",
headers=headers,
timeout=timeout10,
) as data:
self.hass.data[DOMAIN_DATA][DATA_DATA] = await data.json()
data = await session.get(
f"{self.site_root}/api/v1/checks/", headers=headers, timeout=timeout10
)
self.hass.data[DOMAIN_DATA][DATA_DATA] = await data.json()
except (aiohttp.ClientError, asyncio.TimeoutError) as error:
_LOGGER.error(f"Could Not Update Data: {error}")
except (ValueError, json.decoder.JSONDecodeError) as error:
Expand Down
17 changes: 7 additions & 10 deletions custom_components/healthchecksio/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,25 +64,22 @@ async def _test_credentials(
else:
_LOGGER.debug("Send Check is not defined")
try:
async with session.get(
f"{site_root}/api/v1/checks/",
headers=headers,
timeout=timeout10,
) as data:
hass.data[DOMAIN_DATA] = {"data": await data.json()}
data = await session.get(
f"{site_root}/api/v1/checks/", headers=headers, timeout=timeout10
)
hass.data[DOMAIN_DATA] = {"data": await data.json()}
except (aiohttp.ClientError, asyncio.TimeoutError) as error:
_LOGGER.error(f"Could Not Update Data: {error}")
return False
except (ValueError, json.decoder.JSONDecodeError) as error:
_LOGGER.error(f"Data JSON Decode Error: {error}")
return False
else:
if data.ok:
_LOGGER.debug(f"Get Data HTTP Status Code: {data.status}")
return True
else:
if not data.ok:
_LOGGER.error(f"Error: Get Data HTTP Status Code: {data.status}")
return False
_LOGGER.debug(f"Get Data HTTP Status Code: {data.status}")
return True


class HealchecksioConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
Expand Down

0 comments on commit 0d407df

Please sign in to comment.