mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 19:23:34 +00:00
Request component_nego only once for tapodevice (#576)
Optimizes the update cycle a bit, as it's doubtful the components change over time
This commit is contained in:
parent
35a452168a
commit
a77af5fb3b
@ -24,6 +24,7 @@ class TapoDevice(SmartDevice):
|
|||||||
timeout: Optional[int] = None,
|
timeout: Optional[int] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(host, port=port, credentials=credentials, timeout=timeout)
|
super().__init__(host, port=port, credentials=credentials, timeout=timeout)
|
||||||
|
self._components: Optional[Dict[str, Any]] = None
|
||||||
self._state_information: Dict[str, Any] = {}
|
self._state_information: Dict[str, Any] = {}
|
||||||
self._discovery_info: Optional[Dict[str, Any]] = None
|
self._discovery_info: Optional[Dict[str, Any]] = None
|
||||||
self.protocol = SmartProtocol(host, credentials=credentials, timeout=timeout)
|
self.protocol = SmartProtocol(host, credentials=credentials, timeout=timeout)
|
||||||
@ -33,7 +34,9 @@ class TapoDevice(SmartDevice):
|
|||||||
if self.credentials is None or self.credentials.username is None:
|
if self.credentials is None or self.credentials.username is None:
|
||||||
raise AuthenticationException("Tapo plug requires authentication.")
|
raise AuthenticationException("Tapo plug requires authentication.")
|
||||||
|
|
||||||
self._components = await self.protocol.query("component_nego")
|
if self._components is None:
|
||||||
|
self._components = await self.protocol.query("component_nego")
|
||||||
|
|
||||||
self._info = await self.protocol.query("get_device_info")
|
self._info = await self.protocol.query("get_device_info")
|
||||||
self._usage = await self.protocol.query("get_device_usage")
|
self._usage = await self.protocol.query("get_device_usage")
|
||||||
self._time = await self.protocol.query("get_device_time")
|
self._time = await self.protocol.query("get_device_time")
|
||||||
|
Loading…
Reference in New Issue
Block a user