mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-11-06 15:41:56 +00:00
Add plumbing for passing credentials to devices (#507)
* Add plumbing for passing credentials as far as discovery * Pass credentials to Smart devices * Rename authentication exception * Fix tests failure due to test_json_output leaving echo as nop * Fix test_credentials test * Do not print credentials, fix echo function bug and improve get type parameter * Add device class constructor test * Add comment for echo handling and move assignment
This commit is contained in:
@@ -9,6 +9,7 @@ try:
|
||||
except ImportError:
|
||||
from pydantic import BaseModel, Field, root_validator
|
||||
|
||||
from .credentials import Credentials
|
||||
from .modules import Antitheft, Cloud, Countdown, Emeter, Schedule, Time, Usage
|
||||
from .smartdevice import DeviceType, SmartDevice, SmartDeviceException, requires_update
|
||||
|
||||
@@ -202,8 +203,14 @@ class SmartBulb(SmartDevice):
|
||||
SET_LIGHT_METHOD = "transition_light_state"
|
||||
emeter_type = "smartlife.iot.common.emeter"
|
||||
|
||||
def __init__(self, host: str, *, port: Optional[int] = None) -> None:
|
||||
super().__init__(host=host, port=port)
|
||||
def __init__(
|
||||
self,
|
||||
host: str,
|
||||
*,
|
||||
port: Optional[int] = None,
|
||||
credentials: Optional[Credentials] = None
|
||||
) -> None:
|
||||
super().__init__(host=host, port=port, credentials=credentials)
|
||||
self._device_type = DeviceType.Bulb
|
||||
self.add_module("schedule", Schedule(self, "smartlife.iot.common.schedule"))
|
||||
self.add_module("usage", Usage(self, "smartlife.iot.common.schedule"))
|
||||
|
||||
Reference in New Issue
Block a user