修复BUG
This commit is contained in:
@@ -934,6 +934,9 @@ class JackeryPlugSensor(SensorEntity):
|
||||
|
||||
def _update_from_coordinator(self, data: dict) -> None:
|
||||
"""Receive data from coordinator."""
|
||||
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,12 +949,15 @@ 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.
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user