Setup your own openhab-cloud (myopenhab) server/instance

I got this working, the instructions are poorly written with respect to the Security Profile section

What you need to do in addition to the instructions is:

Set the Payload to be V2 under the Linking.
Ensure when you create the Amazon profile you do it under ‘LOGIN WITH AMAZON’ not under ‘Security Profiles’

Then it links

1 Like

This has been bugging me for hours, I can’t get the app to work on my oh-clod/nginx instance!
The end result is always the “spinning circle of death” in the android app, and if I check my nginx access.log it seems it continuously tries to download the sitemap again and again.
(I’ve checked firewall logs, even tried disabling it. Also tried clearing any cache/default sitemap in the app).

Nginx access.log:

myexternalIP - myuserid [10/Oct/2018:10:51:22 +0200] "GET /api/v1/settings/notifications HTTP/1.1" 200 32 "-" "okhttp/3.9.1"
myexternalIP - myuserid [10/Oct/2018:10:51:22 +0200] "GET /rest/bindings HTTP/1.1" 200 3138 "-" "okhttp/3.9.1"
myexternalIP - myuserid [10/Oct/2018:10:51:22 +0200] "GET /rest/sitemaps HTTP/1.1" 200 416 "-" "okhttp/3.9.1"
myexternalIP - myuserid [10/Oct/2018:10:51:22 +0200] "GET /rest/sitemaps/House/House HTTP/1.1" 400 270 "-" "okhttp/3.9.1"
myexternalIP - myuserid [10/Oct/2018:10:51:23 +0200] "GET /rest/sitemaps/House/House HTTP/1.1" 400 270 "-" "okhttp/3.9.1"
myexternalIP - myuserid [10/Oct/2018:10:51:23 +0200] "GET /rest/sitemaps/House/House HTTP/1.1" 400 270 "-" "okhttp/3.9.1"
myexternalIP - myuserid [10/Oct/2018:10:51:23 +0200] "GET /rest/sitemaps/House/House HTTP/1.1" 400 270 "-" "okhttp/3.9.1"
myexternalIP - myuserid [10/Oct/2018:10:51:23 +0200] "GET /rest/sitemaps/House/House HTTP/1.1" 400 270 "-" "okhttp/3.9.1"
myexternalIP - myuserid [10/Oct/2018:10:51:23 +0200] "GET /rest/sitemaps/House/House HTTP/1.1" 400 270 "-" "okhttp/3.9.1"
....the last lines of request repeats forever...

Any clues? :thinking:

Edit:
The server apparently sends a 400 (Bad Request) on the response, but can’t figure out why.
(No errors in nginx error.log)
Edit2:
If I manually login via web on my phone and try to retrieve the same url it works just fine, its only the app that won’t work

Wow thank you so much! However I think I ask the wrong question, sorry!
What I want is to be able to receive in app notification when using a custom openhab-cloud instance. (which will be possible when use offical website account but not possible for custom one?)
or are you saying the offical ohcloud website is using ifttt to achive in app notifications?
May I ask you when setup ifttt like you mentioned above, do you receive the in app notification from your custom oh-cloud instance?
sorry for those noob questions.

I have tested in-app notification (using Google Cloud Messaging configuration on the custom oh-cloud instance), but I have not used it for anything else than testing sending a message from the oh-cloud web interface. Not sure I can help here…

OH-cloud is able to send notifications directly through the google cloud messaging engine. You need to configure a project in google cloud and set-up the openauth to make it work anyway. No need for IFTTT.

I have only used IFTTT to send events to my custom OH-cloud instance, so I have not tried it to send notifications to the mobile. It might work, anyway.

How did you manage to translate IFTTT request URI to the openhab REST api endpoint? IFTTT appends “ifttt/v1/status” to the end of the rest end point and this cause a 401 response from my private openhab-cloud.

I am not using IFTTT anymore (too unreliable for geofencing, which was what I mostly wanted it for), but here some snapshots of the API config I was using, in case it is useful to somebody. It is probably not the best in the world, and can be surely improved

My IFTTT API configuration for custom OH Cloud instance:

1 Like

Thank you very much for your reply. This really helps. However, I have 2 noob questions and hope you don’t mind.

  1. Is it a must to have oath2 established before any triggers, or can I use no authentication until I get things working?

  2. If you found IFTTT not reliable for location services, what is your recommended alternative?

I have only tried with oauth setup.

I am using EpiGeoZone, even if it has been discontinued by the developer. For that, I use a custom PHP integration frontend, as it does not support OAUTH.

I can’t get this working. I installed this on Ubuntu in AWS, got some weird problem with bcrypt. sudo node app.js returns immediately.

