My.openHAB support in openHAB 2

All, I am happy to announce that I have ported the my.openHAB bundle from 1.x over to 2.0! It is thus now available as an openHAB 2 add-on!

There are a few changes that you should be aware of:

  • You do not require a myopenhab.persist file anymore; if you do not create one, the bundle will automatically send all item updates to my.openHAB. If you create the file, it will be taken into account as before and only what you have configured in it will be persisted.
  • You will find the uuid in userdata/uuid and the secret in userdata/myopenhab/secret.
  • To remotely access your openHAB dashboard, go to https://my.openhab.org/start/index.

Best regards,
Kai

3 Likes

Hi Kai,

do i have to create a new account to test my.openHAB with openHAB 2?

I have my.openHAB running with an openHAB 1.7.1 installation at this time.

Best regards
Mani

No, you can use the existing account. You either

  • go to your account settings (https://my.openhab.org/account) and temporarily change UUID and secret
  • or you shutdown your 1.7 instance, copy the uuid and secret file to the openHAB 2 instance and start this up

I can find userdata/uuid in my openHAB 2 installation.
But there is no userdata/myopenhab/secret.
I do not have that folder userdata/myopenhab/

There seemed to be a problem with the #307 build - I just tried the latest https://openhab.ci.cloudbees.com/job/openHAB2/308/, which works fine. Note that you will have to start the runtime at least once to make the uuid and secret files appear.

1 Like

I am getting a message “ERROR 400 OK” whenever I try to change a switch state on my.openhab.org.

Please suggest what’s wrong.

This happens only with the Paper UI, the Classic UI works ok.

I was able to reproduce it there. In the logs I find

2015-08-15 20:35:03 [DEBUG] [o.i.m.internal.MyOpenHABClient:274  ] - Got request 4895
2015-08-15 20:35:03 [DEBUG] [o.i.m.internal.MyOpenHABClient:283  ] - {"content-type":"text/plain;charset=UTF-8","cache-control":"no-cache","host":"my.openhab.org:443","accept-language":"de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4","accept":"*/*","content-length":"2","origin":"chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm","user-agent":"openhab-cloud/0.0.1","accept-encoding":"gzip, deflate"}
2015-08-15 20:35:03 [DEBUG] [o.i.m.internal.MyOpenHABClient:305  ] - Request method is POST
2015-08-15 20:35:03 [DEBUG] [o.i.m.internal.MyOpenHABClient:345  ] - Jetty set header content-type = text/plain;charset=UTF-8
2015-08-15 20:35:03 [DEBUG] [o.i.m.internal.MyOpenHABClient:345  ] - Jetty set header cache-control = no-cache
2015-08-15 20:35:03 [DEBUG] [o.i.m.internal.MyOpenHABClient:345  ] - Jetty set header host = my.openhab.org:443
2015-08-15 20:35:03 [DEBUG] [o.i.m.internal.MyOpenHABClient:345  ] - Jetty set header accept-language = de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
2015-08-15 20:35:03 [DEBUG] [o.i.m.internal.MyOpenHABClient:345  ] - Jetty set header accept = */*
2015-08-15 20:35:03 [DEBUG] [o.i.m.internal.MyOpenHABClient:345  ] - Jetty set header content-length = 2
2015-08-15 20:35:03 [DEBUG] [o.i.m.internal.MyOpenHABClient:345  ] - Jetty set header origin = chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm
2015-08-15 20:35:03 [DEBUG] [o.i.m.internal.MyOpenHABClient:345  ] - Jetty set header user-agent = openhab-cloud/0.0.1
2015-08-15 20:35:03 [DEBUG] [o.i.m.internal.MyOpenHABClient:345  ] - Jetty set header accept-encoding = gzip, deflate
2015-08-15 20:35:03 [WARN ] [io.rest.core.item.ItemResource:206  ] - Received HTTP POST request at 'items/Light_FF_Bath_Ceiling' with an invalid status value ''.
2015-08-15 20:35:03 [DEBUG] [o.i.m.internal.MyOpenHABClient:588  ] - Jetty finished receiving response header
2015-08-15 20:35:03 [DEBUG] [o.i.m.internal.MyOpenHABClient:597  ] - Sent headers to request 4895
2015-08-15 20:35:03 [DEBUG] [o.i.m.internal.MyOpenHABClient:598  ] - {"headers":{"Content-Length":"320","Content-Type":"text/html; charset=ISO-8859-1","Server":"Jetty(9.2.12.v20150709)","Cache-Control":"must-revalidate,no-cache,no-store"},"id":4895,"responseStatusText":"OK","responseStatusCode":400}
2015-08-15 20:35:03 [DEBUG] [o.i.m.internal.MyOpenHABClient:573  ] - Jetty received response content of size 320
2015-08-15 20:35:03 [DEBUG] [o.i.m.internal.MyOpenHABClient:579  ] - Sent content to request 4895
2015-08-15 20:35:03 [DEBUG] [o.i.m.internal.MyOpenHABClient:551  ] - Finished responding to request 4895

@belovictor, Do you have any idea, what might be wrong here?

From what I see POST is made without any content. Probably it is a problem with 2.0 bundle, will check this.

@Kai,
BytesContentProvider(byte[]… bytes)
BytesContentProvider(String contentType, byte[]… bytes)

So new BytesContentProvider(requestBody) probably produces an empty content :smile:

@Kai,
request.content(new BytesContentProvider(requestBody.getBytes()));
fixes the problem.

1 Like

great news - just waited for this binding to Switch OH2

Ok, so https://github.com/openhab/openhab2/commit/c49af820c3659bc1040ed7902bebac6adf43ec6f should fix the problem then. Thanks for the analysis (and feel free to create PRs yourself for fixes!).

1 Like

well my openhab will not create anything in userdata/ …

installation of openhab2 is up and running… other addons like habmin2, zwave are working

i placed the io.myopenhab jar in the addons folder and restarted… anything i missed?

thanks for help

I just tested it (again):
Using the latest demo snapshot and copied the myopenhab 2.0.0 jar into addons:
It created the files
userdata/uuid
userdata/myopenhab/secret

So all looks good.

Just an FYI to all those chasing issues with myopenhab in OH2, my system showed everything connected but nothing would populate on my.openhab.org until i installed rr4dj persistance also.

Is this Correct Kai??

I am not aware of any dependency on rrd4j, so I cannot confirm.
If this is the case, I would rather consider it a bug that needs to be analyzed.

I have been trying to get My.openhab.org persistence to work for 2 weeks.
It would show online etc but nothing would appear in the items list. In
desperation i tried adding removing various bindings, until rr4dj. The
second it installed a new connection appeared in the log to openhab.org and
it all worked.

So unless you can think of anything that would make this occur I would say
there is a bug.

Please test and let me know

cameron

I have an issue that my.openhab shows offline.

I have put the UUID and the secret in.

Is there anything else i need to do? I know with openhab 1 i had to change a parameter to External

Are there any myopnehab messages in your log?

Nothing in the logs,
I ran log:set DEBUG org.openhab.io.myopenhab
I restarted it
Then ran log:display org.openhab.io.myopenhab

nothing was returned.