Newbie Problem with adding .things config file

Hi All,

I new to openhab, and have watched videos and read through the documentation but im still struggling.

I see that by using Visual source code you can import items into your .items config file, can you do the same with .things?

I have a working configuration setup through paper ui, but when I try to write my .things I seem to struggle with it working. I get ther syntax wrong.

for example, when I try to add the gateway for my xiaomi gateway hub (which for some reason I have two in paper ui, one with

‘Xiaomi Gateway’ with the
Mihome:bridge:MacAddress

and another with
Xiaomi Mi Smart Home Gateway
Mihome:gateway:MacAddress

in my .thing file do I just write all this out?
Bridge mihome:bridge:MACadd “Xiaomi Gateway” [ serialNumber=“MACadd”, ipAddress=“192.168.xxx.xxx”, port=9898, key=“whatever the key was”, pollingInterval=600 ] {
Things:
bridge Macaddy “Xiaomi Gateway” [itemId=“MACadd”]
gateway Macaddy “Mi Smart Home Gateway” [itemId=“MACadd”]
]

is that right? even though the MAC address is the same for both?

When I do create the .things file.

all things appear offline, and the original autodiscovered items still appear online in configuration/things.

but now the offline things have
mihome:gateway:MACaddress:MACaddress
which doesn’t see right as the online autodiscovered things just have
mihome:gateway:MACaddress

im so confused

Hi Dave,

Welcome to OH2.

Most of the videos out there are outdated…be rather careful…

by far your best source of accurate information…and this forum of course, but watch for the timestamps, OH has developed over the years and older forum posts may not be applicable anymore.

As to your question: You need to use EITHER PaperUI OR text files to define a thing or an item. You can do 95% of all operations through PaperUI, so for now maybe that is easier. You do not want to have two identical things or items defined.

OH offers options and choices in many areas, so you can work in the ways most comfortable to you; unfortunately, this can be overwhelming and confusing to beginners.

If you have accepted your things through the PaperUI, do NOT configure them as well in text files. It may help at this point to simply delete your .things files and continue to work in PaperUI only. If you still have double-entries, it may be the easiest to start over with a new clean install.

Finally, there is one area, where there is only textual configuration possible: sitemaps. (And just in case: PaperUI is for admin only; for standard use, you will need to create a sitemap.)

Thanks Markus.

I really want to use the configuration files, I have read many conversations that you can loose your entire configuration and the best way is to have configs.

I have many IoT devices, and I don’t want to have to recreate them (and I believe once I understand how to use these config files I will get much better at the config).

do I need to delete all the autodiscovered devices once I use the addon.cfg and the .things/.items?

any idea’s?

@itdnd

This depends how old the things you read were. If you have a current version, all configuration is stored in a jsondb


OpenHabian also provides easy backup solutions for all your configurations, so there would be no need to worry.

If you are determined to go with text files, be prepared to struggle with syntax…
but here you go:

  • read the doc, read the doc, read the doc
  • delete all your things in PaperUI; stop OH, clean cache, and restart OH
  • start building you things files slowly
  • do NOT add things through the PaperUI
  • most things if configured correctly through your text files, will disappear in your PaperUI inbox (not all)
  • you can check whether you can control things through PaperUI, if you can, your things file works
  • closely monitor the logs if you edit things files and follow-up on errors
  • be prepared to use the sequence: stop OH, clean-cache, start OH regularly to get rid of issues

There are quite a few people, who use OH with text files only configs…but it is easier to learn OH if you use PaperUI for all of that…

1 Like

If you call it simply ‘.things’ then you’re making a hidden file (filenames that start with a dot), there should be a filename prefix such as ‘default.things’.