From a571b7a5ddc0245292cbedeccdcc56cefb4655e7 Mon Sep 17 00:00:00 2001 From: petretiandrea Date: Fri, 29 Mar 2024 20:11:45 +0100 Subject: [PATCH] fix(core): expose device raw_state --- plugp100/new/tapodevice.py | 7 ++++++- tests/unit/test_plug_strip.py | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/plugp100/new/tapodevice.py b/plugp100/new/tapodevice.py index b3bd0b1..c1c160f 100644 --- a/plugp100/new/tapodevice.py +++ b/plugp100/new/tapodevice.py @@ -22,6 +22,7 @@ class LastUpdate: components: Components device_info: DeviceInfo + raw_state: dict[str, Any] class TapoDevice: @@ -62,7 +63,7 @@ async def update(self): else: state = (await self.client.get_device_info()).get_or_raise() self._last_update = LastUpdate( - device_info=DeviceInfo(**state), components=components + device_info=DeviceInfo(**state), components=components, raw_state=state ) await self._update_from_state(state) _LOGGER.info("Fetching component updates...") @@ -126,6 +127,10 @@ def overheated(self) -> bool: def firmware_version(self) -> str: return self.device_info.get_semantic_firmware_version().__str__() + @property + def hardware_version(self) -> str: + return self.device_info.hardware_version + @property def wifi_info(self) -> "WifiInfo": return WifiInfo(self.device_info.signal_level, self.device_info.rssi) diff --git a/tests/unit/test_plug_strip.py b/tests/unit/test_plug_strip.py index 09ae2b4..01188a1 100644 --- a/tests/unit/test_plug_strip.py +++ b/tests/unit/test_plug_strip.py @@ -23,6 +23,7 @@ async def test_must_expose_device_info(device: TapoPlug): async def test_must_expose_socks_info(device: TapoPlug): for sock in device.sockets: assert sock.device_type == DeviceType.Plug + assert sock.device_id != device.device_id assert sock.device_id is not None assert sock.mac is not None assert sock.model is not None