Then I tried the same with Ubuntu 64bit in VirtualBox. There sudo node app.js gives “node_redis: Warning: Redis server does not require a password, but a password was supplied.” It stays on until ctrl-c but curl http://localhost:3000 just gives Connection refused.

You can ignore the Redis warning. Please follow the instructions here and let us know if it worked.

Finally got the oauth part working with IFTTT. For the benefit of the rest, here are the steps I followed:

oauth2 setup for openhab-cloud

  1. From IFTTT API Tab select Authentication from left menu

  2. Select “My API has users with non-expiring OAuth2 access tokens” option

  3. Client ID: ifttt

  4. Client Secret: Type in any combination of long string of your choice

  5. Authorization URL: https://YOUR_DOMAIN/oauth2/authorize

  6. Token URL: https://YOUR_DOMAIN/oauth2/token

  7. Redirect URL: https://ifttt.com/channels/YOUR_IFTTT_NAME/authorize

  8. Save

Now, we need to add IFTT token information in to mongo db.

  1. Log in to your openhab cloud server
  2. Change the directory to your openhab-cloud installation folder
    cd /opt/openhab-cloud/
  3. Create addoauth.js using Pedro Garcia’s script over here
    sudo nano addoauth.js
    paste the script content
    press ctrl+x and Y
  4. run the script
    sudo node addoauth.js ifttt ifttt <that long string you typed in IFTTT as Client Secret>

Run connection test from IFTTT to see if everything works as expected!
Note: You have to update config.json to include IFTTT Channel Key and test token as below:

  1. Edit config.json file
    sudo nano /opt/openhab-cloud/config.json

  2. Update the iftttChannelKey and the iftttTestToken as below

    “ifttt” : {
    “iftttChannelKey” : “Service key from IFTTT API tab - General section”,
    “iftttTestToken” : “See below”
    },

To obtain your iftttTestToken,

  1. Register a test user at your openhab cloud instance.
  2. Then enter those user credentials at the “Demo account login” section of the IFTTT API tab - Authentication section
  3. Run a connection test by clicking on the “Begin Test” button located at the “Connection Test” section of the API tab
  4. Click “Allow” when prompted to authorize IFTTT accessing your openhab-cloud
  5. Once test complete, Copy the “AccessToken” from the BODY of the RESPONSE of “Request Access Token” section. This becomes your iftttTestToken for the above config.jason update

Ah! one last point, don’t forget to Enjoy! :wink:

1 Like

I read the linked instructions, and downgraded Node to 7.10.1 and now it seems to work.

I haven’t done proxy etc settings yet but I don’t expect any problems there.

Hello,
thanks for your guide.
At the end, were you able to use alexa with a private server?
Thank you.

Hi Flavio, the android App work without recompile anything. I setup my own cloud with google Firebase.

Hi All

I had to change my account from US to AU, as a result ive lost all my routines. I reset all Echo devices, readded them and relinked the openhab development skill as im using a private cloud instance of OH2.

It cant find any smart home devices, any thoughts? :frowning:

Same problem… I configured notifications for android device through Google Firebase and everything is going well, but I have problems with iOS notifications. I have Apple developer account and I have the certificates generated and configured in config.json (section apn).

When I start the cloud service, all the logs look good but the connection to APN does not show any message. I Edited the aps-helper.js file to show some log (logger.info) and the module loads but apparently no function inside the module is loaded.

And trying in various ways even doing an upgrade of the module node-apn but still does not work. It seems that something is wrong in the code.

Has anyone tried to use notifications from iOS?

Hi All

Trying to setup this up on another machine now, far out its crazy!!!

Anyway, NGINX working, SSL setup, Domain Setup, Oh2 Cloud private setup.

I register an account using the UUID/Secret but it says OFFLINE.

My mobile app cant connect either, it says ‘unable to resovle host undefined’ presumably because its showing OFFLINE in the webpage

Any suggestions wise ones? my eyes are going square! The day OH2 release a private cloud version of this the better. It shouldnt be this hard or complex. A notifciation worked just find via GCM.

Some logs:


