Skip to content

Commit

Permalink
Add timeout to prevent home assistant block on startup when sense is …
Browse files Browse the repository at this point in the history
…down (#32)

* Add timeout to prevent home assistant block on startup when sense is down

* Use SenseAPITimeoutException to incdicate failure
  • Loading branch information
bdraco authored Mar 10, 2020
1 parent 045e670 commit 6f37765
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sense_energy/asyncsenseable.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ async def authenticate(self, username, password):
try:
async with aiohttp.ClientSession() as session:
async with session.post(API_URL+'authenticate',
timeout=self.api_timeout,
data=auth_data) as resp:

# check for 200 return
Expand All @@ -29,7 +30,7 @@ async def authenticate(self, username, password):
# Build out some common variables
self.set_auth_data(await resp.json())
except Exception as e:
raise Exception('Connection failure: %s' % e)
raise SenseAPITimeoutException('Connection failure: %s' % e)

# Update the realtime data for asyncio
async def update_realtime(self):
Expand Down

0 comments on commit 6f37765

Please sign in to comment.