# Modbus ON-Line / OFF-line status

**URL:** https://discourse.nodered.org/t/modbus-on-line-off-line-status/24813
**Category:** General
**Created:** [14 April 2020 14:09 UTC](https://discourse.nodered.org/t/modbus-on-line-off-line-status/24813 "2020-04-14T14:09:37Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![farcry](https://avatars.discourse-cdn.com/v4/letter/f/9de053/32.png) [@farcry](https://discourse.nodered.org/u/farcry)
#### Post date: [14 April 2020 14:09 UTC](https://discourse.nodered.org/t/modbus-on-line-off-line-status/24813/1 "2020-04-14T14:09:37Z")

</div>

Hello.  
I would like to monitor the OFFLINE status of Modbus device.  
For now I'm using SERIAL comunication.  
If the device is OFFLINE I would lit RED LIGHT.  
If it is ONLINE the light would be GREEN.  
I tried with STATUS (link below), but if device goes OFFLINE the function does not execute...

> <https://stackoverflow.com/questions/42220701/node-red-get-modbus-tcp-read-state-change>

How can I show OFFLINE status?

Thanks.

---

<div class="post-metadata">

### Author: ![farcry](https://avatars.discourse-cdn.com/v4/letter/f/9de053/32.png) [@farcry](https://discourse.nodered.org/u/farcry)
#### Post date: [14 April 2020 14:38 UTC](https://discourse.nodered.org/t/modbus-on-line-off-line-status/24813/2 "2020-04-14T14:38:05Z")

</div>

I have figured out.  
For now I use simple function (connected to button):

var status = msg.status.text;  
var error = false;  
msg = {};  
if(status.indexOf('active') == -1){  
msg.background = "RED"; //COMM ERROR  
}  
else{  
msg.background = "GREEN"; //COMM OK  
}  
return msg;

---

<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: [13 June 2020 14:38 UTC](https://discourse.nodered.org/t/modbus-on-line-off-line-status/24813/3 "2020-06-13T14:38:14Z")

</div>

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