File tree 1 file changed +20
-6
lines changed
1 file changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -190,18 +190,32 @@ export function GetActionsList(executeAction: (fcn: DoAction) => Promise<void>):
190
190
name : 'Set Volume to Specific Value' ,
191
191
options : [
192
192
{
193
- type : 'number ' ,
193
+ type : 'textinput ' ,
194
194
label : 'Volume' ,
195
195
id : 'value' ,
196
- default : 50 ,
197
- min : 0 ,
198
- max : 100 ,
199
- step : 1 ,
196
+ default : '' ,
197
+ useVariables : true ,
200
198
} ,
201
199
] ,
202
200
callback : async ( action ) => {
203
201
await executeAction ( async ( instance , deviceId ) => {
204
- if ( deviceId ) await ChangeVolume ( instance , deviceId , true , Number ( action . options . value ) )
202
+ if ( deviceId ) {
203
+ const value = await instance . parseVariablesInString ( String ( action . options . value ) )
204
+
205
+ if ( ! / ^ \d + $ / . test ( value ) ) {
206
+ instance . log ( 'warn' , `Invalid volume value: ${ value } ` )
207
+ return
208
+ }
209
+
210
+ const intValue = Number ( value )
211
+
212
+ if ( intValue < 0 || intValue > 100 ) {
213
+ instance . log ( 'warn' , `Volume value out of range: ${ intValue } ` )
214
+ return
215
+ }
216
+
217
+ await ChangeVolume ( instance , deviceId , true , intValue )
218
+ }
205
219
} )
206
220
} ,
207
221
} ,
You can’t perform that action at this time.
0 commit comments