diff --git a/sense_energy/asyncsenseable.py b/sense_energy/asyncsenseable.py index 279051f..2125e4f 100644 --- a/sense_energy/asyncsenseable.py +++ b/sense_energy/asyncsenseable.py @@ -2,6 +2,7 @@ import aiohttp import json import websockets +import ssl from .sense_api import * from .sense_exceptions import * @@ -14,6 +15,8 @@ async def authenticate(self, username, password): "password": password } + self.ssl_context = ssl.create_default_context() + # Get auth token try: async with aiohttp.ClientSession() as session: @@ -45,7 +48,7 @@ async def async_realtime_stream(self, callback=None, single=False): """ Reads realtime data from websocket""" url = WS_URL % (self.sense_monitor_id, self.sense_access_token) # hello, features, [updates,] data - async with websockets.connect(url) as ws: + async with websockets.connect(url, ssl=self.ssl_context) as ws: while True: try: message = await asyncio.wait_for(