Skip to content

Fix custom_text entity-mode snippets staying skipped for text-backed entities - #67

Merged
tamaygz merged 2 commits into
mainfrom
copilot/fix-custom-text-provider
Jul 2, 2026
Merged

Fix custom_text entity-mode snippets staying skipped for text-backed entities#67
tamaygz merged 2 commits into
mainfrom
copilot/fix-custom-text-provider

Conversation

Copilot AI commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

custom_text snippets configured in entity mode could remain skipped during briefing generation even when the linked source entity visibly had content. This was caused by treating the entity state as the only valid text source and by not allowing text entities in the selector.

  • Entity-mode text extraction

    • Keep using the entity state when it contains usable text.
    • Fall back to common text-bearing attributes (text, message, value) when the state is blank, unknown, or unavailable.
    • Preserve the existing skipped behavior only when no usable text is present.
  • Supported source entities

    • Extend the entity selector to include text entities in addition to input_text, sensor, and template.
  • Regression coverage

    • Add provider/coordinator coverage for:
      • attribute-backed text when state is unknown
      • refreshed entity values across repeated generate() calls
      • selector support for text entities
result = await adapter.async_fetch({"source_ref": source_ref})
text = self._extract_entity_text(result)
if text is None:
    return {"empty": True}
return {"text": text, "title": None, "severity": None}

Copilot AI linked an issue Jul 2, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix custom text provider not updating value from source entity Fix custom_text entity-mode snippets staying skipped for text-backed entities Jul 2, 2026
Copilot AI requested a review from tamaygz July 2, 2026 14:09
@tamaygz
tamaygz requested a review from Copilot July 2, 2026 14:09

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

Fixes a bug in the custom_text provider’s entity mode where snippets could remain skipped despite the source entity having usable text, by broadening what counts as “text” and expanding supported entity domains.

Changes:

  • Add text extraction fallback to common attributes (text, message, value) when entity state is blank/unknown/unavailable.
  • Extend the entity selector to allow text entities in addition to existing domains.
  • Add regression tests covering attribute-backed text, selector domains, and ensuring entity reads are refreshed on each coordinator generate().

Reviewed changes

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

File Description
custom_components/user_briefing/providers/custom_text.py Adds text entity support and robust entity text extraction (state + attribute fallbacks).
tests/test_provider_schemas.py Verifies the custom_text entity selector includes the text domain.
tests/test_custom_text.py Adds test ensuring attribute fallback works when entity state is unknown.
tests/test_coordinator.py Adds regression test ensuring entity-mode custom_text reads the latest entity value on each async_generate().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tamaygz
tamaygz marked this pull request as ready for review July 2, 2026 14:23
@tamaygz
tamaygz merged commit 0504dc8 into main Jul 2, 2026
1 check passed
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.

the custom text provider doesnt work

3 participants