Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change/override plant entity name and option to hide species #102

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

CybDis
Copy link

@CybDis CybDis commented Mar 29, 2024

Implements feature request from #98

Also adds an option to hide the species (which may be very long text and disturb dashboards with many small cards)

@@ -36,6 +36,10 @@ export default class FlowerCard extends LitElement {
this._hass = hass;
this.stateObj = this.config?.entity ? hass.states[this.config.entity] : undefined;

if (this.config?.name) {
this.stateObj.attributes.friendly_name = this.config.name;
Copy link
Owner

Choose a reason for hiding this comment

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

I don't really like to overwrite the values in the original object, as it might cause confusion in other parts of the code or while debugging other issues.
So I'd rather do it the other way. If config.name is not set, set it to friendly_name and then display config.name instead.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the feedback, I already noticed some strange behavior due to overriding the original object.
I've changed the code to display name instead of friendly_name and use friendly_name if name is not set.

Please review the changed and cherry-pick, as the branches are conflicted now.

@Olen
Copy link
Owner

Olen commented Apr 5, 2024

Thanks.
I added some comments.

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