He’s using a Contact type because it works here. His Items do not represent a controllable light switch on their own. It’s part of a pulsed relay system via GPIO ; for each light, there is a Switch Item simulating a pushbutton, and a Contact Item showing the status of the light circuit. You can’t send commands to the “status” Item, you can’t use the “pulse” Item state to indicate light state, you have to use them as an interlinked pair.
It’s not really related to the rules in question - whether he’s looking for ON or CLOSED makes no fifference there.
@julesx81 is stuck with Contact type to represent light on/off I believe - because the GPIO v1.x binding he has in use limits incoming binary channels to Contact types.
2019-12-18 12:14:42.603 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'all pulse off': The name 'nameOfLight' cannot be resolved to an item or type; line 53, column 21, length 14
i don’t understand the differences between sendcommand functions… First need two string as parameters , instead the second one item object as first , and second param? What? Not a string?
rule "all pulse off"
when
Item all_lights_off received command ON
then
logInfo("pulseAll","Rule started.")
gLight.members.filter[a|a.state==OPEN].forEach[s|
logInfo("pulseAll","Processing Item {} ({})",s.name,s.state)
var nameOfLight = s.name.split("_")
var nameofPulse = nameOfLight.get(0).toString + "_" + nameOfLight.get(1).toString + "_Pulse"
sendCommand(nameofPulse, "OFF")
Thread::sleep(300)
]
logInfo("pulseAll","Rule ends.")
sendCommand(all_lights_off, OFF)
end
someItem.sendCommand(OFF)
is a method of your Item. That’s to say, it’s part of the Item object and expects a real command suitable for itself. e.g. mySwitch.sendCommand(UP) is going to fail because UP isn’t suitable for a Switch type Item.
sendCommand("myItemname", "somevalue")
is an action in rules language. It’s deliberately written to be as generalized as possible. It has no idea what kind of Item is involved until it looks it up by name, it may not even exist. So it has no idea what kind of commands might be allowed.
It does try its best to deal with whatever you might give it instead of two strings, though it doesn’t always pick the right one because it is guessing then.
Don’t make it guess, give it two strings like it says in the documentation…
There is nothing called gLights in what you have shown us.
Filter for what purpose? Using what criteria? In a rule, for display, leave out any members with FRED in their names, turn on only members updated in the last week?