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
@ozzieg
ozzieg / electric-imp-mata-device
Created August 9, 2014 20:16
Electric Imp Device code utilizing the Firmata protocol based on Firmata implementation in Javascript from http://jgautier.github.com/firmata/. Utilizes the UART to talk to an Arduino.
server.log("Device started, impee_id " + hardware.getimpeeid() + " and mac = " + imp.getmacaddress() );
//------------------------------------------------------------------------------------------------------------------------------
// Uart57 for TX/RX
SERIAL <- hardware.uart57;
// FIRMATA CONSTANTS
const PIN_MODE = 0xF4;
const REPORT_DIGITAL = 0xD0;
const REPORT_ANALOG = 0xC0;
//Code snippet for integrating with the Ninjablocks cloud
//Requires signing up with the Ninjablocks cloud here: https://a.ninja.is/born
//
//Assumptions:
// - Uses the User Access Token method
// - Create a Block ID that is unique and alphanumeric
// -
//
// NINJABLOCKS API
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');