Allow push/clear snippet services to target slots by slot_label or subentry_id - #69
Conversation
slot_label or subentry_id
There was a problem hiding this comment.
Pull request overview
This PR improves the ergonomics of the push_snippet / clear_snippet services by allowing callers to target custom_text slot-mode snippets using either the machine identifier (subentry_id) or the human-friendly slot_label, aligning service usage with configuration UX.
Changes:
- Updated service schemas to accept optional
subentry_idand newslot_labeltargeting forpush_snippetandclear_snippet. - Added resolver logic to map
slot_label→subentry_idwith strict validation (unknown/ambiguous/non-slot/non-custom_texttargets rejected). - Added focused tests for schema acceptance and label-resolution behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_services.py | Adds schema-level tests ensuring slot_label payloads validate for push/clear. |
| tests/test_custom_text.py | Adds resolver tests for label→subentry resolution and ambiguous-label rejection. |
| custom_components/user_briefing/services.py | Implements optional targeting via slot_label and introduces a dedicated clear-snippet schema. |
| custom_components/user_briefing/strings.json | Updates service field UX text to document the new targeting option. |
| custom_components/user_briefing/services.yaml | Updates service descriptions/fields to expose slot_label and make subentry_id optional. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot fix, still not working: 2026-07-02 17:27:00.887 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Error for call_service at pos 1: push_snippet_invalid_subentry |

push_snippet/clear_snippetrequired asubentry_id, while snippet setup exposes a human-orientedslot_label, creating a mismatch in everyday automation usage. This change makes service targeting consistent with configuration by accepting either identifier.Service targeting compatibility
custom_textslot-mode snippets:subentry_idwhen provided (existing path),slot_label.custom_texttargets,Service schema updates
push_snippet:subentry_idis optional;slot_labelis now supported.clear_snippet: moved to a dedicated schema with the same optionalsubentry_id/slot_labeltargeting model.Service UX text updates
Snippet slot IDorSnippet slot label.Focused coverage for new behavior
slot_label-only payloads.