Simple Device Counts based on status

I am working on some workflows and am trying to get some simple counts of device types and their status. Currently have a workflow that basically gathers all devices that have a “deviceClass” of “edgeCompute” and a “connectionStatus” of “connected” The result in the debugger looks great, but I get counts of “0”. I am unsure of what to put in the attributes other than the “aggregation” of “count”

Can you please clarify what you mean by:

The result in the debugger looks great, but I get counts of “0”.

It sounds like it’s both working and not working :slight_smile:

Also, if you can paste any screenshots that help communicate what you’re seeing, those are really helpful.

Thanks for the reply Brandon. I am using the Guage Query. You can see based on this screen shot that the debugger shows the placeholders as I laid them out, but the counts are all 0. I should have 3 total EdgeDevices, 2 of them are online, and 1 is currently offline.

Thanks, I understand now. I’d recommend using the Device: Get Node with the Return an object containing metadata along with results option. This will give you a totalCount field with the total number of devices matching your query.

In your example, the Gauge Query Node could return the number of devices if state_description was reported at least once for each device. Here’s what is happening with that query:

  1. The last received value for state_description is queried for every device matching your device query.
  2. The Count aggregation then counts how many data points were returned.

So if you have 5 devices and each device reported state_description at least once, you’ll receive 5 as the result.

If state_description was never reported for a device, it won’t show up in #1, so won’t be included in the aggregation in #2.

As a test, I did the same query using devices that I know have reported that attribute:

In any case, if your goal is to get the number of devices based on a device query, the Device: Get Node is the way to go.

Thank you sir, lastly, if wanted to place one of those values onto my custom page, i would call something like…{{}}. Is that correct?

The Endpoint Reply Node has a configuration field for what you’d like to send to the page to be rendered. If you choose Full Payload, then your example template could be correct.

If you choose to send a subset of your payload, then the template will change accordingly. Whatever you send to the page will be available on pageData.

Brandon, I am not having much luck getting access to this portion of the page data. The debugger shows everything correctly…

The full path is as follows…

Inside my custom page I am trying to display that value by enclosing it between {{}}.

Am I missing something??

What’s on your page’s context? You can see the context in the page’s render log when you refresh the page in your browser. What’s shown in the workflow debug log is not necessarily what’s available in the page context. The Endpoint Reply Node is what controls the data passed to the page.

We do have a great Deeper Dive webinar that explains how data makes it from a workflow to a page context to be rendered. This would be a great video to review:

I will checkout the video. The render log shows the same structure as the debug, so I am certain the data is there…

pageData.working.stats.edg.offline.count (this is from the render log)

Good morning Brandon,

I finished watching the video. Great stuff! Everything in the video was confirmed to be correct as far as my implementation is concerned, but I am still not having any luck. Any other direction you could direct me?

Brandon, so this is now working. There was something strange with the order that the workflow was going. I tweaked a few things and changed the flow and also changed to “Full Payload” on the endpoint reply.

Thank you for all your assistance!