I want to compare a value/variable inside a rule to many numbers. If the value is the same like one of the numbers, then the rule should do something. Is this possible with only a variable - without a number-item?
With items i know the command “if xxx = member of group-name”, but with variables i don´t have any groups…
I have a rfid-reader and many rfid-chips. Now i want to do something inside a rule, when a known rfid-chip is recognized. How would you solve this?
Should i put all known rfid-numbers into number-items?
I already do this like rlkoshaks design pattern method #3
This works great, here is my whole rule:
rule "RFID Haustuer triggered"
when
Item RFID_uid_haustuer received command
then
val itemName = "RFID_"+receivedCommand
//val itemLabel = itemName.label // This is the problem in this rule...
val authorized = gRFID_Authorized.members.findFirst[ id | id.name == itemName ]
val unauthorized = gRFID_Unauthorized.members.findFirst[ id | id.name == itemName ]
// Purposefully putting unauthorized first so if an ID is in both Groups the unauthorized Group takes precedence
if(unauthorized != null) {
// alert attempted unauthorized access
logInfo("RFID", "RFID Haustür UNAUTHORIZED ---> RFID_ID --> " + receivedCommand + " : ")
}
else if(authorized != null) {
// unlock the door
logInfo("RFID", "RFID Haustür AUTHORIZED ---> RFID_ID --> " + receivedCommand + " : " + itemName.label)
if (Kontakt_EG_Haustuer.state == CLOSED) {
Haustuer_Dummy.sendCommand(1)
}
}
else {
// alert attempted unkown access
// do some stuff
}
end
I want to display the label of the item in my logInfo --> So that i can see the real name of my rfid-chip and not only the item-name.