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

@ysc: In your opening post you provided a scheme of the initial version of the ontology.
Where can I find the recent version?
I know that I can define my own synonyms, but what are the current predefined tags that are to be used in the items file?

Good or bad news, you decide - the ontology is still the same as in the OP’s picture, it hasn’t changed since. :wink:

@ysc Im always focussing on the good side of things. So, I go for the “Good news”. :wink:
Let me ask yet two more questions:

1.) If one uses just the “one-line” equipment variant like in your example with the roller shutters, what points will be available then? I.e., for a rollershutter that is defined as follows:

Rollershutter volet_sdb2 "sdb2 [%d %%]" {knx="1/1/2, 1/1/3, 1/1/1 + <1/1/0"}

where:
1/1/2 = Move UP/DOWN
1/1/3 = Step UP/DOWN
1/1/1 = Command absolute position
1/1/0 = State absolute Position (Requestable)

Will all points be available, i.e. can I request Habbot to open / close the roller shutter or to set it to 50%? Or do I have to go for the “Equipment with multiple Ponts” variant?

2.) I have Hue bulbs in my ceiling lights. So, I have actually three items: light power, dimming and colortemperature. Is it the correct way to associate the items in the following way?

Group   gEG                           "Erdgeschoss"                                     ["GroundFloor"]
Group   EG_Wohnen                     "Wohnzimmer"    <sofa>            (gEG)           ["LivingRoom"]
Switch  Licht_EG_Wohnen_Couch	      "Couch-Licht [%s]" <light>        ( EG_Wohnen )   ["Light","Switch"]              { knx="..."}
Dimmer	HUE_EG_Wohnen_Couch_Dimmer    "Couch-Licht (Dimmer) [%.0f%%]"   ( EG_Wohnen)    ["Light","Control"]             { channel="hue:..." } 
Dimmer	HUE_EG_Wohnen_Couch_Farbtemp  "Couch-Licht (Farbe) [%.0f%%]"    ( EG_Wohnen )	["ColorTemperature", "Control"] { channel="hue:..." }

Do I maybe have to define a higher-order group for the Light “Couch-Licht” and subordinate these three points to that group?

You’ll have to add the Blinds tag to your rollershutter item, and then it will normally identify this item when you say “set the rollershutter in the living room to 50%” or “show me the blinds in the living room” (there are a number of built-in synonyms for a given class, e.g. for Blinds in German: openhab-core/bundles/org.openhab.core.semantics/src/main/resources/tags_de.properties at main · openhab/openhab-core · GitHub

Unfortunately HABot is not trained for “close/open” commands yet (I know…), so as a workaround you have to say “set the blinds to 0%” or 100% which will send “0” resp. “100” commands to that item.

In that case if you say “turn on (or off) the lights in the living room” it will likely find both Licht_EG_Wohnen_Couch and HUE_EG_Wohnen_Couch_Dimmer and send “ON” (or “OFF”) to both (because Dimmers can receive ON/OFF commands). If you say “set the lights in the living room to 30%” it will only send 30 to HUE_EG_Wohnen_Couch_Dimmer because the switch doesn’t accept that type of command.

Oh… Mhhh… Is there a way to restrict the association to the dimming functionality of the Hue-Item only? I.e. by using setpoint or so?

Not sure, but I don’t think so, sorry… currently it will not consider the type of Point (which could be a good idea eventually), only extract the concepts of “light” and “living room” from your query and send a command to all matching items whose type can accept it.

@ysc: Well, I have good news! :slight_smile:
OpenHAB together with its Binding for Hue supports ON/OFF to be handled seperately from brightness 0…100%.
Although both, the “Light Plug” switch item and the “Hue” dimmer items react on the ON/OFF trigger, this trigger is not directly converted to 0 or 100 by the dimmer item. Instead, the dimmer item sends an On/Off command instead of a brightness-value 0…100 to the hue basis. So, when the Light is switched on again, it goes on with the brightness it was switched off with.
It’s OK for me that when telling HabBot to switch on/off the lights in the room, it sends ON/OFF to all items (switches and dimmers).

Having said this, however, I was unfortunately not able to change any state of roller shutters or garage door. And the dimmers react only to certain values.

Group 		EG_WC         		"WC"         				["Room"]
Rollershutter 	Roller_EG_WC		"Rollladen WC"			(EG_WC)		["Blinds"]			{ knx="..." }
Dimmer		HUE_EG_WC_Decke_Dimmer	"WC (Decke) Dimmer [%.0f%%]"	(EG_WC)		["Light"]			{ channel="hue:...:brightness" } 
Group 		gGG 			"Garage" 					["Garage"]
Rollershutter 	Roller_Garagentor	"Garagentor"			(gGG)		["Switch"]			{ knx="...", synonyms="Garagentor" }

Using the above item definition, when trying to change the light to 70, I got the response that OpenHAB/HabBot did not understand the numerical value. However, when telling to change the light to 71, it works.

The rolllershutter in the toilett and the garage door can be found:

However, when trying to open/close them, OpenHAB/HabBot replies that it doesn’t understand my query:

I know this is an old thread, but I just opened HabBot for the first time to play with it and discovered that essentially none of my items have any tags. Almost all of my items have been created via PaperUI, so I don’t have any text files that I can update to add them. Is there an easy way to add tags to many items without the text files? Is the one way one item at a time via the API?

The correct answer is “yes”.

The sneeky answer is there is a way, but in all likelihood, if you are doing everything through PaperUI anyway you will not like it.

  1. Add a tag to an Item through PaperUI so you have an example.
  2. Stop openHAB.
  3. Open /var/lib/openhab2/jsondb/org.eclipse.smarthome.core.items.Item.json.
  4. Find the Item that you added the tag to and find the elements that define that tag.
  5. Edit each Item you want to add a tag to so it looks just like that, only with the proper tags.

Until we have OH 3 that’s about all you can do. Though, adding tags through the REST API isn’t all that much more involved than adding the tags would have been if PaperUI supported it.

Definitely not! You can add tags through rules. If you are using scripted automation, Jython, and the helper libraries, it would look like this…


from core.log import logging, LOG_PREFIX#, log_traceback
LOG = logging.getLogger("{}.TEST_2".format(LOG_PREFIX))

test_item = itemRegistry.getItem("Virtual_Switch_1")
LOG.warn("Before: {}".format(test_item.getTags()))
test_item.addTag("Add tag through rule example")
LOG.warn("After: {}".format(test_item.getTags()))

If you are still holding on to the rules DSL, it would look like…

rule "Test DSL rule"
when
    System started
then
    logWarn("Rules", "Before: {}", Virtual_Switch_1.getTags)
    Virtual_Switch_1.addTag("Tag example from DSL")
    logWarn("Rules", "After: {}", Virtual_Switch_1.getTags)
end

So, just build these out with all of the Items that you want to add tags to.

Well, I definitely wouldn’t have thought of using rules!

I was thinking about using the rest api to get the full list of my items, converting the json to a csv, sorting it and adding my tags with excel, and then making a python script to write my changes back to the API. I want the magical spreadsheet ability to copy and paste and fill. I’m not afraid of the API, but if there was already a tool to do the conversion from the flat spreadsheet back to the database for me, I’d prefer to just use that.

I can’t say I’m a big fan of PaperUI, but it has the massive advantage over the text files of not requiring me to be on a computer and then directly ssh (or samba) to the files to be able to make any changes.

Yes, I keep hearing things “maybe in openHAB 3,” but there seems to be a lot of rumor and almost nothing official about what it will really look like. :roll_eyes:

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: 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.