diff --git a/custom_components/mass/services.py b/custom_components/mass/services.py index 4e09413a..9d9c9a0f 100644 --- a/custom_components/mass/services.py +++ b/custom_components/mass/services.py @@ -59,6 +59,8 @@ def compact_item(item: dict[str, Any]) -> dict[str, Any]: item[key] = compact_item(value) elif isinstance(value, list): for subitem in value: + if not isinstance(subitem, dict): + continue compact_item(subitem) # item[key] = [compact_item(x) if isinstance(x, dict) else x for x in value] return item @@ -66,6 +68,8 @@ def compact_item(item: dict[str, Any]) -> dict[str, Any]: dict_result: dict[str, list[dict[str, Any]]] = result.to_dict() for media_type_key in dict_result: for item in dict_result[media_type_key]: + if not isinstance(item, dict): + continue compact_item(item) return dict_result