Skip to content

Commit

Permalink
- handle http 400
Browse files Browse the repository at this point in the history
- logging post data
  • Loading branch information
marq24 committed Jan 2, 2024
1 parent ca967ca commit c1840b4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions custom_components/senec/pysenec_ha/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1956,6 +1956,7 @@ async def write(self, data):
await self.write_senec_v31(data)

async def write_senec_v31(self, data):
_LOGGER.debug(f"posting data: {data}")
async with self.web_session.post(self.url, json=data, ssl=False) as res:
try:
res.raise_for_status()
Expand Down Expand Up @@ -2429,6 +2430,8 @@ async def app_get_data(self, a_url: str) -> dict:
except Exception as exc:
if res.status == 500:
_LOGGER.info(f"APP-API: Wallbox Not found {a_url} [HTTP 500]: {exc}")
if res.status == 400:
_LOGGER.info(f"APP-API: Wallbox Not found {a_url} [HTTP 400]: {exc}")
if res.status == 401:
_LOGGER.info(f"APP-API: Wallbox No permission {a_url} [HTTP 401]: {exc}")
self._app_is_authenticated = False
Expand Down Expand Up @@ -2537,6 +2540,8 @@ async def app_post_data(self, a_url: str, post_data: dict, read_response: bool =
except Exception as exc:
if res.status == 500:
_LOGGER.info(f"APP-API: Not found {a_url} [HTTP 500]: {exc}")
if res.status == 400:
_LOGGER.info(f"APP-API: Not found {a_url} [HTTP 400]: {exc}")
if res.status == 401:
_LOGGER.info(f"APP-API: No permission {a_url} [HTTP 401]: {exc}")
self._app_is_authenticated = False
Expand Down

0 comments on commit c1840b4

Please sign in to comment.