Skip to content

Allow push/clear snippet services to target slots by slot_label or subentry_id - #69

Merged
tamaygz merged 3 commits into
mainfrom
copilot/fix-mismatch-expected-service-call-format
Jul 2, 2026
Merged

Allow push/clear snippet services to target slots by slot_label or subentry_id#69
tamaygz merged 3 commits into
mainfrom
copilot/fix-mismatch-expected-service-call-format

Conversation

Copilot AI commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

push_snippet/clear_snippet required a subentry_id, while snippet setup exposes a human-oriented slot_label, creating a mismatch in everyday automation usage. This change makes service targeting consistent with configuration by accepting either identifier.

  • Service targeting compatibility

    • Added slot resolution logic for custom_text slot-mode snippets:
      • use subentry_id when provided (existing path),
      • otherwise resolve by slot_label.
    • Kept strict validation semantics:
      • rejects unknown labels,
      • rejects non-slot or non-custom_text targets,
      • rejects ambiguous labels (multiple matches).
  • Service schema updates

    • push_snippet: subentry_id is optional; slot_label is now supported.
    • clear_snippet: moved to a dedicated schema with the same optional subentry_id/slot_label targeting model.
  • Service UX text updates

    • Updated service field metadata/translations to document that callers can provide either Snippet slot ID or Snippet slot label.
  • Focused coverage for new behavior

    • Added tests for schema acceptance of slot_label-only payloads.
    • Added resolver tests for:
      • successful single-label resolution,
      • ambiguous-label rejection.
action: user_briefing.push_snippet
data:
  config_entry_id: "<profile_entry_id>"
  slot_label: "Morning Alerts"   # alternative to subentry_id
  text: "Heavy rain expected after 16:00"
  severity: warning

Copilot AI linked an issue Jul 2, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix mismatch in expected service call format Allow push/clear snippet services to target slots by slot_label or subentry_id Jul 2, 2026
@tamaygz
tamaygz requested a review from Copilot July 2, 2026 14:31
Copilot AI requested a review from tamaygz July 2, 2026 14:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_id and new slot_label targeting for push_snippet and clear_snippet.
  • Added resolver logic to map slot_labelsubentry_id with strict validation (unknown/ambiguous/non-slot/non-custom_text targets 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.

Comment thread custom_components/user_briefing/services.py
Comment thread tests/test_custom_text.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@tamaygz
tamaygz marked this pull request as ready for review July 2, 2026 14:56
@tamaygz
tamaygz merged commit 3fd572d into main Jul 2, 2026
1 check passed
@tamaygz

tamaygz commented Jul 2, 2026

Copy link
Copy Markdown
Owner

@copilot fix, still not working:
image

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
2026-07-02 17:27:00.887 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140224114937504] push_snippet_invalid_subentry
2026-07-02 17:27:10.666 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
2026-07-02 17:27:10.666 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140224114937504] push_snippet_invalid_subentry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mismatchexpected service call format

3 participants