@mega-yfue/eufy-sdk / buildModelIndex
Function: buildModelIndex()
ts
function buildModelIndex(categories): Map<string, {
category: string;
name: string;
}>;Flatten a product catalog into a product_code → { name, category } lookup for labelling discovered devices. Every variant code in p_codes maps to its parent product too, so a device reporting a sub-model resolves to the same marketing name.
The category name is trimmed here, at ingest — the live catalog returns some names with trailing whitespace (e.g. "Plug-in Home Battery "), and normalising once at the source means every consumer (a device's identity().category, detectSolixCapabilities, and any exact-match category test) sees the clean name, rather than each call site having to remember to trim.
Parameters
categories
Returns
Map<string, { category: string; name: string; }>