Custom Widget: How to access the "Data from" data inside the custom widget

Team,

I would like to make a SIMPLE custom widget. I have attached a file below. The idea is to have more flexibility for onscreen display and the infobox than the image marker widget allows. Since the script is for monitoring water moisture on an orchard, I don’t really need real-time… - so I think I only need to grab the variables using on “onStart” method.

background: I’m not a strong Javascript developer… which makes this harder for me.

In this script the following two items are something I don’t understand:

* What is the proper way to put code inside the onStart method/event? (note: I tried moving my HTML inside the onStart and I could not get it to work )

* What is the proper way to get the data from the device/variable placed in the “Data from” section of the custom widget? ( I couldn’t find any current example code ).

Thanks!

Marlan

Everyone,

I can’t find good docs on the onStart and onRealtime.

So I’m piecing it together.

onStart() - runs early 1x and gets filled w the parameters. I don’t see that it gets any dynamic data. parameters are delivered in the widget → edit → parameters section in the dashboard setup.

onRealtime() - I THINK, runs on each update *AND* runs at initialization. It grabs all the data listed in the “Data from” section of the widget in the dashboard setup. I don’t see how to limit how much data comes across - I’d like to limit it to the LAST update only for each variable. Once I find out, I’ll report here.

On the onRealtime function, it gets its data from the Dashboard->Edit Mode->Edit Custom Widget settings shown here:

As you can see, I have TWO (2) items in the “Data from”.

If I changed the settings in the “Options” to limit to ONE (1) sample for each variable, I would have expected in the onRealtime() function to return TWO separate pieces of data, ONE FOR EACH “Data from”.

But it doesn’t work that way. No matter how hard I try, I can’t get it to do that. When I set the “max data points” to 2, I get this:

However, I would have expected something more like this:

{qty: 2, bucket: “id of item1 in setup”, origin: “6626d0e5f6e9f600109624e8”, variables: [“water_soil”]}

{qty: 2, bucket: “id of item2 in setup”, origin: “6626d0e5f6e9f600109624e8”, variables: [“water_soil”]}

I’m going to post a more specific community title.