Skip to content

Instantly share code, notes, and snippets.

@ozzieg
ozzieg / enpointExample.groovy
Last active August 29, 2015 22:00 — forked from aurman/enpointExample.groovy
SmartThings API Endpoint Example
/**
* App Endpoint API Access Example
*
* Author: SmartThings
*/
preferences {
section("Allow Endpoint to Control These Things...") {
input "switches", "capability.switch", title: "Which Switches?", multiple: true
input "locks", "capability.lock", title: "Which Locks?", multiple: true
@ozzieg
ozzieg / 0_reuse_code.js
Last active August 29, 2015 14:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
imp.configure("Roomba", [], []);
hardware.pin1.configure(DIGITAL_IN_WAKEUP);
hardware.pin2.configure(DIGITAL_OUT_OD_PULLUP);
impWakeupPin <- hardware.pin1;
roombaWakeupPin <- hardware.pin2;
roombaWakeupPin.write(1);
hardware.uart57.configure(115200, 8, PARITY_NONE, 1, NO_CTSRTS);
//Connection will be either 115200 or 57600
// Tutorial 3: T1 & T2 combined Electric imp April inputs & outputs from JQM web app
//Imp & Agent are written in squirrel-lang.org They should have a .NUT extension.
//but I've used .js so the editor will use colour highlighting.
//Tutorial 1 Reading Electric imp April input from JQM web app
//Imp & Agent are written in squirrel-lang.org They should have a .NUT extension.
//but I've used .js so the editor will use colour highlighting.
// Tutorial 2 setting Electric imp April outputs from JQM web app
//Imp & Agent are written in squirrel-lang.org They should have a .NUT extension.
//but I've used .js so the editor will use colour highlighting.
@RestResource(urlMapping='/button/*')
global class ButtonController {
@future(callout=true)
public static void light(Boolean state) {
HTTPRequest outreq = new HTTPRequest();
outreq.setEndpoint('http://api.superpat.com:5000/pins/25');
outreq.setMethod('POST');
outreq.setHeader('Content-Type', 'application/json');
outreq.setBody(state ? 'true' : 'false');