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

Add tile card feature for input_select domain #16650

Closed

Conversation

rbnis
Copy link

@rbnis rbnis commented May 28, 2023

Proposed change

This PR adds the option to select an option of an input_select entity.
With this users have an easy way to integrate input_selects into their dashboards.

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

Example configuration

The feature in this PR does not need any additional configuration.
But to test this feature I added an input_select entity with the id input_select.demo and name Demo.
This input_select has the options foo, bar, baz and qux.
Then I added a dashboard with this configuration:

views:
  - title: Home
    cards:
      - type: tile
        entity: input_select.demo
        features:
          - type: input_select-options
            options:
              - foo
              - baz
              - qux

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.
    • Im not sure what tests to add for the changes in this PR. If this is needed any guidance is appreciated :)

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

  • Documentation added/updated for www.home-assistant.io
    • I have only prepared a branch with the documentation change but have not yet opened a PR as I have a question regarding the coordination of publishing the docs and releaseing the feature.
      • Is it enough to just link from the docs PR to this PR? Or do I have to do anything else?

@home-assistant
Copy link

Hi @rbnis

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@spacegaier
Copy link
Member

Could you add a screenshot to show how it would look like?

Copy link
Member

@piitaya piitaya left a comment

Choose a reason for hiding this comment

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

Hi 👋
Thanks for the contribution.
There are some missing points before merging it :

  • Select entities must be supported too
  • If there are many options, the texts will not fit. You should display a dropdown (but we didn't have one that fit the tile card for now 😔). And we can add an option list | dropdown so the user can select the desired display.

@@ -17,6 +18,7 @@ const TYPES: Set<LovelaceTileFeatureConfig["type"]> = new Set([
"vacuum-commands",
"fan-speed",
"alarm-modes",
"input_select-options",
Copy link
Member

Choose a reason for hiding this comment

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

Can we rename it to select-options and add support for select entity too?

}

private _schema = memoizeOne(
(localize: LocalizeFunc, stateObj?: HassEntity) =>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
(localize: LocalizeFunc, stateObj?: HassEntity) =>
(stateObj?: HassEntity) =>

switch (schema.name) {
case "options":
return this.hass!.localize(
`ui.panel.lovelace.editor.card.tile.features.types.alarm-modes.${schema.name}`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
`ui.panel.lovelace.editor.card.tile.features.types.alarm-modes.${schema.name}`
`ui.panel.lovelace.editor.card.tile.features.types.select-options.${schema.name}`

Comment on lines +11 to +14
export const supportsInputSelectOptionsTileFeature = (stateObj: HassEntity) => {
const domain = computeDomain(stateObj.entity_id);
return domain === "input_select";
};
Copy link
Member

Choose a reason for hiding this comment

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

Should support select entities too.

Comment on lines +65 to +69
(option) =>
this._config?.options?.includes(option) ||
this._config?.options === undefined ||
this._config?.options?.length === 0
)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
(option) =>
this._config?.options?.includes(option) ||
this._config?.options === undefined ||
this._config?.options?.length === 0
)
(option) =>
this._config?.options?.includes(option) ||
this._config?.options === undefined
)

If options is empty we must display nothing.

.options=${options}
.value=${value}
@value-changed=${this._valueChanged}
.ariaLabel=${options}
Copy link
Member

Choose a reason for hiding this comment

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

This must be a label, not options

@piitaya piitaya mentioned this pull request Sep 20, 2023
9 tasks
@piitaya
Copy link
Member

piitaya commented Sep 20, 2023

I close this PR as it's replaced by #17971.

@piitaya piitaya closed this Sep 20, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Sep 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants