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

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 ?

In the meantime I solved it.
Following steps described on the previous described webpage works for basic authentication ( userpass set in openhab-cloud ) but not for oauth2 authentication.
Besides that when acount linking is defined authorization URI and access token URI need to point to your openhab-cloud server ( https:///oauth2/authorize resp. https:///oauth2/token ). Set the scope to your client-id.
To add the required information into the mongodb I used the script addoauth.js from this post: Setup your own openhab-cloud (myopenhab) server/instance

Hi All

Can multiple instances of OpenHab cloud be run on the same box? Ie 3000, 3010, 3100

etc

It appears there are MANY references to port 3000 in the code.

hey, whenever I try to run an authentication test in the ifttt api platform I get this error

    Retrieve user information
Could not get user info, please try again.

ideas?

This looks like because that you could not either log in or receive a response from the private server.

Could you please confirm you followed these steps?

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

yes, the issue persists

Could it be me using the development version of the config?

@anjana55

Could you check your nginx error log while this test runs and see whats causing this?

tail -f /var/log/nginx/openhab-cloud.org-error.log

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

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