Add mode attribute to number entity#43867
Add mode attribute to number entity#43867Shulyaka wants to merge 4 commits intohome-assistant:devfrom
Conversation
|
Hey there @home-assistant/core, mind taking a look at this pull request as its been labeled with an integration ( |
|
Hey there @home-assistant/core, mind taking a look at this pull request as its been labeled with an integration ( |
|
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
|
Dear bot, please remove the stale label. Thank you. |
|
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
|
May I ask someone to re-trigger the CI pipeline please? |
|
This requires a frontend PR as well? |
|
Probably, yes (after home-assistant/frontend#8325). |
Are the changes required as simple as reverting that pull request? I want to use the |
| return step | ||
|
|
||
| @property | ||
| def mode(self) -> str: |
There was a problem hiding this comment.
Isn't this competing with device class?
There was a problem hiding this comment.
It's an attribute that further classifies this entity which influences how it is represented.
There was a problem hiding this comment.
That is true, so is the device class, icon, name, picture and such itself.
There must be a way for an integration to provide details on e.g., min/max, but also a representation. I could see the frontend being able to override that (e.g., in a Lovelace configuration).
Alternatively, we could indeed introduce device classes to the number integration, although, in general, the input is not always related to the unit shown.
E.g., Speed. Could be something between 0-100%/1-255, or something between 500-15000rpm. The first would be a nice slider, the second... probably not that much.
There was a problem hiding this comment.
Correct me if I'm mistaken, but I assume that these changes are beyond the scope of this pull request.
Are there any changes necessary to get this merged in?
There was a problem hiding this comment.
It would be an alternative that would render this PR not needed.
There was a problem hiding this comment.
The advantage of the mode attribute is that it gives a platform more control over the representation, and the platform knows better whether the value it has is more discrete or monotonous. So, I would consider this PR as more about the nature of the data than just about a representation.
Also, it gives the control for the user to override it using the existing customize functionality.
As a compromise for the both, I can suggest to implement the same nice algorithm but as a default value for the attribute, e.g. instead of return MODE_SLIDER it would be more like return MODE_SLIDER if (max - min) / steps <= 255 else MODE_BOX.
There was a problem hiding this comment.
Also, it gives the control for the user to override it using the existing customize functionality.
That is not something that should be used to adjust UI behavior, for these things we have the UI itself.
I agree with the suggestion given by balloob for that matter.
There was a problem hiding this comment.
We should start with my suggestion and then we can see if this PR is still needed. Let's not apply multiple solutions at once.
|
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
Proposed change
Since the basic support for the
numberentity is merged (#42735), it's time to add additional features to it.The most important is the
modeattribute like withinput_number. It will be used to define the type of control that is more natural to the entity. The entities that are more analogue by nature could enjoy the nice slider in the frontend, while the ones that are more digital would provide input as text.Type of change
Example entry for
configuration.yaml:Additional information
Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: