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

Hi, I have issue with deleting links, commands pasted to ssh terminal looks OK

ohadmin@oh:~$ curl -X DELETE --header "Accept: application/json" "http://localhost:8080/rest/links/Weather_ForecastDay3Day_IconImage/weathercompany:weather:local:forecastDay3Day#iconImage"

with following output:


{"error":{"message":"Link Weather_ForecastDay3Day_IconImage -\u003e weathercompany:weather:local:forecastDay3Day does not exist!","http-code":404}}

Command generated by REST looks to use different format for channel and it works:

curl -X DELETE --header "Accept: application/json" "http://oh:8080/rest/links/Weather_ForecastDay3Day_IconImage/weathercompany%3Aweather%3Alocal%3AforecastDay3Day%23iconImage"

any clue how to fix this either in exporter or in OH settings please?

TIA
Karel

PS: OH is running on Ubuntu xenial in LXC container on openwrt router

Just to update - if someone has same issue - I fix it for my setup by adding

.replace(/:/g,"%3A").replace("#","%23")

at each link.channelUID in /etc/openhab2/html/exporter/js/exportREST.js
example:

...links.map(link => {return ["curl -X PUT --header \"Content-Type: application/json\" --header \"Accept: application/json\" -d \"{}\" \"http://localhost:8080/rest/links/" + link.itemName + "/" + link.channelUID.replace(/:/g,"%3A").replace("#","%23") + "\""]})

Hi Karel and thanks for spotting this. I don’t have any links with # in them so had not seen the problem.
It also worked just to replace # with %23 (and keep : ).
…:weather:local:forecastDay3Day%23iconImage
A bit odd that either worked, but not combined.

The proper solution is of course to use encodeURIComponent() to fix any non-URI compatible characters. I’ve uploaded a new version. I could then add/remove your link both via REST and SSH.

I’m sorry it took me so long to reply. At the moment I’m building a high speed logger with ESP32 to fix my car. Time flies… just wish the car did as well :confused:

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…