kris@oh2dev:/var/www/openhab-cloud$ cat /var/www/openhab-cloud/logs/openhab-cloud-2019-02-14-process-3000.log
2019-02-14 03:54:03:033 info: openHAB-cloud: Backend service is starting up...
2019-02-14 03:54:03:033 info: openHAB-cloud: Backend logging initialized...
2019-02-14 03:54:03:033 info: openHAB-cloud: Initializing XMPP connection to GCM
2019-02-14 03:54:04:044 info: openHAB-cloud: Connecting ro Redis at 127.0.0.1:6379
2019-02-14 03:54:05:055 info: openHAB-cloud: Mailer will emulate sending in development environment
2019-02-14 03:54:05:055 info: opneHAB-cloud: Trying to connect to mongodb at: mongodb://127.0.0.1/openhab?poolSize=100
2019-02-14 03:54:05:055 info: openHAB-cloud: Scheduling a statistics job (every 5 min)
2019-02-14 03:54:05:055 info: openHAB-cloud: IFTTT is configured, app handling IFTTT capabilities...
2019-02-14 03:54:05:055 info: openHAB-cloud: express server listening on port 3000
2019-02-14 03:54:05:055 info: openHAB-cloud: Redis connect response: OK
2019-02-14 03:54:05:055 info: Redis is ready
2019-02-14 03:54:05:055 info: openHAB-cloud: Successfully connected to mongodb
2019-02-14 03:54:09:099 info: openHAB-cloud: GCM XMPP connection is online
2019-02-14 03:54:51:5151 info: openHAB-cloud frontend is shutting down from SIGINT
2019-02-14 03:56:49:4949 info: openHAB-cloud: Backend service is starting up...
2019-02-14 03:56:49:4949 info: openHAB-cloud: Backend logging initialized...
2019-02-14 03:56:49:4949 info: openHAB-cloud: Initializing XMPP connection to GCM
2019-02-14 03:56:49:4949 info: openHAB-cloud: Connecting ro Redis at 127.0.0.1:6379
2019-02-14 03:56:50:5050 info: openHAB-cloud: Mailer will emulate sending in development environment
2019-02-14 03:56:50:5050 info: opneHAB-cloud: Trying to connect to mongodb at: mongodb://127.0.0.1/openhab?poolSize=100
2019-02-14 03:56:50:5050 info: openHAB-cloud: Scheduling a statistics job (every 5 min)
2019-02-14 03:56:50:5050 info: openHAB-cloud: IFTTT is configured, app handling IFTTT capabilities...
2019-02-14 03:56:50:5050 info: openHAB-cloud: express server listening on port 3000
2019-02-14 03:56:50:5050 info: openHAB-cloud: Redis connect response: OK
2019-02-14 03:56:50:5050 info: Redis is ready
2019-02-14 03:56:50:5050 info: openHAB-cloud: Successfully connected to mongodb
2019-02-14 03:56:51:5151 info: openHAB-cloud: GCM XMPP connection is online
2019-02-14 03:57:50:5050 debug: openHAB-cloud: Checking for offline openHABs (0)
2019-02-14 03:57:50:5050 debug: openHAB-cloud: Checking orphaned rest requests (0)
2019-02-14 03:58:50:5050 debug: openHAB-cloud: Checking for offline openHABs (0)
2019-02-14 03:58:50:5050 debug: openHAB-cloud: Checking orphaned rest requests (0)
2019-02-14 03:59:50:5050 debug: openHAB-cloud: Checking for offline openHABs (0)
2019-02-14 03:59:50:5050 debug: openHAB-cloud: Checking orphaned rest requests (0)
2019-02-14 04:00:00:000 info: openHAB-cloud: every5min statistics collection job started
2019-02-14 04:00:00:000 info: openHAB-cloud: every5min statistics collection job finished
2019-02-14 04:00:38:3838 info: openHAB-cloud frontend is shutting down from SIGTERM
kris@oh2dev:/var/www/openhab-cloud$

Hi Pasi
how did you downgrade your node version? I too cannot get this working and its driving me crazy.

Hi All

has anyone got the email function working on this to have password resets sent to you? I cannot get it working.

A suggested configuration would be great!

Thanks

Hi,
I followed steps documented here https://heathpaddock.com/2017/02/02/making-amazon-echo-alexa-sing-to-openhab2/ and was able to use authentication that is stored in variable userpass ( userpass is variable containing username, password in file config.js located in directory openhab-alexa ).
Now I want to use oauth2 with an Amazon account.
Thus I uploaded openhab-alexa again after putting userpass into a comment.
I made sure that account linking is configured etc. ( following several documents ).
I disabled the skill in the app on the phone and enabled it again.
Logged in via amazon web page on the phone.
I tried to access a switch but access to the items file is denied.
It looks like the authorization does not work and access is not granted.

34.243.201.211 - - [11/Mar/2019:22:26:44 +0100] "GET /rest/items/ HTTP/1.1" 401 22 "-" "-"
34.243.201.211 - - [11/Mar/2019:22:26:44 +0100] "GET /rest/items/ HTTP/1.1" 401 22 "-" "-"
34.243.201.211 - - [11/Mar/2019:22:26:44 +0100] "GET /rest/items/ HTTP/1.1" 401 22 "-" "-"
34.243.201.211 - - [11/Mar/2019:22:27:50 +0100] "POST /rest/items/Yamaha_Mute HTTP/1.1" 401 22 "-" "-"

While logging in to amazon web page I was not redirected to the private cloud instance.

Do you have any hint what I might have done wrong ?