HowTo: Move ALL items to JSON dB for easy editing in PaperUI and tagging for Google Home (and Alexa)

Hi Peter thank you for help and update, just download it and test and it’s perfect.

I updated my last comment as finally it does not work (I try it on link without # which was OK and spot again errors after posting) I fix it evening and plan to edit my post in the morning as it was too late already.
I’m not really programmer than my workflow is google/trial/fail/google… :slight_smile: and it takes sometimes long time.

I really like your tool. Again thanks a lot for fix and hope your car will fly again soon.

I am probably doing something wrong here, when I extract to a temp folder there is no “exporter” folder.
After downloading the file from GitHub I extract the content using sudo 7za e PeteR-REST-Exporter-Importer.7z

Not sure what I am doing here that is wrong, so any help is appreciated.

try x instead of e:

7za x PeteR-REST-Exporter-Importer.7z

@marcel_erkel after using x insted of e seems that I am still getting same content
image

May I am downloading the wrong file ? Not sure if this is possible, but…

I’ve tried the .7z file from here https://github.com/giPeteR/OpenHAB-exporter-importer then i get an error “Is not archive” when trying to extract

When I click on the file name, I get this


then I get the download button to get the download link and use it on my linux PC (ssh) to download the file

sudo wget https://github.com/giPeteR/OpenHAB-exporter-importer/raw/master/PeteR-REST-Exporter-Importer.7z

Ok, I see what you mean. The exporter directory is not in the zip. Here’s how to make it work:

mkdir /tmp/exporter
wget https://github.com/giPeteR/OpenHAB-exporter-importer/raw/master/PeteR-REST-Exporter-Importer.7z
7za x PeteR-REST-Exporter-Importer.7z -o/tmp/exporter
sudo chown -R openhab:openhab /tmp/exporter
sudo mv /tmp/exporter $OPENHAB_CONF/html/

Open your browser and go to http://<openhabip>:8080/static/exporter

You will now see the instruction page.

2 Likes

Thank you @marcel_erkel it is working now I really appreciate your help

1 Like

Or I could read the documentation all the way through first :roll_eyes: and find the answer!

Thank you for helping out!
I initially zipped my main HTML folder /srv/openhab2-conf/html/ which contained the subfolder /exporter. But it also contained some other stuff not needed. During an update I only zipped the /exporter folder and forgot to update the instructions.

1 Like

Hi - the problem with step 7, where http://openhabianpi:8080/doc/#!/items/createOrUpdateItems can’t be accessed is because some of you guys don’t have the rest documentation addon installed in paperUI. Attached is an image where you can find the rest doc addon.

After this addon is installed, you’ll be able to access http://openhabianpi:8080/doc/#!/items/createOrUpdateItems

2 Likes

Hello,
I do not have a technical question, but I would like to know where you see the benefits of using the item configuration in PaperUI.
I personally have a mix with around 1000 items via PaperUI and 1000 via item files. I’m not really happy about, but it happend,. :slight_smile: actually it happened because adding items to thing (e.g. adding items to my homematic devices was initially much easier via PaperUI)
However right now I would prefer all of my items in item files, since it’s much easier and faster to modify a bunch of items, e.g. if you want to add them to a new group. On the item files I can use several tools to easily modify them, in PaperUI I have to click on every single item do my modification and save it…

My question now is, am I using the PaperUI item config wrong and is there a easy way to modify several items really quickly?

Hi!
This is a really powerful way / tool to multi edit stuff. Thank you!

I moved my stuff to a playground setup so I can learn this and try things without breaking as I am not skilled at this.

I am however stuck at step 7 where it spits out a http err 500. I opened the code in Visual studio code in the hopes of it to spit out something and also in jsonlint and some other online json formatting/ verification tool.

What am I missing here? do I need to update to some certain java level in OH?

Running the OH2 in a docker container on a ubuntu server

Br
Johan

Martin, I’m all with you.
Initially, as a “beginner” it was so much easier to use the Paper UI to do the work. And to understand how OH created things/items/channels. But now (some months ago) I’ve bought a new RPi4 and will move OH to that one. I will then go over all naming of my devices, to make them “logical” to use with Google Home, and also logging with PostgreSQL, and graphing with Grafana, and making rules in Node-RED. So you’re right, I will probably leave Paper UI except for when figuring out how new things are added/function.

Jo[quote=“jr555se, post:35, topic:65070, full:true”]
Hi!
This is a really powerful way / tool to multi edit stuff. Thank you!

I moved my stuff to a playground setup so I can learn this and try things without breaking as I am not skilled at this.

I am however stuck at step 7 where it spits out a http err 500. I opened the code in Visual studio code in the hopes of it to spit out something and also in jsonlint and some other online json formatting/ verification tool.
[/quote]

I apologize for this late answer, and I hope you figured it out…?
I think you had not installed REST Documentation, as mentioned in the 5 - previous post.

People, I’m sorry for slow response.
When I do something I usually spend “a lot” of time with that, but then I move on to another project. Luckily few people have had questions, and others have helped. As I mentioned, I’ve bought a new RPi and will probably refactor a lot of things soon.
I think the way forward is to manually define things, items and channels, so I don’t have multiple tables in PostgreSQL and don’t have to rewrite the SQL queries in Grafana. Not there yet…
I still think Paper UI is very powerful and an excellent way of discovering new things. It’s just not meant to update several things at once.

maybe, I honestly cannot remember :smiley:
At least my issues are resolved.

Dont worry! I know how it is :slight_smile:

For those interested; I made a small tool for the other way around (JSONDB -> textual config): JSON2Config

1 Like

HI to everyone i’m new to Openhab.
I ve installed Openhab 2.5.8 via apt on a headless RPI 3b+.
So $OPENHAB_CONF is /etc/openhab2
In the folder $OPENHAB_CONF /html i’ve estracted the package.
Whith another linux machine i open browser on page
IPADRESSOFRPI:8080/static/index.html, the page loads
but 3 error messages appear:
Links fetch error:’ ReferenceError: generateLinks is not defined ’
Items fetch error:’ ReferenceError: generateItems is not defined ’
Things fetch error:’ ReferenceError: generateThings is not defined ’
And no text appear to be copy-pasted…

Hi @PeterR
I think I stumbled upon a bug with Openhab2 which breaks your script. I have this group item in my .item file:

Group:Switch:AND(ON,OFF)            AlarmArmed     "Alarm uzbrojony" <alarm>           (Home)   ["Alarm"]

It got serialized to:

{"name":"AlarmArmed",
    "tags":["Alarm"],
    "type":"Group",
    "members":[],"groupType":"Switch","function":{"params":["ON","OFF"]},"link":"https://dom.tjach.pl/rest/items/AlarmArmed","state":"OFF","editable":false,"label":"Alarm uzbrojony","category":"alarm","groupNames":["Home"]}

Putting that via CURL lead to:

< HTTP/1.1 500 Internal Server Error
< Server: nginx/1.18.0 (Ubuntu)
< Date: Sun, 03 Jan 2021 11:20:17 GMT
< Content-Type: application/json
< Content-Length: 82
< Connection: keep-alive
< Content-Encoding: UTF-8

{"error":{"http-code":500,"exception":{"class":"java.lang.NullPointerException"}}}

After a little bit of research, I’ve noticed that the serialized group item does not contain the function part (Items | openHAB ).

The correct serialized item is like this:

	{"name":"AlarmArmed",
    "tags":["Alarm"],
    "type":"Group",
    "members":[],"groupType":"Switch","function":{"name": "AND","params":["ON","OFF"]},"link":"https://dom.tjach.pl/rest/items/AlarmArmed","state":"OFF","editable":false,"label":"Alarm uzbrojony","category":"alarm","groupNames":["Home"]}

So is it a bug in Openhab REST or I’m doing something wrong?

Hey,
in case someone still reads this: I had the same Issue. I found a fork on GitHub that works:

If solves for me the issues
Links fetch error:’ ReferenceError: generateLinks is not defined ’
Items fetch error:’ ReferenceError: generateItems is not defined ’
Things fetch error:’ ReferenceError: generateThings is not defined ’

Cheers

FWIW, OH 3.1 and up has an UI option to import .items file contents