Skip to content

Show labels in ObjectSelector overview#51840

Draft
gjohansson-ST wants to merge 3 commits into
home-assistant:devfrom
gjohansson-ST:gj-20260503-01
Draft

Show labels in ObjectSelector overview#51840
gjohansson-ST wants to merge 3 commits into
home-assistant:devfrom
gjohansson-ST:gj-20260503-01

Conversation

@gjohansson-ST
Copy link
Copy Markdown
Member

@gjohansson-ST gjohansson-ST commented May 3, 2026

Proposed change

Modify the ObjectSelector (adds new key) to also be able to show the labels in the "overview":
Untitled

Backend PR: home-assistant/core#170436

Related to: home-assistant/core#147928

Screenshots

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • I have followed the perfect PR recommendations
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

To help with the load of incoming pull requests:

@MindFreeze
Copy link
Copy Markdown
Member

Yea, this can't be the default. Can't think of a great solution right now, but a dedicated translation key would work at least.
Something like ${translation_key}.fields.${name}.overview_label with a value in en.json of "Uncompensated value: {value}". The : should be part of the translation

@gjohansson-ST gjohansson-ST marked this pull request as draft May 8, 2026 13:35
@gjohansson-ST
Copy link
Copy Markdown
Member Author

Yea, this can't be the default. Can't think of a great solution right now, but a dedicated translation key would work at least. Something like ${translation_key}.fields.${name}.overview_label with a value in en.json of "Uncompensated value: {value}". The : should be part of the translation

The selector is quite "complex" as is so another field is probably not gonna be an issue.
I'll make that adjustment and see if it looks like it could make sense.

@gjohansson-ST gjohansson-ST marked this pull request as ready for review May 12, 2026 17:01
@gjohansson-ST gjohansson-ST changed the title Labels in ObjectSelector overview Show labels in ObjectSelector overview May 13, 2026
? `${this._computeLabel({
name: labelField,
selector: fields[labelField]?.selector,
})}: `
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The : should really be part of the translation otherwise it won't work in all languages

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was really trying to avoid another field needed to be translated and instead just have a bool saying if it should display in the overview or not.

I'd think this probably looks ok even to remove : so it would just say Uncompensated value 5?

const overviewLabels = this.selector.object!.overview_labels || false;

const labelField =
preferredLabel || Object.keys(this.selector.object!.fields!)[0];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The ! here is optimistic. fields may be undefined according to the type

@home-assistant
Copy link
Copy Markdown

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant Bot marked this pull request as draft May 13, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants