How do you send a variable to a bucket from a custom widget

Hi

I would like to send a variable created in a custom widget script to the bucket of the device where the data for the widget is coming from.

Thanks.

Hi Shepard!

Take a look at this article as it will help you send data via your custom widget. You’ll need to use the sendData function.

Hi Freddy

Thanks for the info. I have used this guide before and have managed to build a custom widget.
The issue im having is in the guide they use a button to send the data to the bucket. I would like to send the data to the bucket dynamically depending on a condition.
Something like this in the code snipet below:


/ Check if both distance and time conditions are met
            var movementStatus;
            if ((maxDistance >= circleRadius.value) && (timeElapsed < timeThreshold.value)) {
                // Significant movement - Apply your logic here
                console.log('Significant movement!');
                movementStatus = 'Moving';


                // Prepare data for sending
                var widgetData = {
                    variable: "movementStatus",
                    value: movementStatus
                };

                // Send data to TagoIO
                window.TagoIO.sendData(widgetData);

            } else {
                // Non-moving - Apply your logic here
                console.log('Non-moving!');
                movementStatus = 'Not Moving';

            }

Do You think this should work, if so then i should look else where if its not working
Thanks