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

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

https://heathpaddock.com/2017/02/02/making-amazon-echo-alexa-sing-to-openhab2/

@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?

@digitaldan Managed to get this working. Looks like the certs were the issue, replaced them and its now working nicely.

Question, if you have multiple OH2 instances, and multiple OH2 Cloud instances, is it just the cloud instance/config.json that keeps the notifications seperate? ie what stops one instance sending alerts to another? Im a little confused on how myopenhab.org does this

Not sure i understand. your OH instance uses the cloud binding to talk to a OH Cloud instance, the host is configured in the binding and defaults to myopenhab.org, but can be set to your own instance. Notifications sent to that OH Cloud instance (host) will use whatever GCM/APNS gateway and cert you have configured on that cloud instance, in turn those need to be coordinated with the mobile build you have registered for notifications.