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

myopenhab
myopenhaborg
openhab-cloud
Tags: #<Tag:0x00007f1e6e217648> #<Tag:0x00007f1e6e217440> #<Tag:0x00007f1e6e2172d8>
(Anjana) #142

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?

0 Likes

(Pedro Garcia) #143

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.

0 Likes

(Pasi Kettunen) #144

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.

0 Likes

(Anjana) #145

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

0 Likes

(Anjana) #146

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

(Pasi Kettunen) #147

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.

0 Likes

(Lucarui) #148

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

0 Likes

(Gonzalo Echevarria) #149

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

0 Likes

(Kris K) #150

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:

0 Likes

(Gonzalo Echevarria) #151

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?

0 Likes

(Kris K) #152

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$

0 Likes

(Kris K) #153

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

0 Likes

(Kris K) #154

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

0 Likes

(Wolfgang Schlueschen) #155

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 ?

0 Likes

(Wolfgang Schlueschen) #156

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

0 Likes

(Kris K) #158

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.

0 Likes