I wanted to follow up and say this is awesome. I used your scripts, changed anything “dexcom” to “skydrop” - and ran it. Now I can use HTTP GET and POST commands to control my sprinklers.
I don’t know if it’s BETTER than the wifi app from skydrop… but I’m always happy to get another thing consolidated into OpenHAB.
Now to fiddle with the skydrop API to see if I can make it useful.
Thanks for your tutorial. Unfortunately I got the following bug, see my logs:
2019-01-16 01:09:12.778 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘Poll Dexcom for data’: The name ‘Dexcom_EGVS_Poll’ cannot be resolved to an item or type; line 125, column 3, length 16
Before spending too much time on this, what is your end goal? I am because of it is specifically to get Dexcom readings, the deejay betwen the readings and the ability to pull them through this API makes it pretty much useless in a home automation context. If that is your goal, you will be better off setting up Nights out which has a much simpler API. I’ve posted a tutorial due integrating it with OH as well.
If you are just trying to get OAurh working, then the specific error means you are missing that Item. in on my phone and about to go to bed so it will be tomorrow veggie I’ll be able to remember what that item is for.
Thanks a lot for your reply rikoshak! Can you send me a link to the tuturial you mentioned - I was not able to find it by googling myself.
My final goal is to create a solution to access a RestAPI which uses OAuth2. Currently I am figuring out if this approach can outperform the idea of developing a full fledged binding, which takes much more time in my opinion. Moreover the binding won’t be useful for third parties, as far as I can guess. What do you think?
Related to the Error-Message: I guess your tutorial has an error in it, because before I can start the call, my log messages tell me, that I need to define the Item somewhere. Can you check, if the tutorial runs on your environment? I guess, that people will try to use it and it is hard and maybe frustrating if the code won’t run. Thanks for offering the tutorial, anyway and maybe thanks in advance for your verification, if this stuff runs in your openhab-instance.
The tutorial is missing the Dexcom_EGVS_Poll Item. It is just a Switch.
If you are looking to interact with a service that requires OAuth, the appropriate approach really is a new binding. This tutorial is just intended to be a “plan B” in case a binding is not feasible, or as a way to prototype the interactions with the interface before writing a binding.
Problems were that it only worked with a client credentials grant, the oauth token url needed a trailing slash, and that the API itself wants PUT requests instead of GET. I think the whole authcode callback thing was not needed, and that was the only part that worked straight away
But when I forget my frustration and am in an optimistic mood, I might try to leverage this html callback method to get ring events into OH.
I think the reason was that it was impossible to do without my own vserver on the internet. I was hoping I would be able to do it trhough myopenhab or maybe with a LAMP webhosting package I already use. But I wasn’t able to.
Please read some of the later posts. Dexcom throttles the data. Unless you have a use for driving your home automation using blood sugar readings that are 30 minutes or more old the API isn’t going to be useful for you. You would be better off setting up Nightscout and either populating it from CLARITY or using xDrip or Spike on iOS. I’ve shown how to do most of that in NightScout openHAB Integration.
This whole process used to work perfectly but not anymore.
when working
Google assistant
select openhab
GA redirects to an Oauth2 screen
fill in credentials
all devices from openhab are visible in google assistant
i unlinked my setup (because i could not sync devices anymore)
now when i do the same i get
Google assistant
select openhab
NO OAUTH2 redirect screen anymore
instead is states that Openhab is connected
then after 5 seconds it states "something went wrong, please try again.
i t looks like google is not even trying to reach openhab anymore and does not get the oauth2 screen anymore
who is reponsible for the Openhab service from within google because i think something is messed up(probably after a recent update in june/juli)
could be that everything still works for everybody but not when you unlink and link again
@rlkoshak I have been using your http request functions quite a bit for other purposes than OAuth, so many thanks for sharing. Anyhow, maybe as an addition you could also implement exceptions for timeout, host not found etc that you can catch - as this is something that I experienced while using it for other services. This would make it more complete?
There is a whole lot about the code in the OP that is out of date. It’s not and never was intended to be production code. It’s just an example. So I’m not really inclined to spend any time updating it or making it bullet proof. Even the way the lambdas are defined is out of date.
Furthermore, I’m not sure that Rules DSL is a good approach for doing something like this any longer. Were I to write this again (which might be the case in the not too distant future) I’d use Jython rules which will allow a much more reasonable coding approach.
Hey @rlkoshak
3 years later I also stumbled over this.
As always really good write Up.
As you say it is Out of Date… I think such a approach is of high value actually.
Many want to Connect to another API but have Not the Skill to come Up with a real Binding.
But If there would be an “official” way how you can Talk to a external Rest API via myopenhab this would be a Low Code solution to many?