Skip to content

Commit

Permalink
Fixed null CT error (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-r committed Jan 1, 2024
1 parent 2c7d64c commit 414fbd3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion custom_components/ohme/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ async def _post_request(self, url, skip_json=False, data=None):
data=data,
headers=self._get_headers()
) as resp:
_LOGGER.debug(f"POST request to {url}, status code {resp.status}")
await self._handle_api_error(url, resp)

if skip_json:
Expand All @@ -133,6 +134,7 @@ async def _put_request(self, url, data=None):
data=json.dumps(data),
headers=self._get_headers()
) as resp:
_LOGGER.debug(f"PUT request to {url}, status code {resp.status}")
await self._handle_api_error(url, resp)

return True
Expand All @@ -144,6 +146,7 @@ async def _get_request(self, url):
url,
headers=self._get_headers()
) as resp:
_LOGGER.debug(f"GET request to {url}, status code {resp.status}")
await self._handle_api_error(url, resp)

return await resp.json()
Expand Down Expand Up @@ -248,7 +251,7 @@ async def async_get_ct_reading(self):
resp = await self._get_request(f"/v1/chargeDevices/{self._serial}/advancedSettings")

# If we ever get a reading above 0, assume CT connected
if resp['clampAmps'] > 0:
if resp['clampAmps'] and resp['clampAmps'] > 0:
self._ct_connected = True

return resp['clampAmps']
Expand Down

0 comments on commit 414fbd3

Please sign in to comment.