Skip to content

Commit fffe7bd

Browse files
authored
Protect against null response payloads (#253)
* Protect against null response payloads * Simplify
1 parent c2be077 commit fffe7bd

2 files changed

Lines changed: 2 additions & 5 deletions

File tree

simplipy/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,12 @@ async def _request(
191191

192192
LOGGER.debug("Data received from /%s: %s", endpoint, data)
193193

194-
if data.get("error") == "mfa_required":
194+
if data and data.get("error") == "mfa_required":
195195
# If we get an "error" related to MFA, the response body data is
196196
# necessary for continuing on, so we swallow the error and return
197197
# that data:
198198
return data
199-
if data.get("type") == "NoRemoteManagement":
199+
if data and data.get("type") == "NoRemoteManagement":
200200
raise EndpointUnavailableError(
201201
f"Endpoint unavailable in plan: {endpoint}"
202202
) from None

simplipy/lock.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ class LockStates(Enum):
1515
unknown = 99
1616

1717

18-
STATE_MAP = {1: LockStates.locked, 2: LockStates.unlocked}
19-
20-
2118
class Lock(EntityV3):
2219
"""A lock that works with V3 systems.
2320

0 commit comments

Comments
 (0)