fix: use pattern matching for camera model validation

Accept any suffix variant (B/W/E/EB/EW etc.) for supported camera models
instead of requiring exact model strings. This allows cameras like
IP4M-1041W (white) to match the IP4M-1041 base model pattern.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
pull/106/head
Jeff Culverhouse 6 days ago
parent bbf91b82d6
commit 83f48c281e

@ -57,7 +57,8 @@ class AmcrestMixin:
return "" return ""
def classify_device(self: Amcrest2Mqtt, device: dict) -> str: def classify_device(self: Amcrest2Mqtt, device: dict) -> str:
if device["device_type"].upper() in [ # Base model patterns - suffix variants (B/W/E/EB/EW etc.) are accepted
supported_base_models = [
"IPM-721", "IPM-721",
"IPM-HX1", "IPM-HX1",
"IP2M-841", "IP2M-841",
@ -65,19 +66,20 @@ class AmcrestMixin:
"IP3M-941", "IP3M-941",
"IP3M-943", "IP3M-943",
"IP3M-956", "IP3M-956",
"IP3M-956E",
"IP3M-HX2", "IP3M-HX2",
"IP4M-1026B", "IP4M-1026",
"IP4M-1041B", "IP4M-1041",
"IP4M-1051B", "IP4M-1051",
"IP5M-1176EB", "IP5M-1176",
"IP8M-2496EB", "IP8M-2496",
"IP8M-T2499EW-28M", "IP8M-T2499",
"XVR DAHUA 5104S", "XVR DAHUA 5104S",
]: ]
device_type = device["device_type"].upper()
if any(device_type.startswith(model) for model in supported_base_models):
return "camera" return "camera"
else: else:
self.logger.error(f"device you specified is not a supported model: {device["device_type"]}") self.logger.error(f"device you specified is not a supported model: {device_type}")
return "" return ""
async def build_camera(self: Amcrest2Mqtt, camera: dict) -> str: async def build_camera(self: Amcrest2Mqtt, camera: dict) -> str:

Loading…
Cancel
Save