Make rule with 196 if-statements more generic

    val inStr = Tex_UDB_Incoming.state.toString
    if(inStr.startsWith("Z")) {
        val itemName = "Tex_GV_"+inStr.substring(0, 3)
        postUpdate(itemName, inStr.substring(4))
    }

See

Since your names are all standardized I don’t see a need for REGEX if you stick to rules.

However, I’m not sure about how the TCP/UDP binding works, but if you can define more than one Item on the same socket you can drop the Tex_UDP_Incoming and the rule entirely and define each Item along the lines of:

Number Tex_GV_Z036 { udp="<[192.168.3.10:*:'REGEX(Z036[\d])']" }
Number Tex_GV_Z035 { udp="<[192.168.3.10:*:REGEX(Z035[\d])]" }

Note I’m not certain about that REGEX. It may need parens instead of brackets. The [\d] is supposed to match the last digit and becomes what the Item’s state gets set to. The first part will only match those packets that start with that String.

Rich

1 Like