Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Better checking of child modules not supported by parent device #966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions kasa/smart/modules/lightpreset.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,13 @@ def query(self) -> dict:
if self._state_in_sysinfo: # Child lights can have states in the child info
return {}
return {self.QUERY_GETTER_NAME: None}

async def _check_supported(self):
"""Additional check to see if the module is supported by the device.

Parent devices that report components of children such as ks240 will not have
the brightness value is sysinfo.
"""
# Look in _device.sys_info here because self.data is either sys_info or
# get_preset_rules depending on whether it's a child device or not.
return "brightness" in self._device.sys_info
4 changes: 0 additions & 4 deletions kasa/smart/smartdevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,6 @@ async def _initialize_modules(self):
child_modules_to_skip = {}
if self._parent and self._parent.device_type != DeviceType.Hub:
skip_parent_only_modules = True
elif self._children and self.device_type == DeviceType.WallSwitch:
# _initialize_modules is called on the parent after the children
for child in self._children.values():
child_modules_to_skip.update(**child.modules)

for mod in SmartModule.REGISTERED_MODULES.values():
_LOGGER.debug("%s requires %s", mod, mod.REQUIRED_COMPONENT)
Expand Down
Loading