mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-25 13:57:21 +00:00
Add support for percentage step size to fans (#8393)
This commit is contained in:
parent
741ac679a0
commit
ace7ee5622
@ -79,6 +79,10 @@ class HaSlider extends PaperSliderClass {
|
||||
return subTemplate;
|
||||
}
|
||||
|
||||
_setImmediateValue(newImmediateValue) {
|
||||
super._setImmediateValue(Math.round(newImmediateValue));
|
||||
}
|
||||
|
||||
_calcStep(value) {
|
||||
if (!this.step) {
|
||||
return parseFloat(value);
|
||||
|
@ -52,6 +52,7 @@ class MoreInfoFan extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
||||
caption="[[localize('ui.card.fan.speed')]]"
|
||||
min="0"
|
||||
max="100"
|
||||
step="[[computePercentageStepSize(stateObj)]]"
|
||||
value="{{percentageSliderValue}}"
|
||||
on-change="percentageChanged"
|
||||
pin=""
|
||||
@ -113,7 +114,7 @@ class MoreInfoFan extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
||||
|
||||
<ha-attributes
|
||||
state-obj="[[stateObj]]"
|
||||
extra-filters="speed,preset_mode,preset_modes,speed_list,percentage,oscillating,direction"
|
||||
extra-filters="percentage_step,speed,preset_mode,preset_modes,speed_list,percentage,oscillating,direction"
|
||||
></ha-attributes>
|
||||
`;
|
||||
}
|
||||
@ -154,6 +155,13 @@ class MoreInfoFan extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
||||
}
|
||||
}
|
||||
|
||||
computePercentageStepSize(stateObj) {
|
||||
if (stateObj.attributes.percentage_step) {
|
||||
return stateObj.attributes.percentage_step;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
computeClassNames(stateObj) {
|
||||
return (
|
||||
"more-info-fan " +
|
||||
|
Loading…
x
Reference in New Issue
Block a user