Hi,
I’m using alexa skill to interact with my openHAB installation via myopenhab.org. It works great but due to current limitations of the smart home alexa model, I’m not able to get all the answers I’d like from my smart home. For example, AFAIK there is no way to get current power consumption or you need to implement workarounds.
One of the workarounds I used was to attach a rule to the LastVoiceCommand event to parse the question and TTS out a speech with the current power consumption. But alexa doesn’t stop processing the command so what I get as a reply is something like “I don’t know…” interrupted and then “Your power consumption is currently 2.3 kW”. Not nice.
So - even if I know nothing about node.js - I tried to write my personal alexa skill in order to ask questions like “Alexa, ask Mister John what the current power consumption is”.
So my problem now is that I’m not able to perform OAuth 2 authentication to myopenhab.org as I’m not sure what client ID / secret pair I should use to authenticate the skill.
Is this Client ID / secret pair something that has to be stored in myopenhab.org? Any way to create one?
I think this not related to the request coming from an alexa skill, it could be any other UI on the web trying to access the apis,
Check if OAuth2 using just OH Rules and myopenhab.org helps.
Alternatively you may try to access the REST API to read out your item. Authentication can be done by using email address and your password. I am doing that to access my own openhab-cloud instance.
Could you describe a bit more in detail what you tried and what does not work ?
In case you login manually to myopenhab instance do you get access to the /rest/items via browser ?
What also should be possible is to run an alexa skill locally e…g. on openhab instance and access the /rest/items on your local server.
mmm, it works from my raspberry but it doesn’t from Windows command line (my Win pc is in the same LAN as my RBPI). I get “Unauthorized” from the Windows command line.
I also tried this node.js script in the alexa skill
Try to use double quotes ( " ) instead of single ( ’ ) quote on windows command line.
I just copied the example from my Linux instance without taking into account that the single quotes could be a problem on windows system…
I found this topic during a search on OAuth2 and myopenhab. The topic of my question would be exact the same, so I decided adding my question here. If creating a new topic is the prefered way, please let me know. “Keep the community clean” can mean both.
Problem description
I stared a redux-react application to get practice writing react components. The application works fine, including live updates with the event source. The first version is just running in my network, so no auth is required. The next step is moving the application into the internet. Using the basic-auth works fine and everything seems nice. But I think it is not. To make basic-auth requests, I need to store my passord as clear text in a cookie. This is Ok for a toy example but to practice writing good code it is a shame.
As I understand myopenhab, the project provides an OAuth2. Which means, I can login and store the session token for other requests.
Question
My question in mind is: Is it possible to register my own applicaiton in myopenhab and login in with OAuth2 to use the token for other requests? A more open question is: Is the intended soltion the way to go?
Thank you for reading this and perhaps support me with an answer.
Kind regards
Jan
@JanK is talking about the OAuth2 support in openHAB Cloud / myopenhab.org which I seem to remember can also work with OAuth2 (there’s an Applications menu), but I have no clue how to register one. Maybe @digitaldan or @MARZIMA can elaborate.
@Bruce_Osborne I also read about autherization in OH3. But you wrote that only Admins require a login. But well, an itegration to OH3 would be a nice solution for my problem. Then I have to switch priorities and first upgrade to OH3 before continuing my project.
@ysc The OAuth2 support in myopenhab is what I was looking for because it is available today. My account in myopenhab shows no application and no button to add one. I already went one step depper into the search and had a look into the code of myopenhab. I found code and URLs for OAuth2 including the database requests for the scope and client id. What I am still looking for is code to insert something into the database.
Untill further ideas I will update OH to v3. This is obvisly the best plan anyway. Perheps I find a way to use this system. All users of my own little app are trustworthy and can get admin access if needed. At least it is an improvment of storing the password in a coockie.
Correct, You can use OAuth2 in myopenhab. But you need to configure it in the mongo database. We give 3rd Parties e.g. Google Assistant access by that way too.