Device State does not match Status

The smart things devices list shows a devices status ONLINE/OFFLINE/ACTIVE/HUB_DISCONNECTED. Is there any way for a smart app to access this variable?

I tried extracting device state by getting all its attributes as follows. However, the field DeviceWatch-DeviceStatus in this seems to not match the above status. For example, one of my smart locks correctly says “ONLINE” on a devices listing but the attribute DeviceWatch-DeviceStatus is NULL.

    def device_state = [:]    
    for (attribute in device.supportedAttributes) {
        device_state."${attribute}" = device.currentValue("${attribute}")

How do I accurately get the status as shown in the smart things dashboard?


Have you tried device.getStatus()?

Thanks. I did end up using the state as you pointed out and it works for my purposes. Just seems strange that the state does not match the attribute, and specifically why the latter is null.

DeviceWatch-DeviceStatus is a special attribute for the device health feature, is different than the device status, and is not supported/set by all device drivers.