core: expose device name to its template for self-referencing#31310
Closed
iseeberg79 wants to merge 1 commit into
Closed
core: expose device name to its template for self-referencing#31310iseeberg79 wants to merge 1 commit into
iseeberg79 wants to merge 1 commit into
Conversation
…ndex)
Templates that read from a shared published-state array (state plugin)
currently need a manually configured index/reference to pick their own
entry - fragile, since array order is not stable and the index is opaque
to users.
The device's own name is known at instantiation (db:ID for configured
devices, the configured name for yaml), and "name" is already a predefined
template property. Populate it so a template can self-reference, e.g.:
jq: '.[] | select(.name == "{{ .name }}").value'
No new param, no template changes required (opt-in per template), no core
interface change. Wired centrally via a small helper used by both the
static and configurable device paths; the helper returns a copy and does
not mutate the caller's params.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Member
|
Nice idea! Lets keep this but not implement it atm. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Templates that read from a shared published-state array (state plugin) currently need a manually configured index/reference to pick their own entry - fragile, since array order is not stable and the index is opaque to users.
The device's own name is known at instantiation (db:ID for configured devices, the configured name for yaml), and "name" is already a predefined template property. Populate it so a template can self-reference, e.g.:
jq: '.[] | select(.name == "{{ .name }}").value'
No new param, no template changes required (opt-in per template), no core interface change. Wired centrally via a small helper used by both the static and configurable device paths; the helper returns a copy and does not mutate the caller's params.