Skip to content

Commit

Permalink
Handle request failure for some of the modules #66
Browse files Browse the repository at this point in the history
  • Loading branch information
erikkastelec committed May 8, 2023
1 parent a304ca7 commit 7a10f56
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion custom_components/wemportal/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"documentation": "https://github.com/erikkastelec/hass-WEM-Portal",
"issue_tracker": "https://github.com/erikkastelec/hass-WEM-Portal/issues",
"dependencies": [],
"version": "1.5.5",
"version": "1.5.6",
"codeowners": [
"@erikkastelec"
],
Expand Down
15 changes: 12 additions & 3 deletions custom_components/wemportal/wemportalapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ def get_devices(self):
break

def get_parameters(self):
assert self.modules is not None
for device_id in self.data.keys():
if self.data[device_id]["ConnectionStatus"] != 0:
continue
Expand All @@ -304,9 +305,17 @@ def get_parameters(self):
"ModuleIndex": values["Index"],
"ModuleType": values["Type"],
}
response = self.make_api_call(
"https://www.wemportal.com/app/EventType/Read", data=data
)
try:
response = self.make_api_call(
"https://www.wemportal.com/app/EventType/Read", data=data
)
except WemPortalError as exc:
if isinstance(exc, reqs.exceptions.HTTPError) and exc.response.status_code == 400:
_LOGGER.error("Could not fetch parameters for device %s for index %s and type %s", device_id, values["Index"], values["Type"])
delete_candidates.append((values["Index"], values["Type"]))
continue
else:
raise
_LOGGER.debug(response.json())
parameters = {}
try:
Expand Down

0 comments on commit 7a10f56

Please sign in to comment.