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

54.164.35.61 - - [03/May/2019:15:19:21 +0300] "POST /oauth2/token HTTP/1.1" 200 309 "-" "IFTTT-Protocol/v1"
88.223.78.20 - - [03/May/2019:15:19:57 +0300] "GET /oauth2/authorize?client_id=gocloud&redirect_uri=https%3A%2F%2Fifttt.com%2Fchannels%2Fgocloud%2Fauthorize&response_type=code&scope=ifttt&state=RytGZllhNkFpR2xjeStYSHZDVHdqcXhTRzlob1dDSGdYZWE1dkc2N3M1N0lMQUlOSmVaMWVkK3JaV0wyeG1QUndnS3ZUVS8veTlsUlkwc2U2QXdSc3c9PS0tOHRsUng5dG1LWGNVSUtaNFYwWG53UT09--9d0a59d70814586c498df2f08709380a01400f32 HTTP/1.1" 200 3737 "https://platform.ifttt.com/services/gocloud/publish/activation?activation_test_callback=https%3A%2F%2Fplatform.ifttt.com%2Fservices%2Fgocloud%2Fapi%2Fauthentication_test" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36"
88.223.78.20 - - [03/May/2019:15:19:58 +0300] "GET /oauth2/js-plugin/jquery-cookie/jquery.cookie.js?_=1556885997743 HTTP/1.1" 404 171 "https://ocloud.ginetas.lt/oauth2/authorize?client_id=gocloud&redirect_uri=https%3A%2F%2Fifttt.com%2Fchannels%2Fgocloud%2Fauthorize&response_type=code&scope=ifttt&state=RytGZllhNkFpR2xjeStYSHZDVHdqcXhTRzlob1dDSGdYZWE1dkc2N3M1N0lMQUlOSmVaMWVkK3JaV0wyeG1QUndnS3ZUVS8veTlsUlkwc2U2QXdSc3c9PS0tOHRsUng5dG1LWGNVSUtaNFYwWG53UT09--9d0a59d70814586c498df2f08709380a01400f32" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36"
88.223.78.20 - - [03/May/2019:15:20:08 +0300] "POST /oauth2/authorize/decision HTTP/1.1" 302 586 "https://ocloud.ginetas.lt/oauth2/authorize?client_id=gocloud&redirect_uri=https%3A%2F%2Fifttt.com%2Fchannels%2Fgocloud%2Fauthorize&response_type=code&scope=ifttt&state=RytGZllhNkFpR2xjeStYSHZDVHdqcXhTRzlob1dDSGdYZWE1dkc2N3M1N0lMQUlOSmVaMWVkK3JaV0wyeG1QUndnS3ZUVS8veTlsUlkwc2U2QXdSc3c9PS0tOHRsUng5dG1LWGNVSUtaNFYwWG53UT09--9d0a59d70814586c498df2f08709380a01400f32" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36"
54.145.70.9 - - [03/May/2019:15:20:12 +0300] "POST /oauth2/token HTTP/1.1" 200 309 "-" "IFTTT-Protocol/v1"

the error.log didn’t produce anything, here is my access.log file

I get another entry accessing “/ifttt/v1/user/info” right after the last entry in your log:

[03/May/2019:16:11:44 +0000] “POST /oauth2/token HTTP/1.1” 200 309 “-” “IFTTT-Protocol/v1”
[03/May/2019:16:11:45 +0000] “GET /ifttt/v1/user/info HTTP/1.1” 200 118 “-” “IFTTT-Protocol/v1”

Have you ever tried calling openHAB API through URL to see if you get user information in a jason formatted string? This is just to confirm your openHAB cloud is properly configured and user information is presented in the right format.

this is what i get

{"errors":[{"message":"Authentication failed"}]}

This is expected because you have to POST oauth2 token at /oauth2/token before this step. Wondering if IFTTT is not calling this step (as per your log) is because some error in posting token.

Just to iron out your suspicion on development configurations, here’s what my config.json file looks like:

{
    "system": {
      "host": "my.domain.biz",
      "port": "443",
      "protocol": "https",
      "logging": "info",
      "subDomainCookies": false,
      "muteNotifications": false
    },
    "express":{
      "key" : "some express key"
    },
    "apn" : {
      "gateway": "gateway.push.apple.com",
      "cert": "certs/aps/aps_production_cert.pem",
      "key": "certs/aps/aps_production_key.pem",
      "passphrase": "passphrase"
    },
    "gcm" : {
      "jid": "something@gcm.googleapis.com",
      "password": "password"
    },
    "ifttt" : {
      "iftttChannelKey" : "IfTTTchaNneLKey",
      "iftttTestToken" : "ReaLLyLonGIFtTttESTtOkeN"
    },
    "mail": {
      "host" : "smtp",
      "port" : 465,
      "user" : "foo@bar.com",
      "pass" : "password"
    },
    "mongodb": {
        "hosts": ["127.0.0.1"],
        "db": "openhab"
    },
    "redis": {
        "host": "127.0.0.1",
        "port": "6379"
    },
    "mailer": {
        "host" : "smtp",
        "port": 465,
        "secureConnection": true,
        "user": "foo@bar.com",
        "password": "password",
        "from": "openHAB Cloud <your@email.address>"
  },
    "legal": {
        "terms" : "",
        "policy": ""
    },
    "registration_enabled": true
}

Hi, everything works fine till npm install. After making changes to config.json and sudo node app.js i get 502 bad gatway when i visit the domain. Need your help with this. Thanks

These are my notes:


openHAB Cloud install

sudo apt-get update
sudo apt-get upgrade

wget https://nodejs.org/download/release/v7.10.1/node-v7.10.1-linux-x64.tar.gz

