Get gateway tag data using peripheral payload

In my workflow for a peripheral device, I want to be able to look up data that is stored within the tags of the gateway that transmitted the peripheral’s payload. I’m guessing that I would use the “Device: Get” Data Node, but I’m not sure what I can pass in from the payload (largely because I can’t simulate the peripheral devices payload) and how to configure the node properly to look up the tags from the associated gateway. Help!

Hi @Jake_Bengtson,

Welcome to the Losant Forums! Happy to have you here, and we’re excited to help you out.

You are actually on the right track with using the Device: Get node for accessing gateway data. Your device payload includes a relayID field which is the ID of the Losant Resource that performed the action that caused the trigger. So for your use case, if the state is reported by the Gateway device, it’s performing that action that causes the Device State Trigger node in the Application workflow to fire, therefore the ID of the gateway will be represented by the relayId.

Configure the node to query by DeviceID, and provide {{relayID}} as the ID template.

You’ll then complete the configuration of this node by specifying the payload path to store the results of the query, which in this case would be the data associated with the gateway deviceID.

Another option, that would allow for more flexibility to monitor payloads with simulated data, would be to use two Device: Get nodes. The first gets the peripheral based on the {{triggerId}} payload field. The resulting data that is added to the payload will include a {{gatewayId}} field which can then be used for your query in the second Device: Get node. I’ve attached a workflow performing this process for your reference to help you get started.

gatewayid—workflow-develop.flow (4.0 KB)

As always, the docs are a great place to get oriented around configurations as well.

Let us know if that sets you on the right path!


Thanks for the help Aidan! Two follow up questions:

(1) In your attached example, it looks like the returned data from “Get Peripheral” is returned to data.working.triggerid (see below)


but then “Get Gateway” makes no reference to that path when getting the gatewayID (see below)

I would think that I would somehow need to reference that path in the payload, no?

(2) What is the best way to test this workflow? Using a Virtual Button only allows you to alter the data portion of the payload…

Thanks again!

Hey @Jake_Bengtson,

You are correct that in your set up you’ll need to direct the ID template field to where {{gatewayId}} is placed on the payload - this was just a placeholder for you to reference, apologies I should have clarified that in my response last night.

I updated the workflow file to better represent the ID templates and the result paths that you’ll see with your set up. Here in the first Get: Device Node I’m storing the result from the query at working.peripheralDevice, then in the second Get: Device node you’ll see that I’m following that same payload path to include the reference to the gatewayId through working.peripheralDevice.gatewayId and storing that at working.gatewayDevice.

gatewayid—workflow-develop(1).flow (4.0 KB)

In order to test this workflow with your specific set up (peripheral to gateway to Losant) you’ll need to build a separate workflow that simulates data for your peripheral device. This can be triggered off of a Virtual Button or a Timer trigger node. We had a great blog post by one of our Solutions Architects around this topic recently:

Hope this helps!