Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion sense_energy/asyncsenseable.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import aiohttp
import json
import websockets
import ssl

from .sense_api import *
from .sense_exceptions import *
Expand All @@ -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:
Expand Down Expand Up @@ -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(
Expand Down