Poll a device or virtual device

Using a workflow, is it possible to retrieve the current value of a device or virtual device attribute even if that attribute was not in the triggering payload? My use-case is that I would like to increment the value of a numerical attribute on a device (or virtual device) in response to certain device events, but the device does not report the current value. (The value is only stored on Losant, so the device doesn’t actually know the value of the attribute.)

To give more context, I have a device that reports a certain attribute as “1” when it successfully completes a task (the “task complete” attribute). This attribute is not really a piece of device state; it represents the fact that an event has occurred on the device. When I send the “task complete” attribute, I would like to increment the “completed task count” attribute on a corresponding virtual device. To do so, though, I need to have the ability either:

  1. to query the current value of the “completed task count” attribute on the virtual device, or
  2. to report a “relative value” for the “completed task count” attribute, whereby I would report “1” to indicate that I want to increment the attribute’s value by one.

I don’t see a way in the available workflow nodes to read the attributes of a virtual device, or of a device, but that seems like it would be the most general way of accomplishing this task.

Thanks for all the help!
Travis

You can get the current state of a device using the Gauge Query node. Set the “Duration” property to “Last received data point”.

1 Like

Great, thanks! Using the Gauge Query and the Function nodes, it looks like I can do just about anything :slight_smile: