From 933a26c270c6328fd2c41156d5d323642f9da53c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E6=B1=82=E5=9C=A3=E5=89=91?= Date: Mon, 2 Feb 2026 16:00:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_components/jackery/sensor.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/custom_components/jackery/sensor.py b/custom_components/jackery/sensor.py index 48e2db6..0eb71c5 100644 --- a/custom_components/jackery/sensor.py +++ b/custom_components/jackery/sensor.py @@ -934,7 +934,10 @@ class JackeryPlugSensor(SensorEntity): def _update_from_coordinator(self, data: dict) -> None: """Receive data from coordinator.""" - plugs = data.get("plugs") or data.get("plug") + if self._dev_type == 2: + plugs = data.get("cts") + else: + plugs = data.get("plugs") or data.get("plug") if not plugs or not isinstance(plugs, list): return @@ -946,13 +949,16 @@ class JackeryPlugSensor(SensorEntity): # Store full raw data for attributes self._raw_data = dict(my_plug) - # Update state (outPw) + # Update state (outPw / power) try: - # Try specific plug keys from protocol or generic 'outPw' + # Try specific keys from protocol # Protocol example: { "a": 12, ... } doesn't show power explicitly. # Assuming 'outPw' or similar exists, or maybe 'p' or 'power'. # Existing code used 'outPw'. Let's stick to it or add fallbacks if known. - val = my_plug.get("outPw") + if self._dev_type == 2: + val = my_plug.get("tPhasePw") or my_plug.get("TphasePw") + else: + val = my_plug.get("outPw") if val is None: val = my_plug.get("power") # Common alternative