mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-26 14:27:20 +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;
|
return subTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_setImmediateValue(newImmediateValue) {
|
||||||
|
super._setImmediateValue(Math.round(newImmediateValue));
|
||||||
|
}
|
||||||
|
|
||||||
_calcStep(value) {
|
_calcStep(value) {
|
||||||
if (!this.step) {
|
if (!this.step) {
|
||||||
return parseFloat(value);
|
return parseFloat(value);
|
||||||
|
@ -52,6 +52,7 @@ class MoreInfoFan extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
|||||||
caption="[[localize('ui.card.fan.speed')]]"
|
caption="[[localize('ui.card.fan.speed')]]"
|
||||||
min="0"
|
min="0"
|
||||||
max="100"
|
max="100"
|
||||||
|
step="[[computePercentageStepSize(stateObj)]]"
|
||||||
value="{{percentageSliderValue}}"
|
value="{{percentageSliderValue}}"
|
||||||
on-change="percentageChanged"
|
on-change="percentageChanged"
|
||||||
pin=""
|
pin=""
|
||||||
@ -113,7 +114,7 @@ class MoreInfoFan extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
|||||||
|
|
||||||
<ha-attributes
|
<ha-attributes
|
||||||
state-obj="[[stateObj]]"
|
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>
|
></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) {
|
computeClassNames(stateObj) {
|
||||||
return (
|
return (
|
||||||
"more-info-fan " +
|
"more-info-fan " +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user