[DEPRECATED] A TRUE Smart Home...HAS JARVIS!

:frowning: that’s to bad. I couldn’t find an alternative that worked as well as Jarvis does. I sure hope they can fix this issue.

Eric,

I started thinking about how to do this as well, and came up with a question…specifically about your implementation of PushBullet. It appears you only use PushBullet as the ‘glue’ to get to ITFFF so you can control the SmartThings devices, correct? It would seem you could replace this with an app and some get/post http code that would ‘push’ directly to the SmartThings cloud, similar to how SmartTiles or Simple Rules builder works. I know you mentioned you are not a coder, but I copied @625alex and @JoeC on this as they are the creators of the apps mentioned.

Alex/Joe,

I just started reading up on web to SmartThings interfacing and believe I understand how the basics on how it is supposed to work, but wanted to verify with you both of your thoughts on how this might be implemented. I envision a simple SmartThings app that allows you to choose which devices can be accessed via the web. The more difficult part for me to understand is the http code that is required to ‘trip’ those devices…I know would need to use OAuth to accomplish this, but from there I don’t quite know what is next.

In addition, Eric’s example in this thread, I would see his EventGhost sending a ‘macro’ to a web page (PHP? Java?) with some sort of parameter that would trip the device. Since I am familiar with get/post, I see something like this “http://webserver.com/code.php?device=Kitchen&command=off”. However, I assume you wouldn’t want to call a web page and instead do some sort of curl command?

Can either of you give some pointers on how this might work? Also, since you already did a lot of the heavy lifting with getting this to work would you be interested in starting off some base code that has simple functionality? I could see this being used heavily by others as a ‘template’ to get them started building web-to-SmartThings interfaces.

The best place to start is to look through Web Services Guide. It shows you how to create endpoints. Once you obtain the endpoints, you plug them into any other software you want to interface with SmartThings. You can trigger the endpoints directly, there is no need for intermediate layer.

SmartTiles is just an endpoint on steroids. The actual control of devices happens once mappings redirects execution to a method. In that method you could do anything you need.
This is the place in SmartTiles where the magic happens.

OAuth is only used for authentication, it’s not an important part of this process. If it’s easier, you could manually authenticate by calling createAccessToken() in your SmartApp. It will assign a new access token and save it in state.accessToken, which you then print in the logs, for example.

I’m not sure what exactly you are trying to achieve, but there are many, many creative ways to do it.

2 Likes

Ok…I will create a small app (one switch) and see if I can build the interface. The documentation was not as clear as I would have liked, but will get through it.

Are you open to questions (here or PM) to assist if I run into some issues?

Sure, I will give you a hand when I can. You may want to open another thread in case anyone else wants to jump in.

