OpenHAB2 + MQTT questions

Hopefully this is just a matter of me not understanding something simple about the software. I’m attempting to set up OpenHAB to display the temperature in my living room. I want to use MQTT to do this. I am running this all on Windows 10.

My mqtt.cfg file has this:


I have Mosquitto running on my pc. I can use the pub/sub commands as well as MQTTLens to publish and subscribe to messages and everything seems to be working fine.


Number livingtemp “Temperature [%.0f]F” { mqtt="<[mosquitto:/living/temp:state:default]" }


sitemap Test label=“OpenHAB”
Number item=livingtemp label=“Living Room Temperature”

Unrelated info, but shows that some things are working: I have also added 6 LIFX bulbs under “Things”. For one of these, I have clicked on the “Thing” and created an “Item”. Not sure where these are stored as they are not showing up in a .thing or .item file (that I have noticed.)

Here’s my question: When I click on “Control” in PaperUI, I see the LIFX bulb that I added an Item for - I can turn it off and on, change the color, etc. However, I do NOT see the temperature item listed in my sitemap. (It doesn’t show in any UI.) I’ve tried using mosquitto_pub to publish a number for it to display, but it never shows up. Should I see the temperature item here? And if not, how to I see the value for it?

Thanks in advance for any assistance.

Yep, common beginners mistake. Should remove the label from;

Number item=livingtemp label="Living Room Temperature"

You have defined the label in the item binding, correctly, with a placeholder for the item value - e.g. should actually be `[%.0f F]`, note the `F` inside the placeholder.

You have then defined a new label in the sitemap, which overwrites the item label. The problem is the sitemap label doesn't include a placeholder for the item value - in this case the temperature value.

You can have a different label in the sitemap if you wish, you just have to add the item value placeholder. But it is better practice (IMHO) to leave the labelling to the item definitions wherever possible.

Thank you for the quick reply!

I’ve made the edits as you suggested:

Number livingtemp “Temperature [%.0f F]” { mqtt="<[mosquitto:/living/temp:state:default]" }

sitemap Test label=“OpenHAB”
Number item=livingtemp

The temp doesn’t display - just the LIFX bulb which isn’t even listed in the sitemap. The LIFX bulb seems to exist in the …core.items.Item.json and …core.thing.Thing.json files. Is it possible it’s being build from these files and ignoring the sitemap? I can see “Refreshing model ‘default.sitemap’” when I edit the file, but no edits seem to make a difference. I stopped/restarted OpenHAB2 just in case, but no difference.

Sorry, I don’t use OH2 (still on OH1.8) so I can’t help with that side of things.

Your sitemap is called Test, but are you actually loading default? From memory, default contains the auto generated things from PaperUI so your LifX bulbs would be here, and the temp item not.

What web address are you opening?

After configuring the LIFX bulb, there were no .sitemap files automatically created, so I created a default.sitemap file and added the temp thing as a test.

I tried renamed the file to test.sitemap and changed the contents to match, but no difference.
sitemap test label=“OpenHAB”
Number item=livingtemp

I’m just going to http://localhost:8080, then clicking the PaperUI icon.

That’s the problem.

PaperUI doesn’t use sitemap files. You need to use/install either the BasicUI or ClassicUI User Interface addons to view sitemap files.

You might already have one installed, if so, click that icon instead of PaperUI

Initially, only the LIFX bulb would show, even in the BasicUI. Fortunately, I now have this working. I installed 1.8.3 and got it working there, then moved the files over to 2.0 to figure out the difference. I noticed that BasicUI was configured to load _default as the default sitemap, so I changed that to just default. Also, in my sitemap file, I didn’t have the sitemap called default to match the filename. I noticed that 1.8.3 complained about this, so I fixed it there. I think the configured default sitemap and the sitemap name not matching the filename were the issues all along. Now, BasicUI loads and shows what’s in my sitemap and doesn’t show the LIFX bulbs as expected.

I guess I’m off to keep learning about OpenHAB! Hopefully I can learn enough to help someone in the future! Thanks to everyone for their responses.

They are stored in the JSONDB files you can fine under userdata/jsondb. In fact, all Items and Things get stored there. What happens is when OH reads and parses your .items and .things files it puts them into this JSONDB as well and OH runs off of the JSONDB.

Control only shows Things, not Items. Since your MQTT Items are using the 1.x version MQTT binding (there is no 2.x version) it has no corresponding Thing. The Control section is, in my opinion, primarily useful as a way to test that you have your Things configured correctly. But for integration and use in your home automation it is not useful because it doesn’t operate on Items which everything else in OH does.

No you shoudn’t. To see the value you need to create a sitemap or HABPanel and put the temperature Item (and presumably your Light Switch, Dimmer, and Color Items) on that. Or you can set up a dashboard in HABmin.