Skip to content

Instantly share code, notes, and snippets.

View mager's full-sized avatar
🏠
Working from home

Mager mager

🏠
Working from home
View GitHub Profile
@mager
mager / smartthings-smartapp-control-switch-lock-with-contact-sensor.groovy
Last active August 29, 2015 14:08
SmartThings SmartApp: Control a switch with a contact sensor
/**
* Example: Control a switch with a contact sensor
*
* Copyright 2014 Andrew Mager
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@mager
mager / smartapp-template.groovy
Created February 9, 2015 21:07
SmartThings: A new SmartApp template
/**
* My First SmartApp
*
* Copyright 2015 Andrew Mager
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@mager
mager / keybase.md
Created April 7, 2015 16:19
keybase.md

Keybase proof

I hereby claim:

  • I am mager on github.
  • I am mager (https://keybase.io/mager) on keybase.
  • I have a public key whose fingerprint is 9D0C D280 C989 C4D0 CF63 4432 9704 0AAE 8D68 330A

To claim this, I am signing this object:

@mager
mager / httpGet.groovy
Created April 19, 2015 22:54
Example: How to make API calls from a SmartApp
/**
* Example: How to make API calls from a SmartApp
*
* Copyright 2015 SmartThings Hack
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
/**
* Silent Safety
*
* Copyright 2015 Diana Laboy-Rush
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@mager
mager / twilio-to-smartapp.php
Created May 28, 2015 21:38
Twilio to SmartApp
<?php
$url = 'https://graph.api.smartthings.com/api/smartapps/installations/dc20d3c1-7573-4fe2-9e13-ac095c4eb20e/hue';
//$data = array('text' => 'color=orange');
$body = $_REQUEST['Body'];
$data = "{'value':'$body'}";
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
@mager
mager / sms-hue.php
Last active August 29, 2015 14:23
SmartThings SmartApp Example: SMS to Hue script
<?php
$url = '<YOUR SMARTAPP ENDPOINT>';
$body = $_REQUEST['Body'];
$data = "{'value':'$body'}";
$options = array(
'http' => array(
'header' => "Authorization: Bearer <YOUR SMARTAPP TOKEN>\nContent-type: application/json",
'method' => 'PUT',
@mager
mager / sonos.groovy
Created June 23, 2015 17:02
Controlling Sonos from SmartThings
preferences {
section("Title") {
input "player", "capability.musicPlayer", title: "music player", required: true, multiple: false
input "frontDoor", "capability.contactSensor", title: "front door", required: true, multiple: false
}
}
def installed() {
subscribe(frontDoor, "contact", myHandler)
}
/**
* Smart Alarm is a multi-zone virtual alarm panel, featuring customizable
* security zones. Setting of an alarm can activate sirens, turn on light
* switches, push notification and text message. Alarm is armed and disarmed
* simply by setting SmartThings location 'mode'.
*
* Please visit <http://statusbits.github.io/smartalarm/> for more
* information.
*
* Version 2.4.3 (7/7/2015)
@mager
mager / get_delivery.json
Created September 2, 2015 22:34
Postmates API: Get the status of a delivery (/customers/:customer_id/deliveries/:delivery_id)
{
"status": "dropoff",
"dropoff": {
"phone_number": "646-234-2271",
"name": "Mager's House",
"notes": "",
"detailed_address": {
"city": "New York City",
"country": "US",
"street_address_1": "498 Central Park N",