Getting all OFFLINE devices

Thanks but for example the Hue Binding thing goes Offline if the connection is lost to the Hue Bridge.
The color item does still have the same old states.

So this is why I am want to get the thing status for example.

I relooked at my approach to this and I decided I don’t need a notification for every thing because Spotify things go offline all the time when you are not using them. So I going to trigger a rule for every thing I want to monitor.

I guess the hue binding doesn’t use the standard approach. You will have to create a rule to trigger on the Thing going offline. There is no way to group things (they are not items after all) so you need to trigger the rule with each Thing you care about. There will be a receivedEvent variable I think you can use to figure out which thing went offline.

To put it on your sitemap you’ll have to create an Item and set it’s state from the rules.

1 Like

I having some issues getting this to work :slight_smile:

I think you can only use a receivedEvent on a channel and not on a thing

Ok here is what I have.

import org.eclipse.smarthome.model.script.ScriptServiceUtil
val telegramAction = getActions("telegram","telegram:telegramBot:Telegram_Bot")

rule "Thing Detected off line list question"
    Thing 'wled:wled:Anabel_NL' changed from ONLINE to OFFLINE or
    Item PING_Device changed to OFF
    telegramAction.sendTelegramQuery("One of your things went OFFLINE in openHAB.\nItem " + triggeringItem + "\n\nDo you want a list of OFFLINE Things?", "Offline_List", "Yes", "No")

