8000 Add energy_monitoring quirk for L535E by fantandrea · Pull Request #1591 · python-kasa/python-kasa · GitHub
[go: up one dir, main page]

Skip to content
< 8000 /include-fragment>
Draft
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
9 changes: 9 additions & 0 deletions kasa/smart/smartdevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,14 @@ def _parse_components(components_raw: ComponentsRaw) -> dict[str, int]:
for comp in components_raw["component_list"]
}

def _enable_device_quirks(self) -> None:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't make it static to be called in _parse_components so I called it just after to fix the self.components without touching the self.components_raw

# Read computed energy values for devices not having physical sensors
if "energy_monitoring" not in self._components and self.model in ["L535"]:
self._components["energy_monitoring"] = 1
_LOGGER.debug(
"[QUIRKS] Energy monitoring enabled to read computed energy values"
)

async def _negotiate(self) -> None:
"""Perform initialization.

Expand All @@ -227,6 +235,7 @@ async def _negotiate(self) -> None:
self._components_raw = cast(ComponentsRaw, resp["component_nego"])

self._components = self._parse_components(self._components_raw)
self._enable_device_quirks()

if "child_device" in self._components and not self.children:
await self._initialize_children()
Expand Down
Loading
0