FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add PIR&LAS for wall switches mentioning PIR support by rytilahti · Pull Request #1227 · python-kasa/python-kasa · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
11 changes: 10 additions & 1 deletion kasa/iot/iotplug.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ..module import Module
from ..protocol import BaseProtocol
from .iotdevice import IotDevice, requires_update
from .modules import Antitheft, Cloud, Led, Schedule, Time, Usage
from .modules import AmbientLight, Antitheft, Cloud, Led, Motion, Schedule, Time, Usage

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -92,3 +92,12 @@ def __init__(
) -> None:
super().__init__(host=host, config=config, protocol=protocol)
self._device_type = DeviceType.WallSwitch

async def _initialize_modules(self) -> None:
"""Initialize modules."""
await super()._initialize_modules()
if (dev_name := self.sys_info["dev_name"]) and "PIR" in dev_name:
self.add_module(Module.IotMotion, Motion(self, "smartlife.iot.PIR"))
self.add_module(
Module.IotAmbientLight, AmbientLight(self, "smartlife.iot.LAS")
)
9 changes: 9 additions & 0 deletions kasa/tests/iot/test_wallswitch.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from kasa.tests.device_fixtures import wallswitch_iot


@wallswitch_iot
def test_wallswitch_motion(dev):
"""Check that wallswitches with motion sensor get modules enabled."""
has_motion = "PIR" in dev.sys_info["dev_name"]
assert "motion" in dev.modules if has_motion else True
assert "ambient" in dev.modules if has_motion else True

Back | FazBrowse Home | New Git URL