Thing status is not updated to OFFLINE even when the power plug is cut

  • Platform information:
    • Hardware: Raspberry pi 3
    • OS: openhasbian
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version: 2.4
  • Issue of the topic: The status was not updated

I found that this script doesnt work :

var thingStatusInfo = getThingStatusInfo("zwave:device:c5155aa4:node2")

if ((thingStatusInfo !== null) && (thingStatusInfo.getStatus().toString() == "ONLINE")) {
    logInfo("ThingStatus", "The thing is online.")
} else {
    logError("ThingStatus", "The thing is offline or doesn't exist.")

When the yeelight ceiling light power plug was cut, the status remain “ONLINE” forever. Calling the thingStatusInfo.getStatus().toString() will also result in “ONLINE”. Any idea?

How do we detect if the lamp is OFFLINE because of power to that lamp being cut?

You’ll find many other example of Things behaving like that throughout openHAB. Why? Think of the Thing as showing the availability of the pathway to the device, rather than the device being operational. Here, the zwave network is working.

In zwave in particular, what would you expect a sleeping battery operated device to look like in this respect - it as after all working normally, and may send a message at any moment.

I don’t know but I think if you pull out your zwave stick your Thing will go offline.

As a generic solution; if you get regular updates from some device, you can use the expire binding to set a state of UNDEF for example, if the regular updates stop.

I am using Yeelight Ceiling light. Btw, i can do a simple ping to the device ip to know if the device is online/offline. however since i am new to openhab, any documentation how to write script to perform ping every 5s and update the item based on the result from ping?

See network binding for pingable device status.

Does it means that I need to build my own binding? Since I am using ready made binding add-on available.

No, there is a binding provided called network binding which can ping IP devices automatically and report their status, which is what you wanted to happen.

Doesn’t have anything to do with zwave Things you describe in your first post though.

Yes, the zwave was only example script from the doc, i adjusted the script according to my device.

however, i have attempted to follow the doc, and did the following scripts:

// services/network.cfg

// ceiling.items
Switch CeilingLampStatus { channel="network:pingdevice:ceiling_lamp:online" }

// ceiling.things
network:pingdevice:ceiling_lamp [ hostname="", retry=0, timeout=500, refreshInterval=5000 ]

However the item CeilingLampStatus still remain NULL. I can ensure the host is pingable.

Any input?

Have you installed the network binding? Does that have anything to say in openhab.log? What does PaperUI tell you about your Thing?

Thanks! its working now. Was not aware that we should install a binding called “Network”.