Ok…went through the intructions and was able to follow them until about about step 8 (http://docs.smartthings.com/en/latest/smartapp-web-services-developers-guide/implementation.html#developing-an-api-access-application) where I assume I will need to go onto my web server and write up some HTTP code…correct?

However, this is where I struggle with this…the use case will be as Eric outlined. There was be a local ‘server’ that holds the voice module, along with EventGhost which will intercept the voice commands and then issue a corresponding command out to the ‘cloud’. This may be a noob question, but can the web commands be sent without a browser…i.e. through a command line?

You can still do that via the browser’s address field:

Enter this URL https://graph.api.smartthings.com/api/smartapps/endpoints?access_token=f15f-c9c9-4206-bea3-34b298a using token obtained in step 7.

Yes, cURL for example.

Ok…cool…got past step 8! For step 9, I assume it is similar:

https://graph.api.smartthings.com/api/smartapps/endpoints?access_token=*token*/api/smartapps/installations/*device* and then something like “&command=on”

If that is correct then I am doing something wrong as I get a login prompt. Does the token and device need to be pulled for each session?

No, to make API calls, you use this url:
https://graph.api.smartthings.com/api/smartapps/installations/APP_ID/path?access_token="abcd"

This is the URL that was returned in step 8.

Is that the correct syntax? Specifically the ‘path’ piece? Using dummy data, here is what I got in step 7 and 8:

Step 7:
{
“access_token”: “AAAA”,
“expires_in”: 1576799999,
“scope”: “app”,
“token_type”: “bearer”
}

Step 8:
[{“oauthClient”:{“clientId”:“myclient”,“authorizedGrantTypes”:“authorization_code”},“url”:“/api/smartapps/installations/xxxx”}]

So, that would make step 9’s syntax:
https://graph.api.smartthings.com/api/smartapps/installations/xxxx/PATH?access_token=AAAA

If that is correct, then how to get toggle the device…is that a “&command=on” command?

I really appreciate you helping me through this!

This is correct.

In mappings closure of your SmartApp you define which method will be called when a PATH is hit.

You need to look at params to see what request attributes are coming in. For example, a command, it’s value and the target.

You may pass as many key/value pairs as necessary into your request using format: &key=value.

Ok…made some progress…when I put /switches?access_token=AAAA in I got the list of the switches I had listed in the app. So that is good…

To interact with the device, now that I have it’s ID, type, and name, can a simply HTTP request work or must THAT be framed within a PUT statement in code?

For reference, the code mappings are:

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

void updateSwitch() {
def command = request.JSON?.command
if (command) {
def mySwitch = switches.find { it.id == params.id }
if (!mySwitch) {
httpError(404, “Switch not found”)
} else {
mySwitch."$command"()
}
}
}

Would that mean if there is an HTTP command that would work I would frame it like this (Assume BBBB is the ID of the switch)

https://graph.api.smartthings.com/api/smartapps/installations/xxxx/BBBB?access_token=AAAA&value=on

Correct? I have tried a bunch of different combinations, but I either get an error or just the list of the switch again.

When you visit a URL via browser’s address bar, it’s a GET request. Your mapping for GET request is showSwitch.

I just realized that we completely highjacked this thread. Do you want to take it to PM or another thread?

I will PM you, but I think this was good discussing this here…this might help others.

Yes this is helpful so another thread would be useful.

If I get this working I will certainly share this as I believe this is a common question (or need).

Ok…got this working…the issues listed in this thread were mostly my doing…if you follow the instructions here: http://docs.smartthings.com/en/latest/smartapp-web-services-developers-guide/implementation.html#developing-an-api-access-application
to the letter, it will work up to a point. But, if you fail to understand it (like I did) and just copy and paste http code, it will install a old version of the IFTTT code and lead you in the wrong direction.

Basically, follow the directions, but make note of the places to put in OAuth and secret information from the App settings…

Bottom line, you CAN turn on/off lights with a single line of http code…so, before I hijacked this thread, would eliminate the need for IFTTT and PushBullet in Eric’s use case.

Gonna keep playing with this to see if I can create an app that can be this ‘glue’ between a voice interface and SmartThings.

I did figure out one trick with this. There is also a way to dim lights through HTTP. After the install or App ID use" /switches/DEVICE_ID/Level/LEVEL_#?access_token=ACCESS_TOKEN" Where “LEVEL-#” is a value between 0-100.

I think you’re misunderstanding what I was trying to accomplish with IFTTT and Pushbullet.

First of all, the idea is to have Jarvis be the center of it all, I wanted to have a smarthouse that could communicate with me, and jarvis did that for me. The reason for IFTTT is that IFTTT can connect to more things than just Smart Things, therefore, I wanted Jarvis to have access to everything IFTTT has access to. But the problem was, how do I get Jarvis to communicate with IFTTT? There’s no way to send a text from my computer and every option to do so was just ridiculously difficult. Then I found pushbullet and eventghost. You see, Eventghost can communicate with jarvis. So when I issue a command with jarvis, he creates an event in eventghost, which I can then create a recipe with Jarvis to communicate with IFTTT…but no, I still couldn’t communicate with IFTTT. The BEST way at the time was with email, which had a significantly slow response time for IFTTT. This made making a home security system very difficult.

That’s when the pushbullet plugin for eventghost comes into play, because pushbullet has the ability to send texts through your phone. Now I could make a recipe in eventghost, have it send an SMS from my phone to IFTTT’s phone number, I then create a recipe in IFTTT to say, “When the sms #lightson is recieved, THEN turn on all philips hue lights”.

I get that smart things can control philips hue, but smartthings has no control over say, logs I make, or my email, none of that stuff, and if it does, it’s much more limited than what IFTTT can already do. I don’t make Smart Things my ‘go-to’ product. I use a wide variety of tech to make my smart house work. I’m sure the http code works, is that for a tile system? If so, i don’t see how it’s relatable to Jarvis.

I fail to understand what your code is supposed to do, why, and how it’s supposed to work and be operated. Please enlighten me :smile:

1 Like

I think @MichaelS tried to eliminate Pushbullet and IFTTT out of your setup without realizing that IFTTT is the brain of your setup.

If SmartThings was the brain, then one could send HTTP commands directly from Jarvis to SmartThings without going through Pushbullet and IFTTT.

Essentially, your accomplishment is that you managed to create an interface between Jarvis and IFTTT. SmartThings connection is not playing a major role here.