Intersection / cg-coffee-bot

Monitor your coffee pot with Google App Engine, send e-mail/Slack/Twitter notifications, and more...
Apache License 2.0
0 stars 1 forks source link

coffee-bot

Monitor your coffee pot with Google App Engine, send e-mail/Slack/Twitter notifications, and more...

What you need

Project structure

This system consists of three parts.

Getting started

TODO: We're just getting started on the getting started docs. See what we did there?

Adding functionality

User interfaces

If you want to create your own user interface you only need to know the API endpoint (http://YOURAPPNAME.appspot.com/get where YOURAPPNAME is the application name you created on Google App Engine) and the JSON data format which is documented below. With that information a web developer can poll the data and visualize it however you want.

If you don't want to worry about polling we have created a callback system in Javascript that you can include to do the work for you. This makes it easier for web developers to get started quickly. The section below explains how it works and how to use it.

Helper library (recommended)

The Helper library deals with all server communication (retries, etc). It is the recommended way to connect to the server since it will be updated to include server push at some point and if you use it you won't need to make any changes to take advantage of it.

The Helper library expects that there are three global functions implemented:

function getRefreshInterval() is a function that returns how often the server should be polled in milliseconds. The default is 5000.

function updateView(lastBrewed, cupsRemaining, carafePresent) is a function that is given three parameters as follows:

function serverError(message) is a function that is given a message indicating if/when something fails on the server. This can be ignored if you don't want to do anything with the errors.

See Helper.html for an implementation that simply displays alert boxes when it receives events.

Example data (JSON)

{
  "lastBrewed": -1,
  "cupsRemaining": 0,
  "carafePresent": true
}

For field definitions see the Helper library section.

Server modules

Want to post your coffee updates to Tumblr? Flash your Philips Hue lights when a fresh pot is brewed? You can do whatever you want by creating a Java class that implements either or both of these methods:

    @Subscribe
    public synchronized void coffeeBrewedEvent(CoffeeBrewedEvent coffeeBrewedEvent) throws MessagingException, IOException;
    @Override
    protected synchronized void handle(CoffeeStatus coffeeStatus) throws Exception;

For an example see com.controlgroup.coffeesystem.processors.SlackCoffeeBrewedEventProcessor or com.controlgroup.coffeesystem.processors.TwitterCoffeeStatusProcessor and the associated wiring code in com.controlgroup.coffeesystem.CoffeeSystem.

Did you implement a cool module that you think that a lot of people would use? Tell us about it by submitting a pull request!