Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 414fbd3

Browse files
authored
Fixed null CT error (#23)
1 parent 2c7d64c commit 414fbd3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

custom_components/ohme/api_client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ async def _post_request(self, url, skip_json=False, data=None):
118118
data=data,
119119
headers=self._get_headers()
120120
) as resp:
121+
_LOGGER.debug(f"POST request to {url}, status code {resp.status}")
121122
await self._handle_api_error(url, resp)
122123

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

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

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

250253
# If we ever get a reading above 0, assume CT connected
251-
if resp['clampAmps'] > 0:
254+
if resp['clampAmps'] and resp['clampAmps'] > 0:
252255
self._ct_connected = True
253256

254257
return resp['clampAmps']

0 commit comments

Comments
 (0)