OH3 semantic config in files question (Sensors)

Hi guys,

Yesterday I upgraded to OH3 and it all worked great, so far no issues and I had do fix actually nothing worth mentioning, great job! :slight_smile:

I now try to get behind the semantic model and how I can configure it in my files as I like the textual config. I might not have found the right documentation to fully understand the semantic model, so I have some questions…


I have some Xiaomi Sensors for Temperature, Humidity and Pressure. Based on this table I have found in the forums (smarthome/SemanticTags.csv at master · eclipse-archived/smarthome · GitHub) I assume the Sensor Thing would be an “Equipment” and the measurements would be “Properties”? Unfortunately this github page does not mention a generic sensor for measurements. Nevertheless another forum post ([wiki] Getting Started with OH3: rewriting the tutorial - 6. Model your home with Items & link Channels) contains a picture with an Equipment type “Sensor”.

Based on my understanding I set the Sensor up like this in my files:

//Livingroom
Group   XHTP03	(W2_Livingroom)	["Sensor"]
Number:Temperature		XHTP03_Temperature	"Temperature"						<temperature>	(XHTP03)	["Temperature", "Measurement"]	{ channel="mihome:sensor_weather_v1:04cf8c8f9bcd:158d00025ee3f0:temperature"	}
Number:Dimensionless	XHTP03_Humidity		"Humidity"							<humidity>		(XHTP03)	["Humidity", "Measurement"]		{ channel="mihome:sensor_weather_v1:04cf8c8f9bcd:158d00025ee3f0:humidity"		}
Number:Pressure			XHTP03_Pressure		"Pressure"							<pressure>		(XHTP03)	["Pressure", "Measurement"]		{ channel="mihome:sensor_weather_v1:04cf8c8f9bcd:158d00025ee3f0:pressure"		}
Number					XHTP03_Battery		"HTP Sensor #3 Battery [%s %%]"		<battery>		(XHTP03)	["Battery", "Measurement"]		{ channel="mihome:sensor_weather_v1:04cf8c8f9bcd:158d00025ee3f0:batteryLevel"	}
Switch					XHTP03_BatteryLow	"HTP Sensor #3 Battery Low [%s]"	<radiobutton>	(XHTP03)	["LowBattery", "Measurement"]	{ channel="mihome:sensor_weather_v1:04cf8c8f9bcd:158d00025ee3f0:lowBattery"		}

Can someone tell me if this is correctly setup based on the semantic model?

So I put all individual items in a group with model type “Sensor”.

I see that “Battery” is an Equipment in the table and not a Measurement, this confuses me.
Also I assume “BatteryLow” should be “Status” based on the Model picture, but how can I define this in the file that it makes sense?

This is how it looks now in the UI:

Also another question:

I can define my living room as e.g. type “Location”, “Room” or “LivingRoom”.
Is there any advantage right now in defining it as a “LivingRoom” instead of the generic types?

Group House			"House"			<location>			["Location"]

Group W2			"Flat Top2"		<flat>		(House)	["Location"]

Group W2_Livingroom	"Livingroom"	<sofa>		(W2)	["LivingRoom"]

Thanks in advance :slight_smile:

1 Like

You have to tag the Items too. For example [measurement, temperature] and [measurement, humidity] and theses items would be members of the Sensor Group and the Sensor Group would be a member of the room Group Item where it resides.

The point type goes first (measurement) and the property type (temperature) goes second.

There is no property type for battery, though I do think there is a batteryAlarm. I tend to use status,power for my battery items.

If you use HABot yes. If not then not yet.

Ok, I already had them tagged like this but now I changed my tags from [“Temperature”, “Measurement”] to [“Measurement”,“Temperature”] and also for Humidity and Pressure. I do not see any change in the UI when I click on the Equipment, but anyway I like it better like this, looks nicer :slight_smile:

In another post I read that the Battery should actually be Sub-Equipment of the Equipment with the Battery. So I tried to add a Battery Equipment Sub-Group to my Sensor Equipment Group like this below.
Unfortunately in the UI the Battery does not get shown under the Sensor but it is visible in “root” :frowning:

