[Solved] Changing colour if item has not updated in x mins?

Coming from Domoticz and busy converting all my sensors or OH2 (Using mqtt)

One of the features I miss. (and can’t seem to work out how to do) is on Domoticz if you had a temperature sensor that had not sent an update in say 30 mins, then the sensor value would change colour to red. So you know it’s no longer sending updates and possibly needs a restart.

Is something like possible in OH2?

It depends on your needs. You can use the expire binding. Easy way:
.items:

Number MySensor "My Sensor [%.1f °C]" <temp> {sensor="binding...", expire="30m,-999"}

.sitemap:

Text item=MySensor valuecolor=[=-999="red"]

But you will get the value -999 to persistence. To avoid these wrong values, you will have to use a second item:
.items:

Number MySensor "My Sensor [%.1f °C]" <temp> {sensor="binding..."}
Switch MySensorOnline {expire="30m,OFF"}

.sitemap:

Text item=MySensor valuecolor=[MySensorOnline==OFF="red"]

and a rule:

rule "My Sensor Update"
when
    Item MySensor received update
then
    MySensorOnline.postUpdate(ON)
end

Whenever the item MySensor receives an update, the rule will trigger and set MySensorOnline to ON.
When there is no update for more than 30 minutes, the expire binding will set the item to OFF.

1 Like

Thanks for the info. Got it working

I think there is a typo in the sitemap:

Text item=MySensor valuecolor=[MySensorOnline=OFF="red"]

Should it be

MySensorOnline==OFF="red"

Yes, you’re perfectly right :slight_smile: I’ll change this, just in case…