Is there any way to get a list of item UID's?

I have a rule which I want to run where it updates the sitemap light switches if a member of the gLights group goes OFFLINE (or ONLINE). In other words, if I switch the light off at the wall rather than through a software method.

The syntax for getting the status of each light is pretty straight forward:

 var status = ThingAction.getThingStatusInfo("uid").getStatus()

And I guess I could create 17 different rules to update each light independently, but it felt like there must be an easier way for when/if a light gets replaced/removed/added or the thing uid changes for any reason.

For now, this is what i’ve come up with, but I believe it’s using the item name rather than the item UID in the status var which returns an error:

[ERROR] [.script.engine.ScriptExecutionThread] - Rule 'Light Offline Switch Update': Could not invoke method: org.eclipse.smarthome.model.script.actions.ThingAction.getThingStatusInfo(java.lang.String) on instance: null
rule "Light Offline Switch Update"
when
	Item gLights received update
then
	logInfo("Light Status", "Updating Light switch states")
	gLights?.members.forEach[light|
		var status = ThingAction.getThingStatusInfo(light).getStatus()
		logInfo("Light UID Changed:",light.name + "UID:" + uid.toString())
		if(status.toString() == "OFFLINE"){
			light.sendCommand(OFF)
			logInfo("Light Status",light.name + "Switch state updated" + status.toString())
		}
		else {
			light.sendCommand(ON)
			logInfo("Light Status",light.name + "Switch state updated" + status.toString())
		}
	]
end

Would one option be to run a bash/php script which extracts the gLights item uid’s from the REST api as an array/list and then does the status check before the rules engine even sees it? I’m not savvy enough with this approach to know where to begin.

Anyone got any bright ideas?

You could probably do it from a rule using the getHttp actions. That will help you to avoid messing with an external script.

I don’t know anything about these UIDs so can’t really help much with the specifics

if the actions won’t work you will want to use the curl command to issue the http API requests.