Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix for issue #396] Ignoring devices from device list response with missing keys #398

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion custom_components/ecoflow_cloud/api/public_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ async def login(self):
)

async def fetch_all_available_devices(self) -> list[EcoflowDeviceInfo]:
_LOGGER.info(f"Requesting all devices")
_LOGGER.info("Requesting all devices")
response = await self.call_api("/device/list")
result = list()
required_keys = {"sn", "productName", "online"}
for device in response["data"]:
if not all(key in device for key in required_keys):
_LOGGER.warning(f"Skipping device due to missing keys: {device}")
continue
sn = device["sn"]
product_name = device.get("productName", "undefined")
device_name = device.get("deviceName", f"{product_name}-{sn}")
Expand Down