Here is a sample application using and SmartThings.
The application uses DHT22 Temperature and Humidity Sensor for Temperateure and Humidity value and defines two Spark.function to read these sensor values.
The SmartThings application defines a new Device Type and uses APIs to read the sensor values. The device type specifies the “Polling” capability but only sometimes it is working (Raised the issue and I am awaiting SmartThings reply on this)
Reference and Inspiration
Installation
Create a new device type (https://graph.api.smartthings.com/ide/devices) with Name: Spark Core Temperature Sensor, Author: Krishnaraj Varma, Capabilities: Polling Relative Humidity Measurement Sensor Temperature Measurement
Create a new device (https://graph.api.smartthings.com/device/list) with Name: Your Choice, Device Network Id: Your Choicem Type: Spark Core Temperature Sensor (should be the last option), Location: Choose the correct location, Hub/Group: Leave blank
Update device preferences, Click on the new device to see the details. Click the edit button next to Preferences and Enter the Device ID and Access Token
Open the Mobile Application and add the newly created device, click refresh to see the Temperature and Humidity values
@james211, It is not using SmartThings Hub since it is only HTTPS calls to Spark Core. I didn’t try it before, but when you asked I disconnected my Hub and waited to become inactive, then I tested it and I am getting the sensor values. I am not sure whether you will be able to use the IDE and create a Device Type without a hub since I already activated my Hub.
@peekay123, I have added two inputs in the Preference section, we have to input Core ID and Access Token after adding the device from phone from My Devices->Spark Temperature & Humidity Device->Preferences->Edit.
@krvarma, did that. At one point I added a log.debug line after line 112 to see what “temperatureParams” was so I could understand the error. Just to be sure, I deleted and rebuilt the My Device and it worked! When I removed the log.debug line from the code and tried again, it would NOT work. I tried deleting and recreating the device but no luck. Same error I started with.
@peekay123, both of my s are not working now, one cannot switch to Spark server after connecting to Local and another keep on blinking white. Let me fix these issues and debug the issue.
Meantime cloud you please delete the retrieve humidity portion and try, just to make sure that the second HTTP call is not creating any problem for the first one.
If you guys want, you can try my SmartApp for the Spark Core as well. I’m using httpGet instead of httpPost and I’m authenticating in the URL instead of the body.
@krvarma, I did what you suggested and it gave me an error. Then I used curl to test the functions and found the core was not responding so I reflashed it and now everything works. I hate these types of bugs!!
And thanks NickW for the offer. I like the idea of using functions and @krvarma, I believe a single function could be called for both values and more. I want to explore remote controlling a relay via the function and an extra button. If either of you has ideas, please share
@peekay123, good to know it is working. Actually I tested it now and it is for me, also tried deleting the device and creating a new one just to see any issues.
@peekay123, regarding single function you mean combining both temperature and humidity in a 32-bit integer and return?, that’s a good idea!
And regarding the remote controlling, are you thinking of button press from SmartThings device and talk to I made a sample 2-3 months back but I didn’t publish it. Now I just put it in GitHub (https://github.com/krvarma/SmartThings_SparkCore)
I’m a little late to this party, but I’m looking for some help in what seems to be the opposite flow of how you all have been using the two platforms. Instead of writing a SmartApp to control the spark, I would like the spark to be able to
Simply issue on/off commands to SmartThings, or
Launch existing SmartApps
Assuming this is possible, can anyone give my box car a push or point me to any relevant urls?
@techbutler, since calling HTTPS calls from Spark Core is not possible you can use some intermediate you can use any intermediate server, may be you can use Sparknode, to listen to events from Spark Core and call the SmartThings API calls. Spark team is working on a feature called WebHooks which will make it easy to for HTTPS calls from Spark Core. This is in beta and hopefully will be releasing soon.
I have done similar to this previously but didn’t publish.
I’m still working on webhooks, and we’ve got like 50 people in the beta. Mostly right now it’s blocked by needing extra documentation, so I’ve gotta write that first, but you’re welcome to join the beta in the meantime if you want!