HABot Walkthrough (2/n): Semantic Tagging & Item Resolving

You can download and run the work in progress. There are dozens of issues open and being worked. The new UI has been posted about on openHAB’s twitter feed. There is a thread to start working on a getting started guide with lots of screen shots.

There is a lot of “official” information out about openHAB 3. For this threads particular case there is even an entire page dedicated to creating the model: [wiki] Getting Started with OH3: rewriting the tutorial - 6. Model your home with Items & link Channels

I have very clearly been looking in the wrong places! I’ve been looking in the “announcements” and “development” categories, and there’s not much there.

Hi Everyone

I have just been reading through trying to get my item attributes sorted for HABot but I must be missing something here.
I am going through my /var/lib/openhab2/jsondb/org.eclipse.smarthome.core.items.Item.json.
Where should these Semantic tags be deployed, am I barking up the wrong tree?
Here is a current item I have in my above json should I be inserting here, and if so where?

  },
  "HallBulbsSwitch": {
    "class": >"org.eclipse.smarthome.core.items.ManagedItemProvider$PersistedItem",

    "value": {
      "groupNames": [],
      "itemType": "Switch",
      "tags": [
        "Lighting"
      ],
      "label": "Hall Bulbs",
      "category": "Lightbulb"
    }

Thanks in advance and I’m sure I’ve missed some core info.

They are right there :slight_smile:

But do not edit the JSON file by hand, use the item API instead.

Hi Dan
Thanks for the the response.
OK, so, yes thats what i thought “they are right there” but when I stopped the hab edited the file (by hand which I have done before to bring things into google) and restarted, the “tags” were not in the HABot > Item attributes review window. Which API are you referring to, paper?
Thanks!

Yes, those files are not meant to be edited by hand.

See https://www.openhab.org/docs/configuration/restdocs.html

We also have an awesome swagger generated UI for accessing the API using your browser, make sure the rest docs are installed:

then go to http://your-openhab/doc/index.html and you can play with all the API’s there, specifically to add a tag, you can use this:

WOW, OK Dan, thank you for that pointer mate, great stuff. I am pretty new to all this so really appreciate the help. I shall give this a play.

Hi Dan, as for editing via the swagger generated GUI my eyes are now open so thank you for that!

HOWEVER,
Now that my newly added item tags have been made I still can’t see them in the HABot Items attributes Review. I HAVE:

Added the new tag/s via http://myhab:8080/rest/swagger.json
Checked the file
org.eclipse.smarthome.core.items.Item.json

},
“HallBulbsSwitch”: {
“class”: “org.eclipse.smarthome.core.items.ManagedItemProvider$PersistedItem”,
“value”: {
“groupNames”: [],
“itemType”: “Switch”,
“tags”: [
“Lighting”,
“lightbulb”,
“Hall”
],
“label”: “Hall Bulbs”,
“category”: “Lightbulb”
}

“lightbulb” tag is there! (I don’t think it has to be uppercase?)

I have rebooted the server,

sudo reboot

cleared the app cache

But still, HABot can not see the attributes, hmmmm

I feel like I am missing something fundamental.
Thanks in advance

SCRATCH ALL THAT,

“lightbulb” tag is there! (I don’t think it has to be uppercase?)

YES it must be 1st letter uppercase in tags “Lightbulb”

Hi everyone,

I was trying to adapt my existing setup to HABot by adding all relevant tags to the existing groups, but for some reason HABot is unable to find any Locations that I pass. Given the Example below, I get a positive response for entering e.g. “Temperatur” with a card containing all the temperature relevant items, but a negative one for “Wohnzimmer” (Living Room) complaining that no Tag related to wohnzimmer was found. Trying combinations of both tag types, such as “What is the Temperature in the Living Room” (and its german counterpart), are also unsuccessful.

// Location Groups
Group	gAll		"All"
Group	gIndoor		"Indoor"				(gAll)			["Indoor"]		{synonyms="Im Haus"}
Group	gEG		"Erdgeschoss"		<groundfloor>	(gIndoor)		["GroundFloor"]		{synonyms="Erdgeschoss"}
Group	gLivingRoom	"Wohnzimmer"		<sofa>		(gEG)			["LivingRoom"]		{synonyms="Wohnzimmer"}
// Device Groups
Group	gActor		"Aktoren"				(gAll)
Group	gSensor		"Sensoren"				(gAll)
Group	gTemperature	"Temperatur"		<temperature>				["RadiatorControl", "Temperature"]
Group	gTempSensor	"Temperaturmessung"			(gTemperature, gSensor)	["Measurement"]
Group	gTempSetpoint	"Temperatureinstellung"			(gTemperature, gActor)	["Setpoint"]
// Devices
Number	LivingRoomWTHIsTemperature	"Temperatur (ist) [%.1f °C]"	(gLivingRoom, gTempSensor)	{channel="homematic:...#ACTUAL_TEMPERATURE"}
Number	LivingRoomWTHSetTemperature	"Temperatur (soll) [%.1f °C]"	(gLivingRoom, gTempSetpoint)	{channel="homematic:...#SET_POINT_TEMPERATURE"}

Any idea what I am missing here? I was wondering if locaton tags are inherited at all from any parent groups (and if so, if the tags are fetched recursively, i.e. is “Wohnzimmer” only location-tagged as [“LivingRoom”}, or [“Indoor”, “GroundFloor”, “LivingRoom”]).

I’ve already tried to investigate the issue by myself and activated logging for HABot by setting the log level for org.openhab.ui.habot to ALL, but this resulted in yet another strange behavior:

  • Whenever a text input leads to a positive response (e.g. “Temperatur”), there is no log entry at all.
  • However, for each negative one (e.g. “Wohnzimmer”), I only get the following entries:
03-Aug-2020 20:50:54.655 [DEBUG] [org.openhab.ui.habot.nlp.internal.IntentTrainer   ] - get-status[0.0897]  activate-object[0.0983]  create-rule[0.0535]  deactivate-object[0.1720]  get-history-daily[0.0535]  get-history-hourly[0.0535]  get-history-last-changes[0.0782]  get-history-monthly[0.2584]  get-history-weekly[0.0557]  set-value[0.0873]
03-Aug-2020 20:50:54.655 [DEBUG] [org.openhab.ui.habot.nlp.internal.IntentTrainer   ] - Intent [name=get-history-monthly, entities={location=wohnzimmer}]

Are there further plugins in which verbose logging would help me to pinpoint the issue?

I appreciate any help you can provide!

Thanks

Lukas

I think it might be related to your use of “device groups”, to work best with HABot the semantic model should normally be something like:

Group Location [<LocationTag>]
\
 Group SubLocation [<LocationTag>]
 \
  Group Equipment [<EquipmentTag>]  // represents a single equipment
  \
   Non-Group Point [<PointTag>, <PropertyTag>]

So:

  • You shouldn’t give groups Point or Property tags;
  • You can’t give both an Equipment and a Property tag to the same item (if you attach a Property tag it implies that the item is a Point, and it can’t be both an Equipment and a Point);
  • In your example the last 2 non-group items (LivingRoomWTHIsTemperature, LivingRoomWTHSetTemperature) should have Point & Property tags (["Measurement", "Temperature"] & ["Setpoint", "Temperature"]) and be direct members of either an Equipment group or a Location group.

The second diagram here: [wiki] Getting Started with OH3: rewriting the tutorial - 6. Model your home with Items & link Channels is an example of a properly designed model.

I also have trouble with HABot finding semantically tagged devices.

When I say “Turn ON the office light” or “Turn ON the light in the office” - it “didn’t find anything” - even though it is correctly in the Model:

grafik

Not sure how to continue here.

Did you try saying lightbulb instead of light? Or say desk light?

An Equipment isn’t really directly controllable as far as HABot is concerned. Point/Properties are controllable. So you need to create an Equipment for the Desk Light as a Group and then add the actual Switch as a member of the Group with a Switch/Light pair of tags. Alternatively, you can tag that Desk Light Item with Switch/Light and make it a Point/Property directly on the Location.

The dimmer item has an “Equipment” Tag "Lightbulb and a Property Tag “Light”. No Point Tag (does it need one?).
The item is part of the groups with the locations.

I’m still not sure what is wrong here. Can you fix it for me?

This is the item and group definition.

Group gTradfri "Tradfri" <ikeatradfri> (gAll) 
Group gGroundFloor  "Ground Floor" <groundfloor> (gAll) ["GroundFloor"]
Group gGF_Office "Office" <office> (gGroundFloor) ["Office"]

Dimmer   TRADFRIE14Schreibtisch_Brightness  "Desk Light" <desklamp> (gTradfri,gGF_Office)   ["Lightbulb","Light"]  {channel="tradfri:0100:gwdcefcaba8de9:65558:brightness"}

Yes. Equipment doesn’t have Properties so that “Light” tag is simply ignored. Only Points with Properties can be controlled. The Locations and Equipment tell HABot what and where but the actual control needs to be a Point/Property.

In OH 3’s MainUI it won’t even let you set a Property tag on an Equipment.

As I said, your Dimmer Item needs to be tagged with a Point tag (e.g. Switch or Control) and a Property Tag (i.e. Light). Not an Equipment Tag.

OK so I’ve added a Group for this which has the Equipment “Lightbulb”
Then “Control” and “Light” for the Dimmer item

Group gTradfri "Tradfri" <ikeatradfri> (gAll) 
Group gGroundFloor  "Ground Floor" <groundfloor> (gAll) ["GroundFloor"]
Group gGF_Office "Office" <office> (gGroundFloor) ["Office"]

Group gTradfriOffice "Tradfri Office Lamp" <desklamp>  (gTradfri,gGF_Office) ["Lightbulb"]
Dimmer   TRADFRIE14Schreibtisch_Brightness  "Desk Light"    <desklamp>  (gTradfriOffice)   ["Control","Light"]  {channel="tradfri:0100:gwdcefcaba8de9:65558:brightness"}

Looks good in the Model:
grafik

Still… no luck:

Edit: I did refresh HABot!

You might need to add some synonyms to the Items to help it understand what you are referring to. I bet it will work using “turn off the desk light” and possible “turn off the desk light in the office”.

When I did a lot of stuff with HABot in OH 2.5 I had to create a lot of synonyms. I’ve not gone back in OH 3 to see how it works though. But it seems the synonyms are still needed. Queries like “light in the front room” and “lights” will show the Items as expected. But when I want to just command an Item I have to use the Item’s label as written.

For example if I enter

query result
lights a list of all the lights with toggles to control them
family room a list of all the stuff in the family room including the lights
family room lights a list of all the lights in the family room
lights in the family room “I am sorry, I’ve got nothing on that.”
turn on the lights in the family room “There doesn’t seem to be anything matching your query.”
turn on Family Room Lamp1 (the Item’s actual label) successfully turns on the light

I think you need to add synonyms to your Items so that your office light is seen by HABot with that name in addition to the Item’s actual label.

1 Like

Yeah it seems that HABot is not fully up to the semantic tagging task yet.