Skip to content

Commit

Permalink
Add workaround to odd curfew API response
Browse files Browse the repository at this point in the history
  • Loading branch information
therefromhere committed Apr 6, 2024
1 parent 9806785 commit c8973ea
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion surepy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import asyncio
import logging

from datetime import datetime, time
from datetime import datetime, time, timedelta
from http import HTTPStatus
from http.client import HTTPException
from logging import Logger
Expand Down Expand Up @@ -407,6 +407,21 @@ async def set_curfew(
# check if the state is correctly updated
if state == desired_state:
return response
else:
bugged_unlock_time = unlock_time.replace(unlock_time.hour - 1)

bug_state = [{
"lock_time": lock_time.strftime("%H:%M"),
"unlock_time": bugged_unlock_time.strftime("%H:%M"),
"enabled": True,
}]

if state == bug_state:
# known issue, don't raise exception
logger.warning("unlock_hour off by one - set %s, got %s (see https://github.com/benleb/surepy/issues/209)", desired_state, state)
return response

logger.error("Error setting curfew, set %s, got %s", desired_state, state)

# return None
raise SurePetcareError("ERROR SETTING CURFEW - PLEASE CHECK IMMEDIATELY!")
Expand Down

0 comments on commit c8973ea

Please sign in to comment.