I use modbus relays either using modbus TCP or modbus RTU. In case if any slave is not online, I want to expose that as a variable to be monitored ideally in openhab app itself. Is it possible to get such variables for status of the slaves? Or is it possible to implement some mqtt client or something else to expose these status to some third party cloud application?
This feature can really improve openhab adaptation for people who are not geek but are techy enough to self diagnose at basic level.
I don’t know anything about modbus but assuming it works like most other OH add-ons, the Thing should go OFFLINE if the device the Thing represents goes offline. So you can monitor the status of the Thing(s) in a rule and do what ever you want (publish an MQTT message, send an email, attempt to restart the Thing or device, etc) when the Thing goes OFFLINE.
If modbus works differently from most OH add-ons and does not do this, you can set expire on one or more of the last Channels (e.g. lastReadSuccess) and set up a rule to watch for the Item(s) changing to UNDEF as a signal that it’s not responding.
You could also use Threshold Alert and Open Reminder [4.0.0.0;5.9.9.9] to do the same thing as the above (trigger an alert if an Item doesn’t change for too long a time) without messing with the states of your Items with expire.