sudo mkdir -p /opt/nodejs

sudo tar -xvzf node-v7.10.1-linux-x64.tar.gz -C /opt/nodejs/

cd /opt/nodejs

sudo mv node-v7.10.1-linux-x64 7.10.1

sudo ln -s 7.10.1 current

sudo ln -s /opt/nodejs/current/bin/node /usr/bin/node

# This is to verify the node version

node -v

# It should say 7.10.1 now

# After that just clone the repo

sudo apt-get install build-essential redis-server mongodb nginx python git certbot
cd /var/www
sudo git clone https://github.com/openhab/openhab-cloud.git OH2-Cloud
sudo chmod 777 OH2-Cloud/

cd OH2-Cloud/

npm install (if this fails due to write permissions, sudo npm install) (You may need to run

sudo apt install npm)
1 Like

Hi, I am beginner. After following ryandetzel write up still i am unable to get my cloud instance running. If any one got a write up on how to build it from scratch on AWS or Scaleway kindly share it as it would be of great help. Thanks

the ifttt api url was missing, but I still get an error, check out more at

got it working, how do i copy the applets from the openhab2 service to my custom one?

Thanks a lot. That got my openhab instace running. But not able to use alexa skill. Is there any write up on alexa skill implementation with private cloud instance.

Yes, here

@hww3 Hi Bill

I have a developer account and the recomplied app, can you tell me what is needed in the config.json for apple notifications? I believe the cert/key file go onto the openhabcloud server under /certs. my file is:

 "apn" : {
      "gateway": "gateway.push.apple.com",
      "cert": "./certs/aps/aps_production_cert.pem",
      "key": "./certs/aps/aps_production_key.pem",
      "passphrase": "123456"
    },

I added the files into the certs/aps directory, reconfigured the config.json but i see this after restart openhabcloud

I can see the IOS app registered in OH2 cloud, but when i send a test notification it crashes openhab cloud

0|IHP Cloud  | TypeError: Cannot read property 'key' of undefined
0|IHP Cloud  |     at validateCredentials (/var/www/IHP-Cloud/node_modules/apn/lib/credentials/validate.js:6:52)
0|IHP Cloud  |     at /var/www/IHP-Cloud/node_modules/apn/lib/connection.js:163:5
0|IHP Cloud  |     at _fulfilled (/var/www/IHP-Cloud/node_modules/q/q.js:854:54)
0|IHP Cloud  |     at self.promiseDispatch.done (/var/www/IHP-Cloud/node_modules/q/q.js:883:30)
0|IHP Cloud  |     at Promise.promise.promiseDispatch (/var/www/IHP-Cloud/node_modules/q/q.js:816:13)
0|IHP Cloud  |     at /var/www/IHP-Cloud/node_modules/q/q.js:624:44
0|IHP Cloud  |     at runSingle (/var/www/IHP-Cloud/node_modules/q/q.js:137:13)
0|IHP Cloud  |     at flush (/var/www/IHP-Cloud/node_modules/q/q.js:125:13)
0|IHP Cloud  |     at _combinedTickCallback (internal/process/next_tick.js:131:7)
0|IHP Cloud  |     at process._tickCallback (internal/process/next_tick.js:180:9)

@digitaldan any suggestions?

thanks

That seems more or less correct. The configuration gets used ~line 4 of notificationsender/aps_helper.js…

apnConnection = new apn.Connection(app.config.apn);

app.config is an object representing the contents of your config.json. I suspect maybe there’s a problem with the config file, perhaps? You could possibly put some logger statements in that file to probe whether the config file contains what you think it should contain.

Bill

1 Like

Hi Bill have you got this to successfully work?

When i had no ./ infront of the cert files, it couldnt find the files. Id have no idea what im doing changing logger files

I’m running a pretty old version of the openhab-cloud app… or at least I was until I scrapped the vm last week.

I put the full path to my files in the configuration file, but that’s just a personal habit. That you’re getting errors about not finding the apn config section, I think something is going wrong before that point.

Here’s the documentation for the version of node-apn that is being used:

I think you could inject the settings directly into line 4 of aps_helper.js to bypass any potential config handling problem… just to narrow down where the problem might actually be.

How would I put those direct into the aps-helper.js?

Im not sure what to place in the file.

Exactly the same issue


var options = {
      "gateway": "gateway.push.apple.com",
      "cert": "/var/www/IHP-Cloud/certs/aps/aps_production_cert.pem",
      "key": "/var/www/IHP-Cloud/certs/aps/aps_production_key.pem",
      "passphrase": "123456"
};
var apn = require('apn'),
    app = require('./../app'),
    logger = require('./../logger'),
    apnConnection = new apn.Connection(options);



@digitaldanls
@MARZIMA

Any thoughts guys?

Hi @dastrix80 , I see you have opened issues on our ios project, cloud project, and asking here as well. Lot of messages in my inbox this am :slight_smile:

Just to be clear, are you building and signing the IOS app with your own keys? In order to support apple PNS you need to create your own app profile in the apple developer portal and generate signing certificates with APNS permissions. You then need to generate APNS keys, and export the PK12 file as a cert and key (if i’m remembering correctly) and use those in your own custom cloud install.

Nm, i see that you are doing this. I’m not sure why you are getting that error, it looks like it should be working.

1 Like

Hi @digitaldan haha I did! Sorry!

Yes, I am. OK, that sounds like exactly what I’ve done but it seems there is some kind of cert issue as I’m getting openssl errors when connecting to the Apple gateway.

Ill keep working on it! but I’m glad you’ve confirmed what im doing is correct.

How does this work for multiple openhab cloud instances using the same app? I assume each instance just needs another copy of the cert, right?