Semantic Model
Hi, I am a new openHAB user. I am learning quickly thanks to the excellent documentation and community. I am currently seeing unexpected behavior in the Semantic Model tree, so I would like to know if I am doing something wrong.
In summary, I expected that the position of the Items on the Semantic Model page would depend only
on the definition of that Items and not on how they are distributed in the .items files, or if they
are modified while the system is running.
I will show two cases. The first one shows the same definition of the Items but in one case they are
all in the same files and in another case they are distributed into two files. Then, I will show that
two equal configurations give different results, and those results depend on the previous Items
definition.
openHAB Docker version: openhab/openhab:3.2.0.M3-debian
1) Location of the Items in the files
1.1) All Items in a single file
test.items
Group gHouse "House" <house> ["SummerHouse"] {widgetOrder="0"}
Group gLiving "Living" <sofa> (gHouse) ["LivingRoom"]
Switch Boiler "Boiler" <heating> (gHouse) ["RadiatorControl"]
Switch Living_Radiator "Radiator" <radiator> (gLiving) ["RadiatorControl"]
I start openHAB and create the admin account.
The image shows that it works as expected:
- Radiator is in Living
- Boiler is in House
1.2) Items in separate files
The same definition as before, but now in two files.
groups.items
Group gHouse "House" <house> ["SummerHouse"] {widgetOrder="0"}
Group gLiving "Living" <sofa> (gHouse) ["LivingRoom"]
heating.items
Switch Boiler "Boiler" <heating> (gHouse) ["RadiatorControl"]
Switch Living_Radiator "Radiator" <radiator> (gLiving) ["RadiatorControl"]
I start openHAB and create the admin account.
The image shows that the result is not the same as before:
- Radiator is in the root
- Boiler is in the root
Summary: The same definition of the Items produces different results.
2) Items modified while the system is running
2.1) Modifying some Items while openHAB is running
Lets start with the same config than the last test.
groups.items
Group gHouse "House" <house> ["SummerHouse"] {widgetOrder="0"}
Group gLiving "Living" <sofa> (gHouse) ["LivingRoom"]
heating.items
Switch Boiler "Boiler" <heating> (gHouse) ["RadiatorControl"]
Switch Living_Radiator "Radiator" <radiator> (gLiving) ["RadiatorControl"]
I start openHAB and create the admin account.
Of course, we have the same unexpected results:
- Radiator is in the root
- Boiler is in the root
Then, I add “Equipment” in the Boiler and Radiator Items while openHAB is running:
heating.items
Switch Boiler "Boiler" <heating> (gHouse) ["RadiatorControl","Equipment"]
Switch Living_Radiator "Radiator" <radiator> (gLiving) ["RadiatorControl","Equipment"]
The Semantic Model is updated and now we see that:
- Radiator is in Living
- Boiler is in House
It seems that adding “Equipment” solves the problem, so in the next test I will add “Equipment” from
the beginning.
2.2)
Now I try to reproduce the same result as in the last test but having the Items already configured
for the openHAB first start instead of modifying the files while openHAB is running.
groups.items
Group gHouse "House" <house> ["SummerHouse"] {widgetOrder="0"}
Group gLiving "Living" <sofa> (gHouse) ["LivingRoom"]
heating.items
Switch Boiler "Boiler" <heating> (gHouse) ["RadiatorControl","Equipment"]
Switch Living_Radiator "Radiator" <radiator> (gLiving) ["RadiatorControl","Equipment"]
I start openHAB and create the admin account.
The same configuration files as in test 1.2), but now with a different result.
The image shows that:
- Radiator is in the root
- Boiler is in the root
Summary: The same file contents produce different results. That results depends on when the Items were configured (before o after openHAB first start).
The playbook
This is the Ansible playbook used to run the tests:
- name: Ensure containers are running
hosts: infra
vars:
openhab_image: openhab/openhab:3.2.0.M3-debian
tasks:
# - name: Copy openHAB test items file
# tags: openhab
# ansible.builtin.copy:
# src: files/test.items
# dest: /opt/openhab/conf/items/test.items
# force: no
- name: Copy openHAB groups items file
tags: openhab
ansible.builtin.copy:
src: files/groups.items
dest: /opt/openhab/conf/items/groups.items
force: no
- name: Copy openHAB heating items file
tags: openhab
ansible.builtin.copy:
src: files/heating.items
dest: /opt/openhab/conf/items/heating.items
force: no
- name: Ensure openhab is up
tags: openhab
docker_container:
name: openhab
image: "{{ openhab_image }}"
state: started
detach: yes
interactive: yes
tty: yes
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- /opt/openhab/conf:/openhab/conf:Z
- /opt/openhab/userdata:/openhab/userdata:Z
- /opt/openhab/addons:/openhab/addons:Z
- /opt/openhab/.java:/openhab/.java:Z
network_mode: host
restart_policy: unless-stopped