Skip to content

Commit b527793

Browse files
committed
Add detection of device by name
Necessary when there is no productName in json flow
1 parent b293639 commit b527793

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

custom_components/ecoflow_cloud/api/public_api.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ async def fetch_all_available_devices(self) -> list[EcoflowDeviceInfo]:
4646
_LOGGER.debug(str(device))
4747
sn = device["sn"]
4848
product_name = device.get("productName", "undefined")
49+
if product_name == "undefined" :
50+
from ..devices.registry import device_by_product
51+
device_list = list(device_by_product.keys())
52+
for devicetype in device_list:
53+
if "deviceName" in device and device["deviceName"].lower().startswith(devicetype.lower()):
54+
product_name = devicetype
4955
device_name = device.get("deviceName", f"{product_name}-{sn}")
5056
status = int(device["online"])
5157
result.append(

custom_components/ecoflow_cloud/devices/registry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"Delta Pro 3": public_delta_pro_3.DeltaPro3,
7272
"Power Kits": public_powerkit.PowerKit,
7373
"Smart Meter": public_smart_meter.SmartMeter,
74-
"STREAM AC": public_stream_ac.StreamAC,
74+
"Stream AC": public_stream_ac.StreamAC,
7575
"Diagnostic": DiagnosticDevice,
7676
}
7777
)

0 commit comments

Comments
 (0)