Rule only running once

Hi all,

I have a rule that works fine the first time it is triggered, but after that it will not trigger again, am I missing something basic here?

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import org.joda.time.*
import java.util.*
import java.util.concurrent.locks.*

rule "Update Tabs"
when Item Hall_Lights changed
		 val StringBuilder json = new StringBuilder()
		var lightarray = Hall_Lights.members
		lightarray.forEach [item |
						json.append('{"name":"' + + '","state":"' + item.state.toString() + '"},')	
		var String fJson = json.toString()
		fJson = fJson.substring(0, fJson.length() - 1)
		fJson = fJson + ']}'
	catch(Exception e)
				logInfo("error", e.toString())

First, are there errors in the log?

Second, add some logging statement so you can see whether it truly isn’t triggering or just not completing.

Third, what is Hall_Lights? If it is a Group realize that a Group’s state is the aggregate of its member’s state. So, for example if all the members are OFF and one turns ON then the Group’s state will change to ON. BUT,if a second light turns ON the Group’s state will remain unchanged and your rule will not trigger.

If you want the rule to trigger for all changes to the members you will need to use “received update”. But realize the problem there is that now the rule will trigger multiple times for each single change to one of its members.

Thank you for the info.

It is indeed a group, I guess the simplest way to get this right is to have an individual rule for each item. I only have 4 lights at the moment so this is doable.

It depends.

Probably the simplest thing to do would be to have the rule triggered by each of the lights:

    Item Light1 changed or
    Item Light2 changed or
    Item Light3 changed or
    Item Light4 changed

That would be excellent :slight_smile: I shall implement that and see how it goes.

I have it for one light and it works great as is, thanks again for your time and help.