# How can I get the current state of my device?

**URL:** https://discourse.nodered.org/t/how-can-i-get-the-current-state-of-my-device/91015
**Category:** General
**Tags:** http-request, websocket
**Created:** [16 September 2024 09:17 UTC](https://discourse.nodered.org/t/how-can-i-get-the-current-state-of-my-device/91015 "2024-09-16T09:17:17Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![hogka](https://avatars.discourse-cdn.com/v4/letter/h/a5b964/32.png) [@hogka](https://discourse.nodered.org/u/hogka)
#### Post date: [16 September 2024 09:17 UTC](https://discourse.nodered.org/t/how-can-i-get-the-current-state-of-my-device/91015/1 "2024-09-16T09:17:17Z")

</div>

Hello everyone!  
I'm kinda new to Node Red and I'm facing some issues, so I hope somebody more experienced than me can help me.  
The thing is I'm trying to get the current state of my LoRa device using a GET HTTP in node and HTTP out node, plus a web socket out node to display the template I created (I followed a tutorial I saw on YT). By doing this I get to see the device's state only if I go to my URL before the device sends an uplink, but the goal is to check the device's state anytime, included after it sends the uplink, so how can I do it?  
I saw there's a dashboard option where I do actually see the device's status anytime but in my case this info should be availabe via URL, so I don't think the is the right solution...

This is what my flow looks like (disclaimer: I'm showing a different device but it's the same machanism).

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/d/1d1c66101052610fe288684de2c10688d369abc4.png)  
When I go to the URL the page doesn't show the infos, and I have to wait for the device to send an uplink which requires a lot of time. This is how the page looks like after I manually activate the device.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/c/0c02746f07c3a6c85c7d104e2dc511067723d9f7.png)

To sum up, I'd like to see the last pic everytime I go to the URL, instead of waiting an uplink from the device.

Thanks in advance to anyone who will help me and I'm sorry for my bad English.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [16 September 2024 09:20 UTC](https://discourse.nodered.org/t/how-can-i-get-the-current-state-of-my-device/91015/2 "2024-09-16T09:20:02Z")

</div>

Welcome to the forum.

Could you post the Youtube link?

It is hard to know what it is saying without watching it.

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [16 September 2024 09:28 UTC](https://discourse.nodered.org/t/how-can-i-get-the-current-state-of-my-device/91015/3 "2024-09-16T09:28:38Z")

</div>

I find the use of HTTP requests to obtain device status confusing (I mostly use MQTT) but I think this might be a solution:

Request the device status fairly frequently, perhaps after a 5 seconds delay from the last response.  
Store the value in a flow context variable.  
Change your template to output the value of the context variable.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [16 September 2024 09:34 UTC](https://discourse.nodered.org/t/how-can-i-get-the-current-state-of-my-device/91015/4 "2024-09-16T09:34:45Z")

</div>

So this LoRa device..... Does it have an IP?

If it does, you could `ping` it. 🤷

---

<div class="post-metadata">

### Author: ![hogka](https://avatars.discourse-cdn.com/v4/letter/h/a5b964/32.png) [@hogka](https://discourse.nodered.org/u/hogka)
#### Post date: [16 September 2024 09:37 UTC](https://discourse.nodered.org/t/how-can-i-get-the-current-state-of-my-device/91015/5 "2024-09-16T09:37:55Z")

</div>

Hi, thanks for the reply!  
Here's the video and page I used as a reference:

[![](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/5/e559df5e25890279512279a7ee7df83f68402b04.jpeg "For Beginners 3: Node-Red IoT Data on WebSocket") ](https://www.youtube.com/watch?v=IYNFFSvT2p4)

---

<div class="post-metadata">

### Author: ![hogka](https://avatars.discourse-cdn.com/v4/letter/h/a5b964/32.png) [@hogka](https://discourse.nodered.org/u/hogka)
#### Post date: [16 September 2024 09:42 UTC](https://discourse.nodered.org/t/how-can-i-get-the-current-state-of-my-device/91015/6 "2024-09-16T09:42:27Z")

</div>

Hi, thanks for the advice!  
I'll do some research about context variable and see if it works out.

---

<div class="post-metadata">

### Author: ![hogka](https://avatars.discourse-cdn.com/v4/letter/h/a5b964/32.png) [@hogka](https://discourse.nodered.org/u/hogka)
#### Post date: [16 September 2024 09:50 UTC](https://discourse.nodered.org/t/how-can-i-get-the-current-state-of-my-device/91015/7 "2024-09-16T09:50:59Z")

</div>

I don't know the device's IP. It's connected to a Milesight gateway and I'm using its Node Red extension to get the Lora inputs.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [16 September 2024 09:52 UTC](https://discourse.nodered.org/t/how-can-i-get-the-current-state-of-my-device/91015/8 "2024-09-16T09:52:56Z")

</div>

Sorry, I am not too familiar with LoRa stuff myself.

But.... If I am not wrong, it connects to a WiFi network - or what ever.  
It gets an IP address when it connects.

So: as long as it is connected to a network, it will have an IP address.

But I am way out of my depth with LoRa stuff.

Maybe someone else could clarify this point.

---

<div class="post-metadata">

### Author: ![hogka](https://avatars.discourse-cdn.com/v4/letter/h/a5b964/32.png) [@hogka](https://discourse.nodered.org/u/hogka)
#### Post date: [17 September 2024 09:39 UTC](https://discourse.nodered.org/t/how-can-i-get-the-current-state-of-my-device/91015/9 "2024-09-17T09:39:37Z")

</div>

I've figured it out! I've done lot of changes but mostly important I used global variables and deleted the web socket out node.

Thank you for your time 🙌

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [1 October 2024 09:40 UTC](https://discourse.nodered.org/t/how-can-i-get-the-current-state-of-my-device/91015/10 "2024-10-01T09:40:19Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
