0.1.0 • Published 8 years ago

serverless-blink1 v0.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

#serverless-blink1

serverless

A serverless endpoint to push and fetch blink(1) LED color codes.

This project leverages:

##Install

Make sure you have the Serverless Framework installed and you're using Node.js v4.0+.

npm install serverless -g

Install the project using Serverless:

serverless project install serverless-blink1

Install project dependencies via npm:

npm install

Install Python dependencies via pip:

pip install -t restApi/vendored/ -r restApi/requirements.txt

or via virtualenv:

virtualenv myenv
source myenv/bin/activate
pip install -r restApi/requirements.txt
cp -R myenv/lib/python2.7/site-packages/* restApi/vendored/

Deploy your functions and endpoints:

serverless dash deploy

##Usage

###Publish

This is where you get creative. Really, you can hook this up to anything, it's just a HTTP PUT. Wrap it in your custom logic.

I often use httpie instead of curl. Try this out:

#~: http POST https://yourAPIGateway/dev/blink1 endpoint=derp --json
"derp"

#~: http PUT https://yourAPIGateway/dev/blink1/derp rgb=#123456 --json
"#123456"

#~: http GET https://yourAPIGateway/dev/blink1/derp --json
"#123456"

The most effective publisher I've used was Nagios Check_MK Business Intelligence because it handled aggregation logic. I'll write a blog post about it sometime soon.

I'm currently experimenting with two publishers: outgoing webhooks from Slack and DataDog.

###Consume

On Mac and Windows, use Blink1Control.

  1. navigate to the Tools tab
  2. click +
  3. enter a Name
  4. set Type as url
  5. paste your endpoint in Path
  6. set Frequency to 1 min or 5 min

I haven't tested this on linux, but try using blink1-tool and setting a cron like so:

* * * * * /path/to/blink1-tool --rgb `derp=$(http GET https://yourAPIGateway/dev/blink1/derp | grep '#' | awk '{ print substr($1, 3, 6) }') ; echo "0x${derp:0:2},0x${derp:2:2},0x${derp:4:2}"`