Monitor your coffee pot with Google App Engine, send e-mail/Slack/Twitter notifications, and more...
This system consists of three parts.
TODO: We're just getting started on the getting started docs. See what we did there?
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.
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:
lastBrewed
is an epoch timestamp (milliseconds) of when we think the coffee was last brewed. If it is -1 then we don't know when it was last brewed, probably because someone took it off of the scale and then put it back.cupsRemaining
is an integer from 0 - 12 indicating approximately how many cups we think are there.carafePresent
is a boolean value that indicates whether or not the carafe is on the scale. If carafePresent
is false then all of the other values are meaningless so check that first!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.
{
"lastBrewed": -1,
"cupsRemaining": 0,
"carafePresent": true
}
For field definitions see the Helper library
section.
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!