[HELP] Thinger.io Slider widget auto resets to Min Value after making slider selection


I set slider value, device receives the value and performs task per value sent. However, the slider then resets to min value, in my case “0”, sends the “0” where the code performs task per “0” value, not what I want. Is the slider suppose to stay at the value I set? If so, why does it not stay at that value?


The same issue here. Exactly the same. Interestingly it does fire desired value once (e.g. to connected PWM) but then in a fraction of second it sends 0 and resets slider position back to zero.


Hi, you should define the resources to also support reporting the current value. From documentation:

Our sketch usually defines some parameters or variables that are used inside the loop code. This kind of resources are normally used to handle or control the execution behaviour. With this kind of resources we can modify any parameter we want to expose, like a float, an integer, a boolean, etc. In this example it is possible to remotelly modify the boolean sdLogging variable defined as a global variable.

thing["logging"] << inputValue(sdLogging);

It is also possible to define a callback function to know when the variable has changed, so we can perform any other action. For this use case, define the resource as the following to have some code executed when the hysteresisVar changes.

thing["hysteresis"] << inputValue(hysteresisVar, {
    // execute some code when the value change
    Serial.println("Hystereis changed to: ");

Check also the documentation at (specially the Show Input Resources State in Dashboards and API)



Thank you alvarolb,
Adding code to query and, when needed, modify the current resource state, like the linked document illustrated (see below code), worked like a charm.

thing[“resource”] << [](pson& in){
in = currentState;
currentState = in;

The slide setting now stays at last state and only changes when I move the slide.

The choice to use and the original design of “C++ 11 Lambda Functions” is genius. I have to admit, I’m not a seasoned C++ user so when I first had to setup a Thinger.io resource, I was clueless as to how it worked. I spent some time understanding C++ 11 Lambda Functions (here’s a video I found helpful; https://www.youtube.com/watch?v=uk0Ytomv0wY ), very convenient and powerful.

Thanks again.


Nice you get it working! Yes, using lambdas allowed a clean code and an easy resource definition. Resources in thinger are like callbacks that can receive and/or generate output… so, they are finally functions. The above definition, inputValue, is simple a macro that is translated to the same lambda you have posted, but in a compact format. But understanding the basic concepts, allows you more flexibility :slight_smile:


Thanks for this post, it really was very useful and the solution was quite easy. Paul, I was looking for information about the lambda functions and the video you posted was very timely. Thank you.

I have a question, I have some sensors that are not permanently on, and I would like the variable that is obtained from the dashboard through the slide widget will not be reset every time the device is turned on. Is this possible?