Skip to content
This repository was archived by the owner on Feb 4, 2024. It is now read-only.

Commit

Permalink
Pyhomematic/add/ipw key blind multi (#318)
Browse files Browse the repository at this point in the history
* Fixed work around for hm init issue

* added callback call

* remove comments

* removed pmatic

* fixed spacing

* according to alignment in #318, listdevice and interface if statement changed

* removed debug breakpoint setting

* added more generic check: proxy._remoteport == [2010, 32010, 42010]

* fixed proxy._remoteport in [2010, 32010, 42010] statement

* Limit to HmIP

* Remove whitespace

* Home Assistant doesn't use createDeviceObjects

* Change skipping mechanism

* Fix syntax

Co-authored-by: Daniel Perna <[email protected]>
  • Loading branch information
weissm and danielperna84 authored Aug 4, 2020
1 parent 2cfc182 commit 45ab6bc
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pyhomematic/_hm.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ def listDevices(self, interface_id):
self._devices_raw[remote] = []
if self.systemcallback:
self.systemcallback('listDevices', interface_id)

# return empty list for HmIP, as currently the maximum lenght is limited to 8192 bytes (see #318 for details)
if self.remotes.get(remote, {}).get('port') in [2010, 32010, 42010]:
return []
return self._devices_raw[remote]

def newDevices(self, interface_id, dev_descriptions):
Expand All @@ -295,7 +299,11 @@ def newDevices(self, interface_id, dev_descriptions):
self._devices_raw_dict[remote] = {}
if remote not in self._paramsets:
self._paramsets[remote] = {}
hmip = self.remotes.get(remote, {}).get('port') in [2010, 32010, 42010]
for d in dev_descriptions:
if hmip:
if d in self._devices_raw[remote]:
continue
self._devices_raw[remote].append(d)
self._devices_raw_dict[remote][d['ADDRESS']] = d
self._paramsets[remote][d['ADDRESS']] = {}
Expand Down Expand Up @@ -522,7 +530,6 @@ def __getattr__(self, *args, **kwargs):
"""
Magic method dispatcher
"""

return xmlrpc.client._Method(self.__request, *args, **kwargs)

# Restrict to particular paths.
Expand Down Expand Up @@ -669,6 +676,11 @@ def proxyInit(self):
LOG.debug("ServerThread.proxyInit: init('http://%s:%i', '%s')" %
(callbackip, callbackport, interface_id))
try:
# For HomeMatic IP, init is not working correctly. We fetch the device list and create
# the device objects before the init is performed.
if proxy._remoteport in [2010, 32010, 42010]:
dev_list = proxy.listDevices(interface_id)
self._rpcfunctions.newDevices(interface_id=interface_id, dev_descriptions=dev_list)
proxy.init("http://%s:%i" %
(callbackip, callbackport), interface_id)
LOG.info("Proxy for %s initialized", interface_id)
Expand Down

0 comments on commit 45ab6bc

Please sign in to comment.