Skip to content

Commit

Permalink
added lookup_url as a parameter for Connection and AsyncConnection.
Browse files Browse the repository at this point in the history
This should make test cases easier.
  • Loading branch information
coreGreenberet committed May 22, 2018
1 parent cf0ae94 commit 906a21a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 2 additions & 3 deletions homematicip/async/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ def ws_connected(self):
"""Websocket is connected."""
return self.socket_connection is not None

async def init(self, accesspoint_id, lookup=True, **kwargs):
async def init(self, accesspoint_id, lookup=True, lookup_url="https://lookup.homematic.com:48335/getHost", **kwargs):
self.set_token_and_characteristics(accesspoint_id)

if lookup:
result = await self.api_call("https://lookup.homematic.com:48335/getHost",
json.dumps(self.clientCharacteristics), full_url=True)
result = await self.api_call(lookup_url, json.dumps(self.clientCharacteristics), full_url=True)

self._urlREST = result["urlREST"]
self._urlWebSocket = result["urlWebSocket"]
Expand Down
6 changes: 2 additions & 4 deletions homematicip/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@


class Connection(BaseConnection):
def init(self, accesspoint_id, lookup=True, **kwargs):
def init(self, accesspoint_id, lookup=True, lookup_url="https://lookup.homematic.com:48335/getHost",**kwargs):
self.set_token_and_characteristics(accesspoint_id)

if lookup:
while True:
try:
result = requests.post(
"https://lookup.homematic.com:48335/getHost",
json=self.clientCharacteristics, timeout=3)
result = requests.post(lookup_url, json=self.clientCharacteristics, timeout=3)
js = json.loads(result.text)
self._urlREST = js["urlREST"]
self._urlWebSocket = js["urlWebSocket"]
Expand Down

0 comments on commit 906a21a

Please sign in to comment.