Implement motion & ambient light sensor modules for dimmers (#278)

This commit is contained in:
Teemu R
2022-01-29 17:53:18 +01:00
parent e3588047fc
commit 8c7b1b4a68
4 changed files with 116 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
"""Module for dimmers (currently only HS220)."""
from typing import Any, Dict
from kasa.modules import AmbientLight, Motion
from kasa.smartdevice import DeviceType, SmartDeviceException, requires_update
from kasa.smartplug import SmartPlug
@@ -40,6 +41,10 @@ class SmartDimmer(SmartPlug):
def __init__(self, host: str) -> None:
super().__init__(host)
self._device_type = DeviceType.Dimmer
# TODO: need to be verified if it's okay to call these on HS220 w/o these
# TODO: need to be figured out what's the best approach to detect support for these
self.add_module("motion", Motion(self, "smartlife.iot.PIR"))
self.add_module("ambient", AmbientLight(self, "smartlife.iot.LAS"))
@property # type: ignore
@requires_update