mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-23 11:43:34 +00:00
Exclude querying certain modules for KL125(US) which cause crashes (#451)
* commented out modules that break * added exclusion logic to smartdevice.py * cleaning up a name * removing test fixture that isn't related to this PR * incorporating PR feedback * fixed an if statement * reduced exclusion list to just 'cloud' * Tidy up the issue comment Co-authored-by: Teemu R. <tpr@iki.fi> * this seems to be what the linter whats --------- Co-authored-by: Teemu R. <tpr@iki.fi>
This commit is contained in:
parent
39310f3f02
commit
9550cbd2f7
@ -27,6 +27,9 @@ from .protocol import TPLinkSmartHomeProtocol
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# Certain module queries will crash devices; this list skips those queries
|
||||||
|
MODEL_MODULE_SKIPLIST = {"KL125(US)": ["cloud"]} # Issue #345
|
||||||
|
|
||||||
|
|
||||||
class DeviceType(Enum):
|
class DeviceType(Enum):
|
||||||
"""Device type enum."""
|
"""Device type enum."""
|
||||||
@ -325,10 +328,15 @@ class SmartDevice:
|
|||||||
)
|
)
|
||||||
self.add_module("emeter", Emeter(self, self.emeter_type))
|
self.add_module("emeter", Emeter(self, self.emeter_type))
|
||||||
|
|
||||||
for module in self.modules.values():
|
for module_name, module in self.modules.items():
|
||||||
if not module.is_supported:
|
if not module.is_supported:
|
||||||
_LOGGER.debug("Module %s not supported, skipping" % module)
|
_LOGGER.debug("Module %s not supported, skipping" % module)
|
||||||
continue
|
continue
|
||||||
|
modules_to_skip = MODEL_MODULE_SKIPLIST.get(self.model, [])
|
||||||
|
if module_name in modules_to_skip:
|
||||||
|
_LOGGER.debug(f"Module {module} is excluded for {self.model}, skipping")
|
||||||
|
continue
|
||||||
|
|
||||||
q = module.query()
|
q = module.query()
|
||||||
_LOGGER.debug("Adding query for %s: %s", module, q)
|
_LOGGER.debug("Adding query for %s: %s", module, q)
|
||||||
req = merge(req, q)
|
req = merge(req, q)
|
||||||
|
Loading…
Reference in New Issue
Block a user