Binding a status into an item: Is it possible?

I’m wondering if it’s possible to bind a thing’s status directly to an item. For example, in pseudocode:

String Smoke_Detector_Status "Status: [%s]" {channel="[Smoke_Detector_Thing.status]"}

I’m aware that it’s possible to do this with rules but I don’t think that that’s the right solution for me as I have dozens and dozens of items. Is this possible?

No. Use rules.

Alternatively, what are you actually trying to achieve, that you have focused on Thing status for?

I’d like to know if a device goes offline (in a general case) and react accordingly. Specifically, many of my devices I’d like to use this for are never used in an ideal scenario (smoke detectors, flood sensors, window break sensors) and don’t regularly update a channel (many of them only have a “low battery” and a “state” channel). Despite this, I’ve noticed that they do become “offline” when the bridge can’t communicate with them at regular intervals. I’d like to know if a flood sensor or a smoke detector somewhere just goes dead but never reports low battery or anything. Right now I can do this by going into the “things” tab on paperui and scrolling through to see what’s not marked as “online”

Thing status is unreliable for this purpose. It’s best interpreted to mean that the pathway to the device is available, not as an indication of device status.

Wanting to know if somethings fails to “check in” at regular intervals is pretty easy. It’s what the expire binding is made for.
E.g set an expire for 24hrs on a battery level Item and have expire set state UNDEF.
Now it is easy for a rule to detect an Item (or Group member) changing to UNDEF and wave flags or whatever.

This relies on you being able to find something about your device that periodically updates, just the same as Thing, but you have control. openHAB has no idea if a smoke alarm should say “I’m okay” every ten minutes, or once a week, but you can find out.

1 Like

For a full example of what rossko57 is talking about see Design Patterns: Generic Is Alive. As he indicated, the Thing status is a poor proxy for the device’s status. For another example, if you have a battery powered Zwave device, it might be completely dead for a very long time (weeks) before the binding will decide to mark it as offline. But many of these devices might have a “hey, I’m still alive” message they publish periodically, maybe a heart beat or a battery level status message, which you can use and timeout the device if you don’t receive this message for too long of a time. This is how I detect when my battery powered zwave smoke alarms go offline.

1 Like

As a side note, this might provide help in the future if it gets merged:

1 Like