Skip to content

Instantly share code, notes, and snippets.

@jamesbulpin
jamesbulpin / octo.js
Created December 4, 2016 11:42
MQTT-Octoblu connector
const util = require('util');
var S = require('string');
var mqtt = require('mqtt');
var meshblu = require('meshblu');
var meshbluJSON = require("./meshblu.json");
// Specifies how you want your message payload to be passed
// from Octoblu to your device
var MESSAGE_SCHEMA = {
type: 'object',
@jamesbulpin
jamesbulpin / lambda.py
Last active December 2, 2016 17:11
Alexa Skill AWS Lambda function for a talking fish
from __future__ import print_function
import urllib
import urllib2
octoblu_trigger = "https://triggers.octoblu.com/v2/flows/01234567-89ab-cdef-0123-4567890abcdef/triggers/01234567-89ab-cdef-0123-4567890abcdef"
# --------------- Helpers that build all of the responses ----------------------
def build_speechlet_response(output):
return {
'outputSpeech': {
@jamesbulpin
jamesbulpin / gist:a897ab3e661e20b575fe9ae7eb04ee64
Created December 2, 2016 16:50
Billy Bass Amazon Echo Intent Schema
{
"intents": [
{
"intent": "BillySay",
"slots": [
{
"name": "Saying",
"type": "LIST_OF_SAYINGS"
}
]
@jamesbulpin
jamesbulpin / piaudio.js
Created November 20, 2016 15:49
A simple Meshblu connector to play base64 encoded mp3 and drive a Big Mouth Billy Bass motors.
// Put a meshblu.json file in the same directory as this file. This must
// contain the Meshlu device UUID and token, e.g.:
// {"server":"meshblu.octoblu.com","port":80,"uuid":"01234567-89ab-cdef-0123-456789abcdef","token":"123456789012345678901234567890"}
var meshblu = require('meshblu');
var meshbluJSON = require("./meshblu.json");
var exec = require('child_process').exec;
var tempfile = require('tempfile');
var fs = require('fs');
@jamesbulpin
jamesbulpin / billybass.ino
Created November 20, 2016 13:38
Arduino sketch to control the motors in a Big Mouth Billy Bass novelty animatronic fish.
const long DEBOUNCE_DELAY = 50;
const long TRIGGER_PULSE = 50;
const int PIN_MOTOR_MOUTH = 10;
const int PIN_MOTOR_HEAD = 9;
const int PIN_MOTOR_TAIL = 11;
const int PIN_CMD_MOUTH = 1;
const int PIN_CMD_HEAD = 2;
const int PIN_CMD_TAIL = 0;
@jamesbulpin
jamesbulpin / test.js
Created October 12, 2016 00:52
*Really* rough prototype Octoblu connector to drive a USBMicro U421 device connected to a novelty button
var meshblu = require('meshblu');
var meshbluJSON = require("./meshblu.json");
// meshblu.json must contain the UUID and token for a generic device created
// within Octoblu: {"server":"meshblu.octoblu.com","port":80,"uuid":"56<redacted>c0","token":"93<redacted>42"}
// Specifies how you want your message payload to be passed
// from Octoblu to your device
var MESSAGE_SCHEMA = {
type: 'object',
@jamesbulpin
jamesbulpin / lwrf433.py
Created October 9, 2016 15:47
A Kodi add-on main script to spawn a Arduino->MQTT proxy
#!/usr/bin/python
import os
try:
import xbmc
import xbmcaddon
except ImportError, e:
import time
class xbmc:
class Monitor:
@jamesbulpin
jamesbulpin / 433listener.py
Created October 9, 2016 15:45
A proxy that forwards MQTT messages received over Arduino USB serial to a MQTT broker - designed to be used as part of a Kodi add-on
#!/usr/bin/python
import threading
import time
import glob
import os
import os.path
import signal
import sys
import Queue
@jamesbulpin
jamesbulpin / lwrf433rx.ino
Created October 9, 2016 15:43
Arduino firmware to decode LightwaveRF 433.92MHz messages received via a simple receiver module.
#define BAUD_RATE 57600
// Receiver state
bool lastValue = LOW;
unsigned long last = -1;
const unsigned int upperThreshold = 70; //upper threshold value
const unsigned int lowerThreshold = 50; //lower threshold value
// Decoder state
#define MAX_REPS 64
@jamesbulpin
jamesbulpin / gist:bdfae2113b40ebdad7f8106c3f242a95
Created September 28, 2016 20:59
An AWS Echo "skill adapter" Lambda function to route lighting control requests to Octoblu via a POST trigger
import urllib
import urllib2
octoblu_trigger = "https://triggers.octoblu.com/v2/flows/<your flow>/triggers/<your trigger>
def lambda_handler(event, context):
access_token = event['payload']['accessToken']
if event['header']['namespace'] == 'Alexa.ConnectedHome.Discovery':
return handleDiscovery(context, event)