//Livingroom
Group   XHTP03			(W2_Livingroom)	["Sensor"]
Number:Temperature		XHTP03_Temperature	"Temperature"						<temperature>	(XHTP03)	["Measurement","Temperature"]		{ channel="mihome:sensor_weather_v1:04cf8c8f9bcd:158d00025ee3f0:temperature"		}
Number:Dimensionless	XHTP03_Humidity		"Humidity"							<humidity>		(XHTP03)	["Measurement","Humidity"]			{ channel="mihome:sensor_weather_v1:04cf8c8f9bcd:158d00025ee3f0:humidity"			}
Number:Pressure			XHTP03_Pressure		"Pressure"							<pressure>		(XHTP03)	["Measurement","Pressure"]			{ channel="mihome:sensor_weather_v1:04cf8c8f9bcd:158d00025ee3f0:pressure"			}
Group   XHTP03_Battery	(XHTP03)		["Battery"]
Number					XHTP03_Battery		"HTP Sensor #3 Battery [%s %%]"		<battery>		(XHTP03_Battery)	["Measurement", "Energy"]		{ channel="mihome:sensor_weather_v1:04cf8c8f9bcd:158d00025ee3f0:batteryLevel"	}
Switch					XHTP03_BatteryLow	"HTP Sensor #3 Battery Low [%s]"	<radiobutton>	(XHTP03_Battery)	["LowBattery", "Energy"]		{ channel="mihome:sensor_weather_v1:04cf8c8f9bcd:158d00025ee3f0:lowBattery"		}

I can’t find “batteryAlarm” but I think you meant the point status tag “LowBattery”. So I use [“LowBattery”, “Energy”] as I assumed:
Power -> Watt
Voltage -> Volt
Current -> Ampere
Energy -> Generic
For the % of the battery I use [“Battery”, “Measurement”] as I assume the % of the battery is a measurement.

For me it seems there is no right or wrong, at least for now, but all up to interpretation?
Will the Things in future create their own model definition or maybe bring a template? It’s quite a lot of work to set this up for every Thing you have if you have lots of devices.

The sensor battery should be viewed as an equipment ( see Yannic’s explanation on this topic ).

1 Like

I think this is the post where I found it yes. But in the UI it is not showing as a Sub-Equipment but in root?
I see no error in my config

There is no right it wrong in the model beyond using tags that don’t exist or trying to put the same item in miss more than one semantically tagged Group. So there is no should. You need to do what makes the must sense to you.

Anyway, at this point all I can tell you is that it can work. Beyond that it’s starting to look like .things files, trying to get it right it’s going to be a huge time sink. I’ve all my Items defined in the UI so can’t provide much more on. items files beyond the fact that others have made it work so it can work.

You can’t mix and match points and properties. I don’t think there is a Battery Point type nor is there a measurement property. The “rules” are:

  • Locations are a Group with a single Location tag and only a single Location tag.

  • Equipment are a Group or an Item with a single Equipment tag.

  • Points are an Item with a single Point tag and an optional Property tag.

You can’t have two property tags. You can’t use a property tag with a location or an equipment tag. You can’t have just a property tag.

If you look at the medel page of the Getting started tutorial you will see which tags are which.

I think that was mentioned at some point but it won’t apply to .items files if it does get implemented. As has always been the case, what’s in files overrides what gets autodiscovered or done through the UI.

Text configs are still very much supported, but as has always been the case, when you use text configs you have to do it all.

Sorry my bad, I actually meant [“Measurement”, “Energy”], not sure why I wrote this…

How does this tie up with the example here from Yannick, where he gives:

Number Temperature_GF_Corridor "Corridor [%.1f °C]"    ["Temperature", "Measurement"]

i.e. this example is ["property", "point"]. However, two lines underneath:

Dimmer Temperature_Setpoint    "Temperature [%.1f °C]" ["Setpoint", "Temperature"]

i.e. this example is ["point", "property"]. So does the order even matter?

(Ignoring the fact that Battery is neither a property, nor a point, of course.)

At least in my case I could not observe any difference after I changed my order. It looked the same in the Model UI

1 Like

I guess not. I thought I had tried it out of order at one point and it didn’t work. I didn’t look at Yannick’s examples that closely.

Hi, I tagged also the last days my text item files for the semantic model and found out, that the structure sometimes go to root, when the tagged group was not present, when the item file was saved.
I have my groups in a separat item file, so I had to save first the group item file, and then the tagged item file.
Also, a restart of the openHAB service reordered the semantic model.

How about Battery (as an item / Point) within an equipment (e.g. Motion Sensor like this:

Group                      gCorridorMotion      "Motion Sensor"                                      (gCorridor)                                 ["Sensor"]
Switch                     Z_Motion_Alarm       "Bewegung"                                           (G_jdbc,gCorridorMotion)                    ["Alarm"]
Number                     Z_Motion_Batt        "Motion Batterie [%d %%]"                            (G_Num,gCorridorMotion)                   ["Level"]

If it works for you then that’s fine. There is no “right” way to do this. It has to be what makes sense to you. If that’s what makes sense for you then it’s the right way for you, and that’s all that really matters.

Is it possible that it must be a Dimmer to be controllable?
I have a Number item instead and can just see the graph when looking into the location where the heating is located (Living Room)

No, I don’t think so. This was just an example I pulled from the linked thread. As you are, I am also using a Number Item for my heating setpoints.