Playing around with Amazon Echo (technical interface discussion)

I am not sure if this is the URL path your are looking for @luma, but I know this works for the UBI.

.http://graph.api.smartthings.com/api/smartapps/installations/ INSTALL CODE /switches/ DEVICE ID /level/ ## ?access_token=ACCESS TOKEN

“***##***” is the value between 0% and 100%.

2 Likes

This yields the following error:

{"error":true,"type":"SmartAppException","message":"Not Found"}

I’m using the standard REST Endpoint Smartapp, simply modifying one of the existing URLs with the changes you suggest. Is there a SmartApp that would be associated with your UBI integration or are you using the existing exampleOauth.php app?

It is not associated with UBI. It’s just one of the Rest Endpoint steps/apps I used from this site. When fully written out, it just an url that turns on/off or set specific levels when clicked to open. Just a note there is no “.” before my http example. I need to add it so the forum would not great a false link.

Are there other REST endpoints? Do you have a link to the specific one you used?

I don’t think that SmartApp has mappings included for dimming, but I’m not sure. The sample web interface only shows on/off/toggle.

Please post a link to the source code of the SmartApp that is providing your specific REST-API Endpoint mappings.

Oauth and Notifications

This is the post I used to get my endpoints. Also once I had my Install code/device ID and access token, I could turn lights off/on/toggle by URL. I found an older post, that I cannot find now, that showed I would add “/level/10” between the device ID and “?access_token”.

That Topic thread does not, as far as I can tell, provide a SmartApp with generic Endpoint mappings all switches including dimmers.

Y’all don’t seem to be on the same page.

Looks like we are. I just know once I got through those steps, I had my install code,.device code and access code, I could get my list of urls to control switches/lights and found a way to dim them at set levels.

I traced the example links you referred to, and they have no mappings{} for setting “level”.

They list these, just as an example in the Documentation.

mappings {
  path("/switches") {
    action: [
      GET: "listSwitches",
      PUT: "updateSwitches"
    ]
  }
  path("/switches/:id") {
    action: [
      GET: "showSwitch",
      PUT: "updateSwitch"
    ]
  }
}

There may be a shared SmartApp installed somewhere that has a “level” endpoint (and, goshdarnit, it’s easy enough to create one…!), but the URL you provided (and that @luma references…) does not appear to provide it.

The example was probably based on Andrew Urman’s simple switch only code (i.e., it supports commands “on, off, toggle”, NOTlevel”).

Like I said before I cannot find the post that recommended adding the “/level/##?”. I think it may be from the previous version of this site. I have old links that no longer work and takes me to the current Community Home page now. The link I posted previous, was one I followed when the previous posts I used were no longer accessible.

For my needs once I got the url for a switch for on/off/toggle, I manually edited the url to control the dimming level. That works for me. I originally used on/off/toggle to control switches through UBI, before Smartthings integration, Once I found the level trick I was able to verbally set any level with one command. I even added the urls in my Pebble Watch with an app to control/dim switches…

Does it still work now? Can you share the URL without the API key, perhaps? You may be pointing to a different version of the SmartApp.

Good point here. I was worried about this myself, however, I never agreed to any EULA imposed by Philips nor registered to view their api documentation (and agreeing to their terms.) I implemented only what was required to get the echo to work

IANAL

With respect to Philips I can take down the project if requested.

2 Likes

Here is the url without the API key.
http://graph.api.smartthings.com/api/smartapps/installations/dd9677bf-354c-48e8-8a33-d2ca5e4e247c/switches/09235b47-637d-4c54-87be-10ba8c761edb/level/50?access_token=

The unedited link currently dims my light to 50%, I checked before posting.

Looking at back at my notes, I think currently the smart app I am using to get my Endpoint installation code is “Thing Layer” by Jody Albritton.

2 Likes

Perfect… This clears everything up, actually, Thank-you!

Jody wrote a SmartApp that you provided a shared link to, and I think this GitHub is probably up to date as well. This SmartApp has a dimmer level Endpoint…

https://github.com/jodyalbritton/smartthings/blob/master/thingLayer.groovy

[quote=“kevintierney, post:160, topic:14887”]
Trying to figure out why the node app can’t get back switches. It’s getting back

{“error”:“true”, “type” : “Unauthorized”,“message” : “Full authentication is required to access this resource”}

I added a console log for the request and get
[/quote]weird. I’m buried in boxes (mid move, gotta complete by Sunday) so I can’t really look at this right now, but that would explain why the Echo doesn’t find any bulbs.

This means I likely did something horribly stupid when I quickly cleaned up the code for the node app. I have the raw code (working in my install) which I can diff up vs the one I posted to github. But that’s gonna be in June (this is hell moving week for me.)

If it helps to know… The Java version has been working fine on my Beagle Bone for a week now, so while I’m interested in the Node.js version, it’s definitely not urgent.

I’m likely too busy until … Sunday? … to do more research, though you’ll probably see comments here from me from time to time.

  • If you want to walk through installation or minor debugging of the Java version with me, @terryhonn or @luma, or anyone; please private message me.

Heck: It may be worth splitting this Topic into two threads: One for the Java, one for the Node; though, ideally, they could easily run against the same SmartApp Endpoints.

(@Ron’s Java has pretty smooth authentication steps built in, which is handy if you’ve not done manual authentication steps worked out.)

ttyl.

Finally got settled in new house with server up, Echo up, and ST up. I used the code posted to gitub, put in my bearer and access uri, and the Echo detected the emulator and found my lights. Not sure why it’s not working for you at this point…

A couple of random thoughts which may or may not apply:

Echo expects to get an answer every time it wants to send a command. So if the receiving “hub” goes into power-saving Mode or sleep mode, echo won’t get a response and may say that the end device cannot be found when in fact it is the intermediary hub that is not responding.

This is been a known problem with voice recognition for other protocols in both Windows and The versions of android that have the power saving feature.

A completely separate issue has to do with range extenders for Wi-Fi. If the Echo is on one branch of your wifi and the “hub” is on another, you will see sporadic failures to communicate, particularly with WiFi 5ghz. This has to do with channel hopping, which is done to keep the signal strong, but paradoxically can cause branches on either side of an extender to get out of sync. And again, echo’s assumption is there will be 100% success in finding the hub, so there’s no retry built in.

Again, neither of those may apply to the current problems being discussed, but I just thought I would mention them as they are common in other voice control protocols.

So the first question: is the host for your “hub” using any power saving or sleep features?

Second question: are you using any range extenders on your WIfi network?

Has anyone else succeeded in getting the ThingLayer SmartApp to work along with the amazon-echo-ha-bridge? I’m struggling to get this endpoint going so I can issue dimming commands. I posted the step-by-step process for deploying the SmartApp here but it got pulled for being off-topic. I’m not sure where to discuss troubleshooting this, as I’m not using the SmartApp as intended and I don’t think I should be bugging the author for off label use.

Really, I just need an endpoint that will allow dimming because the standard REST endpoint SmartApp linked above doesn’t.