-
Hello Roland, is it possible that if i set the value of a "Number Slider" variable SP ("setVariable('SP', curpos);" and use this variable in a shortcut, that the slider is not showing up? URL of the shortcut (GET): http://r1.fritz.box/cm?cmnd=ShutterPosition%20{{{SP}}} I was trying to kind of initialize the slider variable that it starts off with a specific value. But as soon as i do the setVariable, the slider is not showing up! Once i remove the setVariable instruction the slider is showing up as expected. Not sure if that is a bug, or if slider variables are just not meant to be initialized?? My use case: i can control my shutters via "HTTP Request shortcut", via Tasmota Interface or physical button. In the latter 2 cases, "HTTP Request Shortcuts" does not know the actual position of the shutter. Therefore i get that position from tasmota and wanted to assign this as initial value for the slider. I know that the slider variable can remember its value, but this may be wrong if the shutter was moved directly in tasmota or via physical button. Thanks for any insights! Regards Rainer |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Hi Rainer, This isn't an error, it's intended behavior, albeit a bit confusing. Basically,
In your case, you only want part 1 to change the stored value (which acts as the initial value), but not part 2, since you still want the variable to be resolved normally. You can achieve this by passing setVariable("my_slider_variable", 123, true); I'll see that I can make this more discoverable, as currently it's only mentioned at the end of the Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
Hi Roland, thanks for your answer. I obviously still have to better understand the concepts behind this app when it comes to scripting. My Scenario:
If i execute this shortcut, the slider variable dialog pops up as expected, and if i select a value my shutter is moved to that direction. If i call the shortcut a second time, the last selected value is preset and i can change it. So far, so good
Why is the slider dialog popping up again? i "only" want to query the VPOS value and then set it to the actual value of the shutter position (this might have changed, if i moved the shutter outside HTTP Request Shortcuts App). My hope was that if i call shortcut1 again after shortcut2 (which only should get the real position of the shutter), then the slider dialog will be initialized with the real shutter position. Maybe this scenario is too complicated. If you have any tips, i appreciated it, but don't spend too much time for that. I really like this app, as it helps to collect and automate the http requests. Probably i do not even see, what all is possible, because i have to dive into many new things (like javascript, different types of http requests, not even talking about intents and headers ....) Kind regards Rainer |
Beta Was this translation helpful? Give feedback.
-
Good evening, thank you for the explanation about why the dialog is popping up, when i did not expect it. As this just was meant for debugging there is no harm not using it! I tried your suggestion and it worked! Thanks! Need to play around a little bit further, as i plan to extend shortcut1 "after script processing" a bit. I plan to wait for approx 30 seconds (this is the time my shutters need to open/close) and based on the position value change the Icon of the shortcut. However you are writing that the "wait" command is blocking the app (and for this 30 seconds is too long). So maybe i need to find a way with "enqueueShortcut('shortcut2', null, 30 * 1000)" (which is non blocking as far as i understood). But i am progressing! Thanks! Rainer |
Beta Was this translation helpful? Give feedback.
I see, so you have shortcut 1 which you use to control the shutter, and you want to use shortcut2 to fetch the shutter's current state and use it as the initial value for the variable used in shortcut 1.
It pops up because you use
getVariable('VPOS')
in your debugging on line 2 in shortcut 2. This triggers the value resolution of VPOS. If you remove that line (and the last line which referencesdebug
), it should behave as expected.(There is currently no way to read a variable's previously stored value without also triggering the variable value resolution, i.e., the slider dialog in this case.)
If your goal is to make sure that in shortcut 1 yo…