GeezerVison is showing github.com — Better checking of child modules not supported by parent device (#966) · pillarsdotnet/python-kasa@a044f2f
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: kasa/smart/modules/lightpreset.py +10Lines changed: 10 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -140,3 +140,13 @@ def query(self) -> dict: |
140 | 140 | if self._state_in_sysinfo: # Child lights can have states in the child info |
141 | 141 | return {} |
142 | 142 | return {self.QUERY_GETTER_NAME: None} |
| 143 | + |
| 144 | + async def _check_supported(self): |
| 145 | + """Additional check to see if the module is supported by the device. |
| 146 | +
|
| 147 | + Parent devices that report components of children such as ks240 will not have |
| 148 | + the brightness value is sysinfo. |
| 149 | + """ |
| 150 | + # Look in _device.sys_info here because self.data is either sys_info or |
| 151 | + # get_preset_rules depending on whether it's a child device or not. |
| 152 | + return "brightness" in self._device.sys_info |
Collapse file
Copy file name to clipboardExpand all lines: kasa/smart/smartdevice.py -4Lines changed: 0 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -202,10 +202,6 @@ async def _initialize_modules(self): |
202 | 202 | child_modules_to_skip = {} |
203 | 203 | if self._parent and self._parent.device_type != DeviceType.Hub: |
204 | 204 | skip_parent_only_modules = True |
205 | | - elif self._children and self.device_type == DeviceType.WallSwitch: |
206 | | - # _initialize_modules is called on the parent after the children |
207 | | - for child in self._children.values(): |
208 | | - child_modules_to_skip.update(**child.modules) |
209 | 205 |
|
210 | 206 | for mod in SmartModule.REGISTERED_MODULES.values(): |
211 | 207 | _LOGGER.debug("%s requires %s", mod, mod.REQUIRED_COMPONENT) |
|