Commit 1029558
feat: expose category on automation, script, and helper config tools (#850)
* feat: expose category on automation, script, and helper config tools
Add category parameter to domain-specific config tools, building on
#677's category CRUD foundation:
- ha_config_get_automation: includes category from entity registry
- ha_config_set_automation: accepts category parameter, applies via
entity registry update after creation (also extracts from config
dict to prevent REST API rejection)
- ha_config_get_script: includes category from entity registry
- ha_config_set_script: same pattern as automations
- ha_config_set_helper: adds category alongside existing area_id
and labels entity registry updates
Categories are stored in the entity registry (not YAML config), so
GET tools make a secondary WebSocket call to fetch them, and SET
tools apply them via entity_registry/update after the primary
create/update succeeds.
Closes #702
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: address Gemini review, add E2E tests for config tool categories
Fixes from Gemini review:
- Use "helpers" scope for helper categories (not helper_type)
- Add category support to helper UPDATE path (was only on create)
- Replace bare except:pass with logger.debug for debuggability
Add E2E tests:
- test_automation_set_and_get_category: full round-trip
- test_script_set_and_get_category: full round-trip
- test_automation_category_in_config_dict: category extraction
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: align helper category param description with automation/script
Include scope='helpers' and mention ha_config_set_category() for
consistency across all category-aware config tools.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: extract _resolve_automation_entity_id shared helper
Deduplicate the entity_id-from-unique_id resolution logic used by
both ha_config_get_automation and ha_config_remove_automation into
a single helper function.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: add str() cast to satisfy mypy no-any-return
state["entity_id"] returns Any from untyped dict; wrap in str()
to match the declared str | None return type.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* refactor: extract shared category helpers, restore remove warning
- Extract fetch_entity_category() and apply_entity_category() into
util_helpers.py, replacing duplicate inline logic in automations
and scripts config tools
- Restore warning log in ha_config_remove_automation when entity_id
resolution fails (was lost during _resolve helper extraction)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: add str() cast in fetch_entity_category for mypy
categories.get(scope) returns Any from untyped dict; cast to
str to match declared str | None return type.
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 d6be6b7 commit 1029558
6 files changed
Lines changed: 605 additions & 16 deletions
File tree
- site/src/data
- src/ha_mcp/tools
- tests/src/e2e/workflows/categories
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
302 | | - | |
| 302 | + | |
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
312 | 316 | | |
313 | 317 | | |
314 | 318 | | |
| |||
1520 | 1524 | | |
1521 | 1525 | | |
1522 | 1526 | | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
1523 | 1531 | | |
1524 | 1532 | | |
1525 | 1533 | | |
| |||
2101 | 2109 | | |
2102 | 2110 | | |
2103 | 2111 | | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
2104 | 2116 | | |
2105 | 2117 | | |
2106 | 2118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
205 | 207 | | |
206 | 208 | | |
207 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
208 | 231 | | |
209 | 232 | | |
210 | 233 | | |
| |||
237 | 260 | | |
238 | 261 | | |
239 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
240 | 271 | | |
241 | 272 | | |
242 | 273 | | |
| |||
296 | 327 | | |
297 | 328 | | |
298 | 329 | | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
299 | 337 | | |
300 | 338 | | |
301 | 339 | | |
| |||
327 | 365 | | |
328 | 366 | | |
329 | 367 | | |
| 368 | + | |
330 | 369 | | |
331 | 370 | | |
332 | 371 | | |
| |||
444 | 483 | | |
445 | 484 | | |
446 | 485 | | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
447 | 491 | | |
448 | 492 | | |
449 | 493 | | |
| |||
499 | 543 | | |
500 | 544 | | |
501 | 545 | | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
502 | 549 | | |
503 | 550 | | |
504 | 551 | | |
| |||
507 | 554 | | |
508 | 555 | | |
509 | 556 | | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
510 | 563 | | |
511 | 564 | | |
512 | 565 | | |
| |||
572 | 625 | | |
573 | 626 | | |
574 | 627 | | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
589 | 633 | | |
590 | 634 | | |
591 | 635 | | |
| |||
0 commit comments