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 number tile feature #18562

Merged
merged 7 commits into from
Nov 10, 2023
Merged

Conversation

JosephAbbey
Copy link
Contributor

@JosephAbbey JosephAbbey commented Nov 7, 2023

Proposed change

Number Input (buttons or slider)
image

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

type: tile
entity: input_number.test
features:
  - type: number
    style: buttons
  - type: number
    style: slider

Additional information

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.

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

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.

Thanks ! I added few comments.

src/translations/en.json Outdated Show resolved Hide resolved
@home-assistant
Copy link

home-assistant bot commented Nov 8, 2023

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 November 8, 2023 10:40
@piitaya piitaya changed the title hui-number-tile-feature Add number tile feature Nov 8, 2023
private async _setValue(ev: CustomEvent) {
const stateObj = this.stateObj!;

await this.hass!.callService("input_number", "set_value", {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that for number domain the service that should be called is number.set_value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I just added that domain so I hadn't tested it yet, good catch.

private async _setValue(ev: CustomEvent) {
const stateObj = this.stateObj!;

const domain = computeDomain(stateObj.entity_id);
Copy link
Contributor

Choose a reason for hiding this comment

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

can we computeDomain once or memoize it? Now it is calculated every time we want to change the value.

Copy link
Member

@piitaya piitaya Nov 9, 2023

Choose a reason for hiding this comment

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

I don't think this will change something because computeDomain is a very simple function and it will make the code complicated. Memoization must be used for large computing like transforming array or computing complex object.
Adding memoization here will be worst because it will introduce multiple checks to compute the value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function also only runs on change not on render so it won't run that often.

@piitaya
Copy link
Member

piitaya commented Nov 9, 2023

@JosephAbbey is this ready to review?

@JosephAbbey JosephAbbey marked this pull request as ready for review November 9, 2023 16:22
@home-assistant home-assistant bot requested a review from piitaya November 9, 2023 16:22
@piitaya
Copy link
Member

piitaya commented Nov 10, 2023

Thank you ! Ok for me !

@piitaya piitaya enabled auto-merge (squash) November 10, 2023 08:24
@piitaya piitaya merged commit 21644c7 into home-assistant:dev Nov 10, 2023
8 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 9, 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