Hi.
I have three garden door and for this i would like use RFID Coins to allow the access. the fully sketch are attached. The hardware construction works seperate, but i have a problem with the rule. I think it is easy for a programmer.
If u hold the coin on the RFID Reader, the PI change the VI_Sec_AC_Read_String (example: 124345678901,Max,1) → (UID, UserTag, DoorID)
The rule check if a VI_Sec_AC_UserN with the same UID and UserTag in the Group Grp_Sec_AC_User and it VI_Sec_AC_UserN String contains the requesting DoorID.
The Problem in the rule is how i define the variable DoorID so that i can used it.
Error from Log:
1. The method or field Door1 is undefined; line 37, column 1765, length 5
2. The method or field Door2 is undefined; line 37, column 1786, length 5
3. The method or field Door3 is undefined; line 37, column 1807, length 5
Perhaps you still have fundamental suggestions for improvement.
-
Platform information:
- Hardware: Synology 916+
- openHAB version: OH 3.1.0 (Docker)
-
Items:
- Grp_Sec_AC_User (Type: Group)
- VI_Sec_AC_User1 (Type: String) (MemberOf: Grp_Sec_AC_User )
- VI_Sec_AC_UserN (Type: String) (MemberOf: Grp_Sec_AC_User )
- VI_Sec_AC_Read_String (Type: String)
-
Rule:
/* User String: 0=(UserID), 1=(UserName),2-4=(DoorID) */
val telegramActionSec = getActions("telegram","telegram:telegramBot:TelegramBotSec")
// ##################################################################
val UserID = VI_Sec_AC_Read_String.state.toString.split(",").get(0)
val UserName = VI_Sec_AC_Read_String.state.toString.split(",").get(1)
val DoorID = VI_Sec_AC_Read_String.state.toString.split(",").get(2)
// ##################################################################
switch (DoorID) {
// ##### Garden Door (Main) #####
case "1": {
Grp_Sec_AC_User.members.filter[state.toString.contains(UserID) && state.toString.contains(UserName)].forEach[User|
var CountUserString = User.state.toString.split(",").length
logInfo("System","COUNT: " + CountUserString)
if (CountUserString == 3) {
val Door1 = User.state.toString.split(",").get(2)
val Door2 = "0"
val Door3 = "0"
logInfo("System","Case 1.3")
}
if (CountUserString == 4){
val Door1 = User.state.toString.split(",").get(2)
val Door2 = User.state.toString.split(",").get(3)
val Door3 = "0"
logInfo("System","Case 1.4")
}
if (CountUserString == 5){
val Door1 = User.state.toString.split(",").get(2)
val Door2 = User.state.toString.split(",").get(3)
val Door3 = User.state.toString.split(",").get(4)
logInfo("System","Case 1.5 - " + Door1)
}
if ((DoorID == Door1) || (DoorID == Door2) || (DoorID == Door3)) {
logInfo("System","Sicherheit - Information: Garten Haupteingang wird geöffnet durch User: " + User.state.toString.split(",").get(1))
} else {
logInfo("System","Sicherheit - Warnung: ACCESS DENIED - Hof Tür - UID: " + User.state.toString.split(",").get(0) + " - UserName: " + User.state.toString.split(",").get(1))
}
]
}
// ##### Garage Door #####
case "2": {
Grp_Sec_AC_User.members.filter[state.toString.contains(UserID) && state.toString.contains(UserName) && (state.toString.split(",").get(2)==DoorID || state.toString.split(",").get(3)==DoorID)].forEach[User|
logInfo("System","Sicherheit - Information: Garagen Tür wird geöffnet durch User: " + User.state.toString.split(",").get(1))
]
}
// ##### Garden Door (Side) #####
case "3": {
Grp_Sec_AC_User.members.filter[state.toString.contains(UserID) && state.toString.contains(UserName) && (state.toString.split(",").get(2)==DoorID || state.toString.split(",").get(3)==DoorID)].forEach[User|
logInfo("System","Sicherheit - Information: Garten Nebeneingang wird geöffnet durch User: " + User.state.toString.split(",").get(1))
]
}
// ##### Default (wrong DoorID) #####
default: {
logInfo("System","Sicherheit - Warnung: wrong Door ID - ACCESS DENIED - UID: " + UserID + " - UserName: " + UserName + " - DoorID: " + DoorID)
}
}
- Sketch of full construction