# Send me notification if status still "reconnecting after "

**URL:** <https://discourse.nodered.org/t/send-me-notification-if-status-still-reconnecting-after/33180>\
**Category:** General\
**Created:** [22 September 2020 13:55 UTC](https://discourse.nodered.org/t/send-me-notification-if-status-still-reconnecting-after/33180 "2020-09-22T13:55:31Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![hassengh](https://avatars.discourse-cdn.com/v4/letter/h/bc8723/32.png) [@hassengh](https://discourse.nodered.org/u/hassengh)\
**Post date:** [22 September 2020 13:55 UTC](https://discourse.nodered.org/t/send-me-notification-if-status-still-reconnecting-after/33180/1 "2020-09-22T13:55:31Z")

</div>

Hello ,  
how I can read communication status with device and it still more 1 minute the systeme send me notification " problem connect to devise".  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/a/7ad11c171f5c281750022a3e240742473b2815f6.png)

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [22 September 2020 14:30 UTC](https://discourse.nodered.org/t/send-me-notification-if-status-still-reconnecting-after/33180/2 "2020-09-22T14:30:34Z")

</div>

One possible way is using the status node to capture the status from the modbus node. You will get the status on the property "msg.status.text".

You may want to use then a switch node to define which message will trigger the notification (you will see that the modbus node provides more then one type of status). A trigger node will allow you to define how long to wait and how to notify.

 ![r-01](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/2/62a3c4dc58f99aadd7e89fa20010a728a9d3f1d8.jpeg)

---

<div class="post-metadata">

**Author:** ![hassengh](https://avatars.discourse-cdn.com/v4/letter/h/bc8723/32.png) [@hassengh](https://discourse.nodered.org/u/hassengh)\
**Post date:** [22 September 2020 14:36 UTC](https://discourse.nodered.org/t/send-me-notification-if-status-still-reconnecting-after/33180/3 "2020-09-22T14:36:56Z")

</div>

Hi Andrei ,  
You can send me source code ,  
I am begginer in node red

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [22 September 2020 14:48 UTC](https://discourse.nodered.org/t/send-me-notification-if-status-still-reconnecting-after/33180/4 "2020-09-22T14:48:56Z")

</div>

Sure, see below. You will need to tweek the configuration of the nodes and probably modify the flow to suit your use case.

```auto
[{"id":"38fe8a3a.af0a46","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"72d0b325.2f226c","type":"modbus-read","z":"38fe8a3a.af0a46","name":"mytcp","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"","dataType":"","adr":"0","quantity":"1","rate":"2","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"1fdecf8e.d4979","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":340,"y":160,"wires":[[],["514e3237.6f0e0c"]]},{"id":"514e3237.6f0e0c","type":"debug","z":"38fe8a3a.af0a46","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":580,"y":200,"wires":[]},{"id":"3f4699c9.f32e06","type":"status","z":"38fe8a3a.af0a46","name":"","scope":["72d0b325.2f226c"],"x":180,"y":340,"wires":[["8c64a36.b68816"]]},{"id":"413a1bdc.37ac74","type":"debug","z":"38fe8a3a.af0a46","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":750,"y":340,"wires":[]},{"id":"3a8ec86e.794008","type":"trigger","z":"38fe8a3a.af0a46","name":"","op1":"","op2":"failed","op1type":"nul","op2type":"str","duration":"1","extend":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":570,"y":340,"wires":[["413a1bdc.37ac74"]]},{"id":"da629ff1.066ba","type":"debug","z":"38fe8a3a.af0a46","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":530,"y":460,"wires":[]},{"id":"8c64a36.b68816","type":"switch","z":"38fe8a3a.af0a46","name":"","property":"status.text","propertyType":"msg","rules":[{"t":"eq","v":"broken","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":370,"y":340,"wires":[["3a8ec86e.794008"],["da629ff1.066ba"]]},{"id":"eb18db0.ba65528","type":"comment","z":"38fe8a3a.af0a46","name":"Here a node to notify, for example, Telegram","info":"","x":880,"y":300,"wires":[]},{"id":"1fdecf8e.d4979","type":"modbus-client","z":"","name":"mytcp","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]

```

---

<div class="post-metadata">

**Author:** ![hassengh](https://avatars.discourse-cdn.com/v4/letter/h/bc8723/32.png) [@hassengh](https://discourse.nodered.org/u/hassengh)\
**Post date:** [22 September 2020 15:04 UTC](https://discourse.nodered.org/t/send-me-notification-if-status-still-reconnecting-after/33180/5 "2020-09-22T15:04:24Z")

</div>

thanks it is work but I have ,  
some time value 1 and 0 , I don't understand why

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/7/372aced3d1256a70beac86e4d2ac44413f7ecc98.png)

```auto
[{"id":"2e7b7ba7.9731b4","type":"tab","label":"Flow 10","disabled":false,"info":""},{"id":"d56a2027.13657","type":"modbus-read","z":"2e7b7ba7.9731b4","name":"","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"","dataType":"Coil","adr":"10198","quantity":"2","rate":"","rateUnit":"","delayOnStart":false,"startDelayTime":"","server":"143b6522.db746b","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":130,"y":100,"wires":[[],["8f031964.89edf8"]]},{"id":"8f031964.89edf8","type":"debug","z":"2e7b7ba7.9731b4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"msg.status.text","targetType":"msg","statusVal":"","statusType":"auto","x":350,"y":240,"wires":[]},{"id":"51af56c0.69ba18","type":"status","z":"2e7b7ba7.9731b4","name":"","scope":["d56a2027.13657"],"x":80,"y":420,"wires":[["aea7db89.3a70d8"]]},{"id":"fc7e36ed.41e568","type":"debug","z":"2e7b7ba7.9731b4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":630,"y":360,"wires":[]},{"id":"96ad5477.621888","type":"trigger","z":"2e7b7ba7.9731b4","name":"","op1":"1","op2":"0","op1type":"val","op2type":"val","duration":"250","extend":"false","units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":420,"y":360,"wires":[["fc7e36ed.41e568"]]},{"id":"aea7db89.3a70d8","type":"switch","z":"2e7b7ba7.9731b4","name":"","property":"status.text","propertyType":"msg","rules":[{"t":"eq","v":"broken","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":250,"y":420,"wires":[["96ad5477.621888"]]},{"id":"143b6522.db746b","type":"modbus-client","z":"","name":"","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"195.145.150.106","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]

```

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [22 September 2020 15:27 UTC](https://discourse.nodered.org/t/send-me-notification-if-status-still-reconnecting-after/33180/6 "2020-09-22T15:27:19Z")

</div>

> [@hassengh](#):
>
> some time value 1 and 0 , I don't understand why

Indeed, this happens as consequence of how the trigger node is configured (picture below). As per the used configuration the trigger node will send the value "1" wait the configured time (250 ms) and then will send the value "0". You may want to change this configuration to the way that works better for you (for instance, send nothing and after 250ms sends an arbitrary value to notify.

 ![r-02](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/5/2562cfb8733304fffa0e176d3cb18076dc265d69.jpeg)

---

<div class="post-metadata">

**Author:** ![hassengh](https://avatars.discourse-cdn.com/v4/letter/h/bc8723/32.png) [@hassengh](https://discourse.nodered.org/u/hassengh)\
**Post date:** [22 September 2020 15:40 UTC](https://discourse.nodered.org/t/send-me-notification-if-status-still-reconnecting-after/33180/7 "2020-09-22T15:40:47Z")

</div>

in this example we don't have comparison between new status and old status  
But I can't receive notification if status device still offline more 250ms.  
I want compare after 250 ms new status with old status if equals send notification

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [22 September 2020 17:15 UTC](https://discourse.nodered.org/t/send-me-notification-if-status-still-reconnecting-after/33180/8 "2020-09-22T17:15:48Z")

</div>

Apparently the modbus node takes 25 seconds to send an update status.If this is true then you won´t be able to manage the notification with 250 milliseconds granularity.

I am not sure I understand how do you want to compare old status with new status. What do you expect to happen when old status = connection broken and new status is the same = connection broken ? Do you want to trigger notification in such case or only when the status changes from connected to not connected (or vice versa) ?

---

<div class="post-metadata">

**Author:** ![hassengh](https://avatars.discourse-cdn.com/v4/letter/h/bc8723/32.png) [@hassengh](https://discourse.nodered.org/u/hassengh)\
**Post date:** [22 September 2020 18:13 UTC](https://discourse.nodered.org/t/send-me-notification-if-status-still-reconnecting-after/33180/9 "2020-09-22T18:13:30Z")

</div>

yes I want send notification (via mail ) if devise offline

---

<div class="post-metadata">

**Author:** ![hassengh](https://avatars.discourse-cdn.com/v4/letter/h/bc8723/32.png) [@hassengh](https://discourse.nodered.org/u/hassengh)\
**Post date:** [23 September 2020 09:28 UTC](https://discourse.nodered.org/t/send-me-notification-if-status-still-reconnecting-after/33180/10 "2020-09-23T09:28:11Z")

</div>

thanks for all ,  
I find solution  
Link : [https://cookbook.nodered.org/basic/trigger-timeout](https://cookbook.nodered.org/basic/trigger-timeout)  
just change timestamp by status

```auto
[{"id":"6ea53ad8.2362a4","type":"debug","z":"ac14500e.2c57d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":450,"y":1160,"wires":[]},{"id":"3da6946e.184a5c","type":"inject","z":"ac14500e.2c57d","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":1160,"wires":[["38caaff4.03f6d","6ea53ad8.2362a4"]]},{"id":"38caaff4.03f6d","type":"trigger","z":"ac14500e.2c57d","op1":"","op2":"timeout","op1type":"nul","op2type":"str","duration":"5","extend":true,"units":"s","reset":"","bytopic":"all","name":"Watchdog","x":270,"y":1200,"wires":[["ae477709.016088"]]},{"id":"ae477709.016088","type":"debug","z":"ac14500e.2c57d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":450,"y":1200,"wires":[]}]

```

---

<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:** [7 October 2020 09:28 UTC](https://discourse.nodered.org/t/send-me-notification-if-status-still-reconnecting-after/33180/11 "2020-10-07T09:28:15Z")

</div>

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