rule "Get status of thing and if OFFLINE send message to telegram"
    Item telegramReplyId received update Offline_List
    val StringBuilder   Message = new StringBuilder
    val things = ScriptServiceUtil.getInstance.thingRegistry.getAll()

   if (telegramMessage.state.toString == "Yes")
    Message.append( " Your OFFLINE things are;   " + "\n" + "\n" )    
    things.forEach[ thing |
        val statusInfo = thing.getStatusInfo()
        if (statusInfo.getStatus().toString() != 'ONLINE') {
            Message.append( "Thing: " + thing.getLabel() + "\n" )
            Message.append( "state: " + statusInfo.getStatus() + "\n" )
            Message.append( "detail: " + statusInfo.getStatusDetail() + "\n" )
            Message.append( "description: " + statusInfo.getDescription() + "\n" + "\n" )
    telegramAction.sendTelegramAnswer(telegramReplyId.state.toString, Message.toString) 
    } else {
    telegramAction.sendTelegramAnswer(telegramReplyId.state.toString, "Ok")


The result in telegram please forgive typo

Item null is because it was triggered by thing if item triggers it shows up.

Select Yes it checks when you select yes so it is a live list not from when it went offline.

Sample of response message

Its still a work in progress

…i should be more up to reading improved functionality on “old” bindings! :wink:

1 Like

I had the same problem, and I noticed that the rule “changed from ONLINE to OFFLINE” did not work reliably. So I created the following script, to be executed regularly. It gets the online/offline data directly from the bridge and sets +"_Online" to the values “ONLINE” or “OFFLINE”.

Replace <huepw> with your apikey for the Hue Bridge.

HueSetup includes all lamps with the number (according to Bridge), name, type and item prefix.

var ThingUID = Java.type("org.eclipse.smarthome.core.thing.ThingUID");

logDebug("HueWorker.js: being loaded");

var HueSetup = [
	[1, "k3", 220, "hueKeller3"]
    // insert here other lamp descriptions

var getHueFromNo=function(id) {
	for (var i = 0; i < HueSetup.length; i++) {
		if(HueSetup[i][0]==id) return HueSetup[i];
	return -1;

var getHueReachable=function() {
	logTrace("HueWorker.js: Getting Hue data");
	var requestURL = 'http://philips-hue.local/api/<huepw>/lights';
	var HttpUtilNativ = Java.type("");
	var results = HttpUtilNativ.executeUrl("GET", requestURL, 5000);
	var inJson = JSON.parse(results);
	logTrace("HueWorker.js: JSON received from bridge: "+inJson);
	var outJson=""
	for (x in inJson) {
		var hue=getHueFromNo(x);
		if(hue[0]!=2) {
			var itState=getItem(hue[3]+"_Toggle").state;
			var onlineState=getItem(hue[3]+"_Online").state;
			var thState=things.get(new ThingUID("hue:0"+hue[2]+":1:"+hue[1])).status;
			var jsOnOff=inJson[x]['state']['on'].toString();
			var jsOnline=inJson[x]['state']['reachable'].toString();
			var thingMatch;
			if(jsOnOff=="true") jsOnOff="ON";
			else if(jsOnOff=="false") jsOnOff="OFF";
			else jsOnOff="UNDEFINED";
			if(jsOnline=="true") jsOnline="ONLINE";
			else if(jsOnline=="false") jsOnline="OFFLINE";
			else jsOnline="UNDEFINED";
			// We test if the online/offline status is the same for the thing and the JSON string
			if (thState==jsOnline) thingMatch="match    ";
			else {
				if(onlineState==jsOnline) thingMatch="mism(cor)"
				else {
					thingMatch="mismatch ";
					events.postUpdate(hue[3]+"_Online", jsOnline);
					logInfo("HueWorker.js: Thing status (ONLINE/OFFLINE) mismatch for item "+hue[3]+". jsOnline="+jsOnline+" with _Online="+getItem(hue[3]+"_Online").state+". Corrected.");
			if(onlineState!=jsOnline) events.postUpdate(hue[3]+"_Online", jsOnline);
			var itemMatch;
			// We test for different light state, e.g. if the item shows on and the JSON-string shows off
			if (itState==jsOnOff)
				itemMatch="match   ";
			else {
				if(jsOnline=="ONLINE") {
				events.postUpdate(hue[3]+"_Toggle", jsOnOff);
				logInfo("HueWorker.js: Item state (ON/OFF) mismatch for item "+hue[3]+". jsOnOff="+jsOnOff+". Corrected.");
				else itemMatch="mism(th)";
			if(itState!=jsOnOff) events.postUpdate(hue[3]+"_Toggle", jsOnOff);
			logDebug("HueWorker.js: "+String(" "+x).slice(-2)+":"+String(hue[3]+"               ").slice(0,18)+
				", testing "+"hue:0"+hue[2]+":1:"+String(hue[1]+"   ").slice(0,5)+
				": ITEM-STATUS:"+String(itState+"  ").slice(0,4)+
				"; THING-STATUS: "+String(thState+" ").slice(0,7)+
				"; JSON: on="+String(jsOnOff+" ").slice(0,3)+
				", reachable="+String(jsOnline+" ").slice(0,7)+
				"; Thing: "+thingMatch+
				", Item: "+itemMatch+
			outJson+="| ";
		outJson+=" ";
	// outJson shows all Json on/off and on-/offline in one line
	logTrace("HueWorker.js: "+outJson);

	name: "Hue Synchronization",
	description: "This rules is a simple example for getting started with JSR223 Javascript",
	triggers: [
		TimerTrigger("0/15 * * * * ?")//Enable/Disable Rule
	execute: function( module, input){

logDebug("HueWorker.js: finished loading");
1 Like

Great, thanks will try this.

Good question!

Each Tasmota and Zigbee (via zigbee2mqtt) has “Reachability” status. With Tasmota it’s the LWT topic, and for zigbee2mqtt it’s the “availability” topic.

I have assigned an item for each thing into gAvailability group, so in my sitemap I can just add

Group item=gAvailability label="Availability Status"

and when I click that, I get all the status.

1 Like

You can still use the thing online offline status with MQTT you just have to set it up.
things file

    Thing topic Kettle "Kettle in Kitchen" @ "Kitchen" [ availabilityTopic ="tele/kettle/LWT", payloadAvailable ="Online", payloadNotAvailable ="Offline"] {

@denominator thanks! I learned something new.

How do we get the list of ALL things, so that my script can loop through and check their online / offline status?

Hey guys,
hey @denominator

I am curious if some of you havethis rule already running?
I found this after some hours of googling but unfortunately this seems to be depreciated.

Maybe some of you made some updates and have it still running and maybe share some snipplets.

thanks in advance

See Thing Status Reporting [3.2.0;3.4.0)

hey @wu3mi

What is it that you are trying to achieve?

I appreciate that you have searched for your answer before asking a question.

The link above is to working code that you can use however I would use @rlkoshak method.

Please let old threads die. Start a new one and you can post links to old threads so people can use them as research to what you are trying to achieve.

If you want good answers please ask a question that will make us understand what it is you are trying to do.

I not saying you haven’t researched it or not to ask the question. Ask the long question like.

I am trying to get a list of all my offline things that will send at the end of each day on telegram? Then provide as much information as you can about everything relevant so you can get a good answer so the answer may include something helpful.

Don’t be afraid of opening a new thread if you are going to ask a question that is three paragraphs or longer.

1 Like

see here
In contrary to Rich’s approach this rule gets triggered if any of your things go offline.


many thanks to all of you. Solved my issues with the inputs from Rich.


1 Like

Hi, looks like your script doesn’t work in OH 3. The method ScriptServiceUtil.getInstance.thingRegistry doesn’t seem exist anymore. Do you find a workaround? Thanks

Check for offline things 15 minutes after openHAB had started

Thank you will give a try