diff --git a/src/api/main_simple.py b/src/api/main_simple.py index 78d4d94..94cd2c7 100644 --- a/src/api/main_simple.py +++ b/src/api/main_simple.py @@ -557,7 +557,11 @@ def _build_sub_capture(content: bytes, filename: str, entry: dict, { "device_name": m.device_name, "manufacturer": m.manufacturer, - "category": m.match_details.get("predicted_category"), + # Per-device category is that device's own catalog category + # (e.g. an Acurite sensor stays "Weather Sensor"). The overall + # ML call lives in the top-level `device_category` field. + "category": m.match_details.get("device_category") + or m.match_details.get("predicted_category"), "confidence": m.confidence, "method": m.match_method, "details": m.match_details, diff --git a/src/matcher/engine.py b/src/matcher/engine.py index ef36cbd..144c68b 100644 --- a/src/matcher/engine.py +++ b/src/matcher/engine.py @@ -87,7 +87,14 @@ class SignatureMatcher: manufacturer=device_match.manufacturer or "Unknown", confidence=device_match.confidence, match_method=device_match.match_method, - match_details=device_match.details + # Preserve each device's own catalog category so the API can + # surface it per-device (e.g. an Acurite sensor stays + # "Weather Sensor"); the ML overall call remains in the + # match_details' predicted_category. + match_details={ + **device_match.details, + "device_category": device_match.category, + } )) return match_results