Hi Rich,
It is incredible how much you have helped me with sound advice. If it is not by directly answering my questions, it is by all your other posts (I’ve read already hours on this forum).
I have changed my code and it seems to work!
My new items:
Number Tex_Zone_Z035_40_1 "Z35 - Raam bureau zijkant open/dicht [MAP(tex_contacts.map):%s]" <window> (gGV_Bureau, gRaamcontact, gAlarmcontact)
Number Tex_Zone_Z036_40_2 "Z36 - Raam bureau zijkant kipstand [MAP(tex_contacts.map):%s]" <window> (gGV_Bureau, gRaamcontact)
My new rule (or part of it):
// To translate UDP zone-updates (Z) to our individual zone-items.
if(in_UDPmsg.startsWith("\"Z0")) {
// val itemName = "Tex_Zone_"+in_UDPmsg.substring(1, 5)
val itemName = gAllecontacten.allMembers.filter[sw|sw.name.contains(in_UDPmsg.substring(1, 5))].head
logInfo("Alarm","itemName =" + itemName)
postUpdate(itemName, in_UDPmsg.substring(5))
}
The only thing I don’t understand is what I see in openhab.log. I would have expected one entry (since I have one “loginfo” statement). But I actually get this:
2017-05-25 11:42:10.831 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=0, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.839 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.847 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.850 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.858 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.861 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.861 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.863 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.864 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.874 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.876 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.879 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.883 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.886 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.887 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.890 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.893 [ERROR] [.script.engine.ScriptExecutionThread] - Rule 'Alarm interface via UDP': null
2017-05-25 11:42:10.900 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.901 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.901 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.902 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.908 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.915 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.916 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.917 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
2017-05-25 11:42:10.923 [INFO ] [eclipse.smarthome.model.script.Alarm] - itemName =Tex_Zone_Z035_40_1 (Type=NumberItem, State=1, Label=Z35 - Raam bureau zijkant open/dicht, Category=window, Groups=[gGV_Bureau, gRaamcontact, gAlarmcontact])
- The first line seems to contain the old value of the item (State=0) all lines after that contain the new value (State=1);
- I also see a ScriptExecutionThread - Rule ‘Alarm interface via UDP’: null
Besides that, everything seems to be functional.
Related to your advice on naming convention: you are absolutely right. For all other items, I have a very clear naming convention, split by ‘_’ and understandable by humans. However, since I didn’t have the “contains” trick you just explained to my, I assumed that the names of these new items should follow a more rigid structure. I can now adjust the names to be back in line with my naming convention.