How to check client device offline

i want to know my client device status (online, offline-not connect to MQTT server) . i search in MQTT binding but we cant get status respone and ping of MQTT server. Please show me how to make this. thanks

There are several ways you can do this:

  1. Network Health binding: it periodically pings the IP of your device and flips a switch to OFF if the device fails to respond

  2. MQTT Last Will and Testament (LWT): when the MQTT broker detects that the client is no longer connected it will publish the LWT message to the configured topic (note LWT is configured on the remote client, not in OH). Then create a switch Item to subscribe for those LWT messages and flip it off when you see a LWT message and back ON when you see any other message (use a rule).

  3. SNMP binding: Configure your device to support SNMP and use the SNMP binding to keep tabs on its status.

I’m sure there are others.

1 Like

thanks for your suggest @rlkoshak. I think with my situation perhaph way 2 is possible.
i have 1 server host in amazon run openHAB and Mosquitto MQTT. In my openhab.cfg i edited line “mqtt:broker.lwt=system”–> restart my Openhab, use mosquitto_sub -t system and then i turn off my device but i don’t get any message from topic system. do i miss any config?please help me > thanks.

You need to configure the LWT on your devices, not in openHAB.cfg. then you need to configure an item in OH to look for the LWT message from the devices. Setting the LWT in openHAB. Cfg will only send the LWT message when openHAB goes offline.

1 Like

Thanks so much @rlkoshak, i finish in configuring LWT on my device . Your supports gave me some knowldge about openhab and MQTT. Again, thanks and have a good time.