@@ -31,25 +31,25 @@ class CustomFanRow extends Polymer.Element {
3131 style ='[[_lowOnColor]] '
3232 toggles name ="low "
3333 on-click ='setSpeed '
34- disabled ='[[_isOnLow]] '> LOW </ button >
34+ disabled ='[[_isOnLow]] '> [[_lowText]] </ button >
3535 < button
3636 class ='speed '
3737 style ='[[_medOnColor]] '
3838 toggles name ="medium "
3939 on-click ='setSpeed '
40- disabled ='[[_isOnMed]] '> MED </ button >
40+ disabled ='[[_isOnMed]] '> [[_medText]] </ button >
4141 < button
4242 class ='speed '
4343 style ='[[_highOnColor]] '
4444 toggles name ="high "
4545 on-click ='setSpeed '
46- disabled ='[[_isOnHigh]] '> HIGH </ button >
46+ disabled ='[[_isOnHigh]] '> [[_hiText]] </ button >
4747 < button
4848 class ='speed '
4949 style ='[[_offColor]] '
5050 toggles name ="off "
5151 on-click ='setSpeed '
52- disabled ='[[_isOffState]] '> OFF </ button >
52+ disabled ='[[_isOffState]] '> [[_offText]] </ button >
5353 </ div >
5454 </ hui-generic-entity-row >
5555 ` ;
@@ -63,11 +63,15 @@ class CustomFanRow extends Polymer.Element {
6363 } ,
6464 _config : Object ,
6565 _stateObj : Object ,
66- _lowOnColor : String ,
67- _medOnColor : String ,
68- _highOnColor : String ,
69- _offColor : String ,
70- _isOffState : Boolean ,
66+ _lowOnColor : String ,
67+ _medOnColor : String ,
68+ _highOnColor : String ,
69+ _offColor : String ,
70+ _lowText : String ,
71+ _medText : String ,
72+ _hiText : String ,
73+ _offText : String ,
74+ _isOffState : Boolean ,
7175 _isOnState : Boolean ,
7276 _isOnLow : Boolean ,
7377 _isOnMed : Boolean ,
@@ -80,12 +84,16 @@ class CustomFanRow extends Polymer.Element {
8084
8185 this . _config = {
8286 customTheme : false ,
83- sendStateWithSpeed : false ,
84- customIsOffColor : '#f44c09' ,
85- customIsOnLowColor : '#43A047' ,
86- customIsOnMedColor : '#43A047' ,
87- customIsOnHiColor : '#43A047' ,
88- customIsOffSpdColor : '#759aaa' ,
87+ sendStateWithSpeed : false ,
88+ customIsOffColor : '#f44c09' ,
89+ customIsOnLowColor : '#43A047' ,
90+ customIsOnMedColor : '#43A047' ,
91+ customIsOnHiColor : '#43A047' ,
92+ customIsOffSpdColor : '#759aaa' ,
93+ customOffText : 'OFF' ,
94+ customLowText : 'LOW' ,
95+ customMedText : 'MED' ,
96+ customHiText : 'HIGH' ,
8997 ...config
9098 } ;
9199 }
@@ -94,13 +102,17 @@ class CustomFanRow extends Polymer.Element {
94102
95103 const config = this . _config ;
96104 const stateObj = hass . states [ config . entity ] ;
97- const custTheme = config . customTheme ;
98- const sendStateWithSpeed = config . sendStateWithSpeed ;
99- const custOnLowClr = config . customIsOnLowColor ;
100- const custOnMedClr = config . customIsOnMedColor ;
101- const custOnHiClr = config . customIsOnHiColor ;
102- const custOffSpdClr = config . customIsOffSpdColor ;
103- const custOffClr = config . customIsOffColor ;
105+ const custTheme = config . customTheme ;
106+ const sendStateWithSpeed = config . sendStateWithSpeed ;
107+ const custOnLowClr = config . customIsOnLowColor ;
108+ const custOnMedClr = config . customIsOnMedColor ;
109+ const custOnHiClr = config . customIsOnHiColor ;
110+ const custOffSpdClr = config . customIsOffSpdColor ;
111+ const custOffClr = config . customIsOffColor ;
112+ const custOffTxt = config . customOffText ;
113+ const custLowTxt = config . customLowText ;
114+ const custMedTxt = config . customMedText ;
115+ const custHiTxt = config . customHiText ;
104116
105117
106118
@@ -126,7 +138,7 @@ class CustomFanRow extends Polymer.Element {
126138 }
127139 }
128140
129- let lowcolor ;
141+ let lowcolor ;
130142 let medcolor ;
131143 let hicolor ;
132144 let offcolor ;
@@ -184,17 +196,25 @@ class CustomFanRow extends Polymer.Element {
184196 }
185197 }
186198
199+ let offtext = custOffTxt ;
200+ let lowtext = custLowTxt ;
201+ let medtext = custMedTxt ;
202+ let hitext = custHiTxt ;
187203
188204 this . setProperties ( {
189205 _stateObj : stateObj ,
190- _isOffState : stateObj . state == 'off' ,
206+ _isOffState : stateObj . state == 'off' ,
191207 _isOnLow : low === 'on' ,
192- _isOnMed : med === 'on' ,
193- _isOnHigh : high === 'on' ,
194- _lowOnColor : lowcolor ,
195- _medOnColor : medcolor ,
196- _highOnColor : hicolor ,
197- _offColor : offcolor ,
208+ _isOnMed : med === 'on' ,
209+ _isOnHigh : high === 'on' ,
210+ _lowOnColor : lowcolor ,
211+ _medOnColor : medcolor ,
212+ _highOnColor : hicolor ,
213+ _offColor : offcolor ,
214+ _offText : offtext ,
215+ _lowText : lowtext ,
216+ _medText : medtext ,
217+ _hiText : hitext ,
198218 } ) ;
199219 }
200220
@@ -206,6 +226,7 @@ class CustomFanRow extends Polymer.Element {
206226 const speed = e . currentTarget . getAttribute ( 'name' ) ;
207227 if ( speed == 'off' ) {
208228 this . hass . callService ( 'fan' , 'turn_off' , { entity_id : this . _config . entity } ) ;
229+ this . hass . callService ( 'fan' , 'set_speed' , { entity_id : this . _config . entity , speed : speed } ) ;
209230 } else {
210231 if ( this . _config . sendStateWithSpeed ) {
211232 this . hass . callService ( 'fan' , 'turn_on' , { entity_id : this . _config . entity } ) ;
@@ -217,4 +238,3 @@ class CustomFanRow extends Polymer.Element {
217238}
218239
219240customElements . define ( 'fan-control-entity-row' , CustomFanRow ) ;
220-
0 commit comments