# Semaphore status

**URL:** https://discourse.nodered.org/t/semaphore-status/59492
**Category:** General
**Created:** [7 March 2022 13:29 UTC](https://discourse.nodered.org/t/semaphore-status/59492 "2022-03-07T13:29:32Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![alda](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@alda](https://discourse.nodered.org/u/alda)
#### Post date: [7 March 2022 13:29 UTC](https://discourse.nodered.org/t/semaphore-status/59492/1 "2022-03-07T13:29:32Z")

</div>

I'm using a semaphore take and semaphore leave to send a multiple commands to main unit. Problem is, that at this moment I can't see if all commands are already sent. Is it any possibilty how to implement any status LED if semaphor is still running or if it's done ?

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [7 March 2022 13:44 UTC](https://discourse.nodered.org/t/semaphore-status/59492/2 "2022-03-07T13:44:42Z")

</div>

Assuming that you are using node-red-contrib-semaphore then the status is shown below the node. You should be able to pick that up in a Status node if you need to.

---

<div class="post-metadata">

### Author: ![alda](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@alda](https://discourse.nodered.org/u/alda)
#### Post date: [7 March 2022 13:58 UTC](https://discourse.nodered.org/t/semaphore-status/59492/3 "2022-03-07T13:58:56Z")

</div>

Thank you. I tried to look on the guide video for status node, but really not cler for me how to implement such simple function like switch LED on/off depends on semaphore status.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [7 March 2022 14:13 UTC](https://discourse.nodered.org/t/semaphore-status/59492/4 "2022-03-07T14:13:49Z")

</div>

The first part is to get the status, then you can worry about how to drive the LED.

Have you added a status node linked to the semaphore node and fed that into a debug node to see what it gives? Make sure you understand what it shows.

---

<div class="post-metadata">

### Author: ![alda](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@alda](https://discourse.nodered.org/u/alda)
#### Post date: [7 March 2022 14:42 UTC](https://discourse.nodered.org/t/semaphore-status/59492/5 "2022-03-07T14:42:21Z")

</div>

Yes, status node is working only with semaphore take, for leave there isn't a status. I will check step by step all texts which I'm receving, but problem is, that last staus I will receive when last command is sent, but semaphore isn't finished (finished is when last answer from main unit is received).

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [7 March 2022 15:17 UTC](https://discourse.nodered.org/t/semaphore-status/59492/6 "2022-03-07T15:17:37Z")

</div>

What are you seeing from the status node?

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [7 March 2022 15:29 UTC](https://discourse.nodered.org/t/semaphore-status/59492/7 "2022-03-07T15:29:07Z")

</div>

Try this example to see how the status works

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/2/c294a753db92b7b4200231c02e4e1682f4f436de.png)

```auto
[{"id":"48c6037f61a92b41","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":220,"y":2300,"wires":[["4fc2999c7fa9fd88"]]},{"id":"4fc2999c7fa9fd88","type":"semaphore-take","z":"bdd7be38.d3b55","config":"988e46c04a575685","name":"","x":380,"y":2300,"wires":[["a24cfa5d45f991b6"]]},{"id":"f6026b9ce35a29c4","type":"debug","z":"bdd7be38.d3b55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":2300,"wires":[]},{"id":"a24cfa5d45f991b6","type":"change","z":"bdd7be38.d3b55","name":"Starting","rules":[{"t":"set","p":"payload","pt":"msg","to":"Starting","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":2300,"wires":[["f6026b9ce35a29c4","0dd211fec225201c"]]},{"id":"0dd211fec225201c","type":"delay","z":"bdd7be38.d3b55","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":220,"y":2380,"wires":[["3ab29f0ac7b4babb"]]},{"id":"3ab29f0ac7b4babb","type":"semaphore-leave","z":"bdd7be38.d3b55","config":"988e46c04a575685","name":"","x":390,"y":2380,"wires":[["3fca666f89f73061"]]},{"id":"3fca666f89f73061","type":"change","z":"bdd7be38.d3b55","name":"Done","rules":[{"t":"set","p":"payload","pt":"msg","to":"Done","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":2380,"wires":[["f6bc2ab85ce92070"]]},{"id":"f6bc2ab85ce92070","type":"debug","z":"bdd7be38.d3b55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":2380,"wires":[]},{"id":"93f8063e2f68aab3","type":"status","z":"bdd7be38.d3b55","name":"","scope":["4fc2999c7fa9fd88"],"x":360,"y":2260,"wires":[["ed86577f04cbfd47"]]},{"id":"ed86577f04cbfd47","type":"debug","z":"bdd7be38.d3b55","name":"msg.status.text","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"status.text","targetType":"msg","statusVal":"","statusType":"auto","x":540,"y":2260,"wires":[]},{"id":"988e46c04a575685","type":"semaphore-config","name":"Test","capacity":"1"}]

```

---

<div class="post-metadata">

### Author: ![alda](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@alda](https://discourse.nodered.org/u/alda)
#### Post date: [7 March 2022 17:28 UTC](https://discourse.nodered.org/t/semaphore-status/59492/8 "2022-03-07T17:28:19Z")

</div>

thanks, it's clear how it works, but I'm not able modify a msg content because message is used as command for main unit. So I must work with status text and make a function which will read a staus and depend on status text will switch on a LED on the start and OFF on the end.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [7 March 2022 17:44 UTC](https://discourse.nodered.org/t/semaphore-status/59492/9 "2022-03-07T17:44:12Z")

</div>

Put this function, or something similar on the output of the Status node, it sends true or false in msg.payload dependent on whether there is something in the queue. You should be able to use that to control the led.

```auto
// return true if some in queue, false if all done
let numberTaken
if (msg.status.text) {
    numberTaken = Number(msg.status.text.split(/[:\/]/)[1])
    if (numberTaken === 0) {
        msg.payload = false // all done
    } else {
        msg.payload = true // still some in queue
    }
} else {
    // no status so ignore it
    msg = null
}
return msg;

```

---

<div class="post-metadata">

### Author: ![alda](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@alda](https://discourse.nodered.org/u/alda)
#### Post date: [7 March 2022 18:09 UTC](https://discourse.nodered.org/t/semaphore-status/59492/10 "2022-03-07T18:09:45Z")

</div>

ok, thanks. I will do this way

---

<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: [21 March 2022 18:09 UTC](https://discourse.nodered.org/t/semaphore-status/59492/11 "2022-03-21T18:09:49Z")

</div>

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