In DSL I want to loop through all things and get some properties (like all things being OFFLINE)
I know how to do it with items:
import org.openhab.core.model.script.ScriptServiceUtil
var strThing = ScriptServiceUtil.getItemRegistry.getItems()
I tried a few days to find an equivalent command for things like these:
ScriptServiceUtil.getInstance.thingRegistry.get()
or
ScriptServiceUtil.getThingRegistryInstance()
or
ScriptServiceUtil.getThingRegistryInstance.get()
but these do not work.
Could anybody please guide me in the right direction?
Please keep in mind, I do not need a comand to get properties of a specific thing. I need a command which returns ALL things.
yes, forgot to mention this in my original post that I have this in mind as plan b.
And thank you for your reply.
Let’s see if some developers see any way to achieve this.
Maybe I see it too much simplified but I was hoping to do a class import see here and use one of these commands:
I read your other thread. I think switching to java will exceed my little experience in xtend.
However, if there is some help available (example codes) I definitely would like to have a look at that.
Access to things like the Thing Registry and Item Registry is more involved than just importing a class. The Item registry gets injected into the rule when it runs. These need to be populated and linked to the actual data that openHAB is using.
Hey Rich, thanks a lot for making this clear to me. A different or complementary approach I am pursuing is to get an event if the status of things changes.
I know that can be done by rule but the solution Yannick came up with is by for leaner.
May I ask you to have a look at this thread.
That is such wonderful solution but I am stuck.