Today I noticed that my motion sensors weren’t triggering the rules when the state changed. In short - I think there is some issue parsing .items files - maybe it times out on startup.
To investigate, I did a GET from the REST API on the item which should have (but failed) triggered the automated lighting.
{
"members": [],
"link": "http://192.168.0.44:8080/rest/items/GF_Hallway_Motion",
"state": "OFF",
"stateDescription": {
"pattern": "%s",
"readOnly": false,
"options": []
},
"editable": false,
"type": "Group",
"name": "GF_Hallway_Motion",
"label": "Hallway motion",
"tags": [],
"groupNames": [
"GF_Hallway",
"gMotion"
]
}
This item is a group that actually aggregates two motion sensors (one upstairs and one downstairs) but as it stands, it tells me there are no members in this group.
Group:Switch:OR(ON,OFF) GF_Hallway_Motion "Hallway motion [%s]" (GF_Hallway, gMotion)
Switch GF_Hallway_Downstairs_Motion "Hallway (downstairs) motion [%s]" (GF_Hallway, GF_Hallway_Motion) {channel="mqtt:topic:mymqttbroker:hallway_motion_sensor_1:motion"}
Switch GF_Hallway_Upstairs_Motion "Hallway (upstairs) motion [%s]" (GF_Hallway, GF_Hallway_Motion) {channel="mqtt:topic:mymqttbroker:hallway_motion_sensor_2:motion"}
So I ran the following command:
touch /etc/openhab2/items/*.items
I then followed this by doing another GET on the same item:
{
"members": [
{
"link": "http://192.168.0.44:8080/rest/items/GF_Hallway_Downstairs_Motion",
"state": "OFF",
"stateDescription": {
"pattern": "%s",
"readOnly": true,
"options": []
},
"type": "Switch",
"name": "GF_Hallway_Downstairs_Motion",
"label": "Hallway (downstairs) motion",
"tags": [],
"groupNames": [
"GF_Hallway",
"GF_Hallway_Motion"
]
},
{
"link": "http://192.168.0.44:8080/rest/items/GF_Hallway_Upstairs_Motion",
"state": "OFF",
"stateDescription": {
"pattern": "%s",
"readOnly": true,
"options": []
},
"type": "Switch",
"name": "GF_Hallway_Upstairs_Motion",
"label": "Hallway (upstairs) motion",
"tags": [],
"groupNames": [
"GF_Hallway",
"GF_Hallway_Motion"
]
}
],
"groupType": "Switch",
"function": {
"name": "OR",
"params": [
"ON",
"OFF"
]
},
"link": "http://192.168.0.44:8080/rest/items/GF_Hallway_Motion",
"state": "OFF",
"stateDescription": {
"pattern": "%s",
"readOnly": false,
"options": []
},
"editable": false,
"type": "Group",
"name": "GF_Hallway_Motion",
"label": "Hallway motion",
"tags": [],
"groupNames": [
"GF_Hallway",
"gMotion"
]
}
So it’s clear to see that although OH initially parsed my item files and created the group, it did not correctly parse all items in all files and complete the processing i.e. adding them to the group.