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

items
tags
googlehome
Tags: #<Tag:0x00007fe0573079f8> #<Tag:0x00007fe057307778> #<Tag:0x00007fe0573072f0>

(Peter R) #1

Dear all, this is my very first post here (and may have a bunch of formatting errors)…
…but I think this may help a lot of people struggling with a mix of .items -definitions.

OS: Raspbian GNU/Linux 8.0 (jessie)
openhab2: 2.5.0~S1502-1 (snapshot 2018-01-20)

OpenHAB REST Exporter/Importer for Items and Links
Download

These files will allow you to make all your items editable (RW) in a couple of minutes.

  • It doesn’t matter if items are created in PaperUI, HabMIN, .items -files. All items can easily be inserted into the OpenHAB JSON dB and editable through PaperUI.
  • This script does not change anything in OH and cannot break anything. It only extracts data in a very easy to edit format, which then (again easily) can be imported to OH using REST and SSH.
  • You yourself have to add any tags (if you like) in your favorite text editor (I’ve fallen in love with Visual Studio Code which has OH support).
  • Or use this tool without any edits to just make all your items editable in PaperUI.

My main purpouse is adding tags enabling Google Home (and likely Alexa?).

This is for RaspberryPi, OpenHab 2 (snapshot) & SSH. It probably works for most platforms as long as you can use SSH.
I’m using OH2 aliases mapped to /srv/ instead of hard paths, which makes it less platform dependent.

The boring stuff: “Use it at your own risk!” I have +200 items and used this method 20 times now, rebooted plenty, tested again… but it may behave differently at your system.

Installation:
Download .7z and extract to a temp folder. Then copy files to /srv/openhab2-conf/html/
You can skip index.html , I only put some useful (to me) links in that start page. Everything needed is in the subfolder exporter .
Browse to: yourserver:8080/static/exporter

Feel free to ask or comment, but please have a look at all helpful links in the html/script.

Best Regards
Pete R

openHAB Google Assistant
HowTo: Listen & Talk to your Home
Moving on from simple mode
Setting Tags and Groups
Apply tags to items added/linked in Paper UI
Add/remove item to group through REST API fails
[SOLVED] Move thing configuration from UI to files
DSL serializer for items and things #4817


Moving on from simple mode
Apply tags to items added/linked in Paper UI
Add/remove item to group through REST API fails
Setting Tags and Groups
(David Graeff) #2

Perfect timing :slight_smile: Thanks a lot.

Cheers, David


(Peter R) #3

You havn’t tried it yet :wink:
(I sure hope it help others, I spen’t around the clock for over a week doing this. But now I can move all items to JSON dB over and over in few minutes.)


(David Graeff) #4

Haha, you mean I regret what I just said :smiley: I’ll try with a test system first as soon as I find time.

But more importantly: I’m working on that Paper UI new generation design study that includes the vision of not having .things and .item files anymore (not in their current form at least) and your importer/exporter is the perfect match.


(Rich Koshak) #5

Thanks for posting! As David said, this is very timely and will get a lot of use over the coming months I’m sure.


(Lucky) #6

I did this when I integrated with Google Assistant but I created a “blacklist” of stuff I didn’t want tagged. There should be a disclaimer about this in OP or in the git. I have items that trigger my alarm system, doors, etc so I was careful not to tag stuff I didn’t want tagged.


(Peter R) #7

This webpage and JavaScript only extract and format the output for easy editing. You yourself have to add tags (if you like), and then import them again using REST and SSH.
I have updated the Intro and made it clearer. Thanks for the input.


(Christian) #8

Is there a typo in the documentataion?

./backup –full

./backup --full


(Peter R) #9

Yes, it was a typo. Thanks for pointing it out. It’s fixed now.
I also noticed the hyphens ‘-’ could become the wrong ones during cut’n’paste. So people, try the - - help to see that you get help. Then - - full should work also.


(Ján Tančibok) #10

Hi, im trying to use ypur scripts, but im unable to access http://openhabianpi:8080/doc/#!/items/createOrUpdateItems, i got 403. Can you help me?

Im just starting with OH, with openHABian
Your scripts are copied to /srv/openhab2-conf/html, and chmod to 777
I have REST Documentation addon installed, I also rebooted rasberry several times.


(Peter R) #11

Hi Ján.
The link that doesn’t work, is it from step 7 in the instructions? Does the other steps work? Can you extract any data at all, i. e. items and links?
Does this work for you?
image

I don’t think this is related to my script. REST is dynamically created and not in /html. Can you access OpenHAB start page and from there click REST API?
http://openhabianpi:8080/start/index
If that works, you can for example in step 7 go to PUT/items
image


(Ján Tančibok) #12

Thank you, yes your scripts worked properly, I was just uncertain about that step 7, because that link doesnt work. Im able to go to PUT /items, manualy, so I going to try it.


(J Wee) #13

Would these scripts affect the frontail settings I have in the html folder?


(Peter R) #14

No it won’t change any settings as long as you don’t replace any files you already have.
Please see updated Installation


(Peter R) #15

You can try with just one item to see you get a response 200 OK. Do that before you start deleting things. You will get OK even if the item already exist. Remember starting/ending [ ].
Wonderful to get some feedback :slight_smile: