# Get gateway tag data using peripheral payload

**URL:** <https://forums.losant.com/t/get-gateway-tag-data-using-peripheral-payload/3194>\
**Category:** Help\
**Tags:** workflow, device\
**Created:** [August 12, 2020, 7:57pm UTC](https://forums.losant.com/t/get-gateway-tag-data-using-peripheral-payload/3194 "2020-08-12T19:57:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jake\_Bengtson](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@Jake\_Bengtson](https://forums.losant.com/u/Jake_Bengtson)\
**Post date:** [August 12, 2020, 7:57pm UTC](https://forums.losant.com/t/get-gateway-tag-data-using-peripheral-payload/3194/1 "2020-08-12T19:57:20Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Aidan\_Zebertavage](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/aidan_zebertavage/32/2719_2.png) [@Aidan\_Zebertavage](https://forums.losant.com/u/Aidan_Zebertavage)\
**Post date:** [August 12, 2020, 9:55pm UTC](https://forums.losant.com/t/get-gateway-tag-data-using-peripheral-payload/3194/3 "2020-08-12T21:55:22Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/2/2866618144415db9cc879f79f2f5f547b522931b.png)

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](https://forums.losant.com/uploads/short-url/7Nu05HKftNMqsiNMIvuLTQ6Qr05.flow) (4.0 KB)

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

> **[Device: Get Node](https://docs.losant.com/workflows/data/get-device/#device-get-node)**
>
> Learn more about the Losant Device: Get Node.

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

Thanks  
@Aidan_Zebertavage

---

<div class="post-metadata">

**Author:** ![Jake\_Bengtson](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@Jake\_Bengtson](https://forums.losant.com/u/Jake_Bengtson)\
**Post date:** [August 13, 2020, 2:10am UTC](https://forums.losant.com/t/get-gateway-tag-data-using-peripheral-payload/3194/5 "2020-08-13T02:10:39Z")

</div>

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)

![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/2/23c3ef0742a995d9c228917c63598ba0cc3316df.png)

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

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/8/81f757ce45f1c1898768a962079561d0343b5317.png)

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!

---

<div class="post-metadata">

**Author:** ![Aidan\_Zebertavage](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/aidan_zebertavage/32/2719_2.png) [@Aidan\_Zebertavage](https://forums.losant.com/u/Aidan_Zebertavage)\
**Post date:** [August 13, 2020, 2:57pm UTC](https://forums.losant.com/t/get-gateway-tag-data-using-peripheral-payload/3194/7 "2020-08-13T14:57:35Z")

</div>

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](https://forums.losant.com/uploads/short-url/fdLka2oGqzRnlbiIEJBgUYQNcAz.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:

> **[How To Simulate Devices and Incoming Data for IoT Applications](https://www.losant.com/blog/use-losant-to-simulate-iot-data)**
>
> Simulate data for IoT applications without physical objects using Losant. Follow this tutorial to fine-tune your IoT user interface by simulating IoT data.

Hope this helps!

Thanks,  
@Aidan_Zebertavage
