From a77af5fb3bae23b624901d762e8ab3123a2a4bbe Mon Sep 17 00:00:00 2001 From: Teemu R Date: Sun, 10 Dec 2023 00:32:30 +0100 Subject: [PATCH] Request component_nego only once for tapodevice (#576) Optimizes the update cycle a bit, as it's doubtful the components change over time --- kasa/tapo/tapodevice.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kasa/tapo/tapodevice.py b/kasa/tapo/tapodevice.py index 6c643a6a..291e1744 100644 --- a/kasa/tapo/tapodevice.py +++ b/kasa/tapo/tapodevice.py @@ -24,6 +24,7 @@ class TapoDevice(SmartDevice): timeout: Optional[int] = None, ) -> None: super().__init__(host, port=port, credentials=credentials, timeout=timeout) + self._components: Optional[Dict[str, Any]] = None self._state_information: Dict[str, Any] = {} self._discovery_info: Optional[Dict[str, Any]] = None 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: 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._usage = await self.protocol.query("get_device_usage") self._time = await self.protocol.query("get_device_time")