Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed null CT error #23

Merged
merged 1 commit into from
Jan 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading