Commit 2ed3887
fix: add exact_match to all search tools, badge search, and dashboard deep search (#814)
* fix: add badge search, exact match mode, and dashboard search to deep search (#801)
- ha_dashboard_find_card now searches view-level badges (views[n].badges),
catching entity references in badge chips that were previously missed
during rename operations
- ha_deep_search gains exact_match parameter (default: True) that uses
substring matching instead of fuzzy scoring, eliminating false positives
when searching for known entity IDs
- ha_deep_search gains 'dashboard' search type that fetches and searches
all storage-mode dashboard configurations for entity references
Closes #801
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: extract _score_deep_match to deduplicate exact_match scoring logic
Addresses Gemini Code Assist review — the scoring logic for exact_match
was duplicated across automations, scripts, and helpers. Extracted into
a single _score_deep_match helper method.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: add exact_match parameter to ha_search_entities and ha_get_integration
Per maintainer discussion in #801, fuzzy matching should be disabled by
default across all search tools. This adds exact_match=True (default) to:
- ha_search_entities: routes directly to substring matching, skipping
fuzzy search entirely. Set exact_match=False for typo-tolerant search.
- ha_get_integration: skips fuzzy scoring branch when filtering by query,
keeping only exact substring matches. Set exact_match=False for fuzzy.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: update E2E tests for exact_match default in ha_search_entities
Tests that specifically verify fuzzy search behavior now pass
exact_match=False, since the default changed to True.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: also search sections-view header cards in ha_dashboard_find_card
Addresses feedback from @Patch76 on #801 — views[n].header.card in
sections views accepts a card (typically Markdown with Jinja2 templates)
that can contain entity references. Like badges, it's a sibling of
views[n].cards and was missed by card-focused search.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: address sergeykad review — error handling, bool coercion, tests
- Dashboard search now raises on failure instead of silently returning
empty results (fixes false-confidence problem)
- Dropped `or False` from `coerce_bool_param(..., default=True)` calls
that undermined the True default (3 locations)
- Fixed potential None.lower() crash in ha_get_integration query filter
- Badge search now triggers on card_type="badge" (not just entity_id)
- Added unit tests for badge search, header card search, strategy dashboards
- Added E2E tests for exact_match default, fuzzy opt-in, dashboard search
type, and search_entities exact_match default
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: kingpanther13 <kingpanther13@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent f62e800 commit 2ed3887
7 files changed
Lines changed: 1310 additions & 406 deletions
File tree
- src/ha_mcp/tools
- tests/src
- e2e/tools
- unit
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
25 | 32 | | |
26 | 33 | | |
27 | 34 | | |
| |||
35 | 42 | | |
36 | 43 | | |
37 | 44 | | |
38 | | - | |
| 45 | + | |
| 46 | + | |
39 | 47 | | |
40 | 48 | | |
41 | 49 | | |
| |||
65 | 73 | | |
66 | 74 | | |
67 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
68 | 86 | | |
69 | 87 | | |
70 | 88 | | |
| |||
96 | 114 | | |
97 | 115 | | |
98 | 116 | | |
99 | | - | |
100 | | - | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
101 | 126 | | |
102 | 127 | | |
103 | 128 | | |
| |||
106 | 131 | | |
107 | 132 | | |
108 | 133 | | |
109 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
110 | 139 | | |
111 | 140 | | |
112 | 141 | | |
| |||
128 | 157 | | |
129 | 158 | | |
130 | 159 | | |
131 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
132 | 163 | | |
133 | 164 | | |
134 | 165 | | |
135 | 166 | | |
136 | 167 | | |
137 | | - | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
138 | 171 | | |
139 | 172 | | |
140 | 173 | | |
141 | 174 | | |
142 | 175 | | |
143 | 176 | | |
144 | 177 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
153 | 188 | | |
154 | 189 | | |
155 | 190 | | |
156 | 191 | | |
157 | | - | |
158 | | - | |
159 | | - | |
| 192 | + | |
160 | 193 | | |
161 | 194 | | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
167 | 202 | | |
168 | 203 | | |
169 | 204 | | |
170 | 205 | | |
171 | 206 | | |
172 | 207 | | |
173 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
174 | 211 | | |
175 | 212 | | |
176 | 213 | | |
| |||
202 | 239 | | |
203 | 240 | | |
204 | 241 | | |
205 | | - | |
| 242 | + | |
206 | 243 | | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | 244 | | |
211 | 245 | | |
212 | 246 | | |
213 | 247 | | |
214 | | - | |
215 | | - | |
| 248 | + | |
| 249 | + | |
216 | 250 | | |
217 | 251 | | |
218 | 252 | | |
219 | | - | |
220 | 253 | | |
221 | | - | |
222 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
223 | 258 | | |
224 | 259 | | |
225 | 260 | | |
| |||
294 | 329 | | |
295 | 330 | | |
296 | 331 | | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
302 | 339 | | |
303 | 340 | | |
304 | 341 | | |
305 | 342 | | |
306 | 343 | | |
307 | 344 | | |
308 | 345 | | |
309 | | - | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
310 | 351 | | |
311 | 352 | | |
312 | 353 | | |
| |||
344 | 385 | | |
345 | 386 | | |
346 | 387 | | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
355 | 398 | | |
356 | 399 | | |
357 | 400 | | |
| |||
0 commit comments