Skip to content

core: expose device name to its template for self-referencing#31310

Closed
iseeberg79 wants to merge 1 commit into
evcc-io:masterfrom
iseeberg79:feat/template-device-identity
Closed

core: expose device name to its template for self-referencing#31310
iseeberg79 wants to merge 1 commit into
evcc-io:masterfrom
iseeberg79:feat/template-device-identity

Conversation

@iseeberg79

Copy link
Copy Markdown
Contributor

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.

…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>
@andig

andig commented Jun 29, 2026

Copy link
Copy Markdown
Member

Nice idea! Lets keep this but not implement it atm.

@andig andig closed this Jun 29, 2026
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.

2 participants