LED Similarity Calculator Skill
Guidance for working with LEDSimilarityCalculator in the lib-electronic-components library.
For metadata-driven similarity architecture, see /similarity-metadata:
- SpecImportance levels (CRITICAL, HIGH, MEDIUM, LOW, OPTIONAL)
- ToleranceRule types (exactMatch, percentageTolerance, minimumRequired, etc.)
- SimilarityProfile contexts (DESIGN_PHASE, REPLACEMENT, COST_OPTIMIZATION, etc.)
- Calculator integration patterns and gotchas
Overview
The LEDSimilarityCalculator compares LEDs based on:
- LED family - Same manufacturer series
- Bin codes - Brightness and color temperature bins
- Color temperature - Must match for high similarity
Applicable Types
ComponentType.LED
// Any type starting with "LED_"
// Uses getBaseType() == ComponentType.LED
Returns false for null type.
Similarity Thresholds
HIGH_SIMILARITY = 0.9; // Same LED, same color temp
MEDIUM_SIMILARITY = 0.7; // Different families but valid LEDs
LOW_SIMILARITY = 0.3; // Different color temperatures
LED Equivalent Groups
TI High-Power LED Series
| Group |
Members |
| TLHR5400 (Red) |
TLHR5400, TLHR5401, TLHR5402, TLHR5403 |
| TLHG5800 (Green) |
TLHG5800, TLHG5801, TLHG5802, TLHG5803 |
| TLHB5800 (Blue) |
TLHB5800, TLHB5801, TLHB5802, TLHB5803 |
LG LED Series
| Group |
Members |
| LG R971 (Red) |
LG R971, LG R971-KN, LG R971-PK |
| LG B971 (Blue) |
LG B971, LG B971-KN, LG B971-PK |
| LG G971 (Green) |
LG G971, LG G971-KN, LG G971-PK |
Samsung LM Series
| Group |
Members |
| LM301B |
LM301B, LM301B-K, LM301B-V2 |
| LM281B |
LM281B, LM281B-K, LM281B-V2 |
Nichia NCS Series
| Group |
Members |
| NCSW (White) |
NCSW170, NCSW170T, NCSW170AT |
| NCSR (Red) |
NCSR170, NCSR170T, NCSR170AT |
Bin Code Handling
LEDs use bin codes for brightness and color sorting:
Brightness Bins (Typical)
K, L, M, N - Brightness grades
Color Temperature Bins (Cree)
FK* - One color temperature
FC* - Different color temperature
// Same color temperature = HIGH
calculator.calculateSimilarity("XPERED-L1-FKA", "XPERED-L1-FKB", registry);
// Returns 0.9
// Different color temperatures = LOW
calculator.calculateSimilarity("XPERED-L1-FKA", "XPERED-L1-FCA", registry);
// Returns 0.3
Family Detection
| Prefix |
Manufacturer |
Family |
| TLHR |
TI |
Red LED |
| TLHG |
TI |
Green LED |
| TLHB |
TI |
Blue LED |
| TLW |
TI |
White LED |
| LG R/B/G |
LG |
Color LEDs |
| LW, LR, LS |
Osram |
Standard LEDs |
| XP, XB, XQ |
Cree |
High-power LEDs |
| L130, L135 |
Lumileds |
LUXEON series |
| LM |
Samsung |
LM series |
| NCS |
Nichia |
Standard series |
Package Compatibility
| Package Type |
Compatible Packages |
| SMD |
SMD, PLCC, 3528, 5050, 2835, 3030, 5630, 0603, 0805, 1206 |
| Through-Hole |
TH, DIP, 5MM, 3MM, 8MM, 10MM, T-1, T-1¾ |
| High-Power |
STAR, MCE, XPE, XPG, XML, LUXEON, REBEL |
Test Examples
// Same LED
calculator.calculateSimilarity("TLHR5400", "TLHR5400", registry);
// Returns 0.9
// Same family, different bin
calculator.calculateSimilarity("TLHR5400", "TLHR5401", registry);
// Returns 0.9
// LG variants with suffix
calculator.calculateSimilarity("LG R971", "LG R971-KN", registry);
// Returns 0.9
// Different color temps
calculator.calculateSimilarity("XPERED-L1-FKA", "XPERED-L1-FCA", registry);
// Returns 0.3
Metadata-Driven Implementation (January 2026)
Status: ✅ Converted (PR #118)
The LEDSimilarityCalculator now uses a metadata-driven approach with spec-based comparison.
Specs Compared
| Spec |
Importance |
Tolerance Rule |
Description |
| color |
CRITICAL |
exactMatch |
Red, Green, Blue, White, etc. |
| family |
HIGH |
exactMatch |
TLHR, LG R, LM301, XP-E, etc. |
| brightness |
HIGH |
exactMatch |
Brightness bin code |
| package |
LOW |
exactMatch |
0603, 0805, 5mm, SMD, etc. |
Implementation Pattern
// Short-circuit check for CRITICAL incompatibility
if (!color1.isEmpty() && !color2.isEmpty() && !color1.equals(color2)) {
return LOW_SIMILARITY;
}
// Weighted spec scoring
// color: CRITICAL (1.0 weight)
// family: HIGH (0.7 weight)
// brightness: HIGH (0.7 weight)
// package: LOW (0.2 weight)
// Family boost for known equivalent groups
if (areSameFamily(mpn1, mpn2)) {
similarity = Math.max(similarity, HIGH_SIMILARITY);
}
Behavior Changes
| Comparison |
Legacy Result |
Metadata Result |
Notes |
| TLHR5400 vs TLHR5401 |
0.9 |
0.96 |
Same family, different bins |
| LG R971 vs LG R971-KN |
0.9 |
1.0 |
Exact family + color match |
| TLHR5400 vs LCW E6SF |
0.7 |
0.66 |
Different families, same color |
| XPERED-L1-FKA vs XPERED-L1-FCA |
0.3 |
0.3 |
Short-circuit on color temp |
Why more accurate: Metadata approach prioritizes color matching (CRITICAL) and separates family from brightness considerations.
Learnings & Quirks
Color Temperature Codes
- Cree uses
FK/FC in bin codes to indicate color temp
- Same base LED with different color temps are NOT equivalent
Brightness Bin Codes
- Adjacent brightness bins (K vs L) are usually interchangeable
- Large gaps in brightness bins may not be suitable substitutes
LG LED Format
- Format:
LG R971-KN where -KN is the suffix variant
- All suffix variants of same base part are equivalent
Package Suffixes
-RL, -RT = Tape and reel packaging
-TUBE = Tube packaging
- These don't affect LED equivalence
1---2name: similarity-led3description: Use when working with LED similarity calculations - comparing LED MPNs, understanding color bins, brightness bins, families, or LED-specific similarity logic.4---5
6# LED Similarity Calculator Skill
7
8Guidance for working with `LEDSimilarityCalculator` in the lib-electronic-components library.
9
10---
11
12**For metadata-driven similarity architecture**, see `/similarity-metadata`:
13- SpecImportance levels (CRITICAL, HIGH, MEDIUM, LOW, OPTIONAL)
14- ToleranceRule types (exactMatch, percentageTolerance, minimumRequired, etc.)
15- SimilarityProfile contexts (DESIGN_PHASE, REPLACEMENT, COST_OPTIMIZATION, etc.)
16- Calculator integration patterns and gotchas
17
18---
19
20## Overview
21
22The `LEDSimilarityCalculator` compares LEDs based on:
23- **LED family** - Same manufacturer series
24- **Bin codes** - Brightness and color temperature bins
25- **Color temperature** - Must match for high similarity
26
27## Applicable Types
28
29```java
30ComponentType.LED
31// Any type starting with "LED_"
32// Uses getBaseType() == ComponentType.LED
33```
34
35Returns `false` for `null` type.
36
37## Similarity Thresholds
38
39```java
40HIGH_SIMILARITY = 0.9; // Same LED, same color temp
41MEDIUM_SIMILARITY = 0.7; // Different families but valid LEDs
42LOW_SIMILARITY = 0.3; // Different color temperatures
43```
44
45## LED Equivalent Groups
46
47### TI High-Power LED Series
48| Group | Members |
49|-------|---------|
50| TLHR5400 (Red) | TLHR5400, TLHR5401, TLHR5402, TLHR5403 |
51| TLHG5800 (Green) | TLHG5800, TLHG5801, TLHG5802, TLHG5803 |
52| TLHB5800 (Blue) | TLHB5800, TLHB5801, TLHB5802, TLHB5803 |
53
54### LG LED Series
55| Group | Members |
56|-------|---------|
57| LG R971 (Red) | LG R971, LG R971-KN, LG R971-PK |
58| LG B971 (Blue) | LG B971, LG B971-KN, LG B971-PK |
59| LG G971 (Green) | LG G971, LG G971-KN, LG G971-PK |
60
61### Samsung LM Series
62| Group | Members |
63|-------|---------|
64| LM301B | LM301B, LM301B-K, LM301B-V2 |
65| LM281B | LM281B, LM281B-K, LM281B-V2 |
66
67### Nichia NCS Series
68| Group | Members |
69|-------|---------|
70| NCSW (White) | NCSW170, NCSW170T, NCSW170AT |
71| NCSR (Red) | NCSR170, NCSR170T, NCSR170AT |
72
73## Bin Code Handling
74
75LEDs use bin codes for brightness and color sorting:
76
77### Brightness Bins (Typical)
78- `K`, `L`, `M`, `N` - Brightness grades
79
80### Color Temperature Bins (Cree)
81- `FK*` - One color temperature
82- `FC*` - Different color temperature
83
84```java
85// Same color temperature = HIGH
86calculator.calculateSimilarity("XPERED-L1-FKA", "XPERED-L1-FKB", registry);
87// Returns 0.9
88
89// Different color temperatures = LOW
90calculator.calculateSimilarity("XPERED-L1-FKA", "XPERED-L1-FCA", registry);
91// Returns 0.3
92```
93
94## Family Detection
95
96| Prefix | Manufacturer | Family |
97|--------|--------------|--------|
98| TLHR | TI | Red LED |
99| TLHG | TI | Green LED |
100| TLHB | TI | Blue LED |
101| TLW | TI | White LED |
102| LG R/B/G | LG | Color LEDs |
103| LW, LR, LS | Osram | Standard LEDs |
104| XP, XB, XQ | Cree | High-power LEDs |
105| L130, L135 | Lumileds | LUXEON series |
106| LM | Samsung | LM series |
107| NCS | Nichia | Standard series |
108
109## Package Compatibility
110
111| Package Type | Compatible Packages |
112|--------------|---------------------|
113| SMD | SMD, PLCC, 3528, 5050, 2835, 3030, 5630, 0603, 0805, 1206 |
114| Through-Hole | TH, DIP, 5MM, 3MM, 8MM, 10MM, T-1, T-1¾ |
115| High-Power | STAR, MCE, XPE, XPG, XML, LUXEON, REBEL |
116
117## Test Examples
118
119```java
120// Same LED
121calculator.calculateSimilarity("TLHR5400", "TLHR5400", registry);
122// Returns 0.9
123
124// Same family, different bin
125calculator.calculateSimilarity("TLHR5400", "TLHR5401", registry);
126// Returns 0.9
127
128// LG variants with suffix
129calculator.calculateSimilarity("LG R971", "LG R971-KN", registry);
130// Returns 0.9
131
132// Different color temps
133calculator.calculateSimilarity("XPERED-L1-FKA", "XPERED-L1-FCA", registry);
134// Returns 0.3
135```
136
137---
138
139## Metadata-Driven Implementation (January 2026)
140
141**Status**: ✅ Converted (PR #118)
142
143The `LEDSimilarityCalculator` now uses a **metadata-driven approach** with spec-based comparison.
144
145### Specs Compared
146
147| Spec | Importance | Tolerance Rule | Description |
148|------|-----------|----------------|-------------|
149| **color** | CRITICAL | exactMatch | Red, Green, Blue, White, etc. |
150| **family** | HIGH | exactMatch | TLHR, LG R, LM301, XP-E, etc. |
151| **brightness** | HIGH | exactMatch | Brightness bin code |
152| **package** | LOW | exactMatch | 0603, 0805, 5mm, SMD, etc. |
153
154### Implementation Pattern
155
156```java
157// Short-circuit check for CRITICAL incompatibility
158if (!color1.isEmpty() && !color2.isEmpty() && !color1.equals(color2)) {
159 return LOW_SIMILARITY;
160}
161
162// Weighted spec scoring
163// color: CRITICAL (1.0 weight)
164// family: HIGH (0.7 weight)
165// brightness: HIGH (0.7 weight)
166// package: LOW (0.2 weight)
167
168// Family boost for known equivalent groups
169if (areSameFamily(mpn1, mpn2)) {
170 similarity = Math.max(similarity, HIGH_SIMILARITY);
171}
172```
173
174### Behavior Changes
175
176| Comparison | Legacy Result | Metadata Result | Notes |
177|-----------|--------------|-----------------|-------|
178| TLHR5400 vs TLHR5401 | 0.9 | 0.96 | Same family, different bins |
179| LG R971 vs LG R971-KN | 0.9 | 1.0 | Exact family + color match |
180| TLHR5400 vs LCW E6SF | 0.7 | 0.66 | Different families, same color |
181| XPERED-L1-FKA vs XPERED-L1-FCA | 0.3 | 0.3 | Short-circuit on color temp |
182
183**Why more accurate**: Metadata approach prioritizes color matching (CRITICAL) and separates family from brightness considerations.
184
185---
186
187## Learnings & Quirks
188
189### Color Temperature Codes
190- Cree uses `FK`/`FC` in bin codes to indicate color temp
191- Same base LED with different color temps are NOT equivalent
192
193### Brightness Bin Codes
194- Adjacent brightness bins (K vs L) are usually interchangeable
195- Large gaps in brightness bins may not be suitable substitutes
196
197### LG LED Format
198- Format: `LG R971-KN` where `-KN` is the suffix variant
199- All suffix variants of same base part are equivalent
200
201### Package Suffixes
202- `-RL`, `-RT` = Tape and reel packaging
203- `-TUBE` = Tube packaging
204- These don't affect LED equivalence
205
206<!-- Add new learnings above this line -->