Giter VIP home page Giter VIP logo

turnkey-triumph-326606_double_red's Introduction

DoubleRed

API for collecting Double Red color sensor readings and interacting with Slack.

Installation

  • Install dependencies with mix deps.get
  • Create and migrate your database with mix ecto.create && mix ecto.migrate
  • Start Phoenix endpoint with mix phoenix.server

Usage

Locations

A location represents a restroom or stall that can be occupied or unoccupied. Register a location with the API and you can begin updating the status of that location.

Create a location

curl -X POST \
  -H "Content-Type: application/json" \
  --data '{
            "location": {
              "name": "Left Bathroom",
              "zone": 0
            }
          }' \
  http://localhost:4000/api/locations

An example response from the locations index might be:

{
  "data": [
    {
      "zone": 0,
      "name": "Left Bathroom",
      "id": "33ac6da6-970e-4f3e-9be1-4189a3abd18b"
    },
    {
      "zone": 1,
      "name": "Right Bathroom",
      "id": "9901dbe5-2a1b-4abb-86d3-811a1a5abe26"
    }
  ]
}

Wafts

A waft represents a status update for the location. At the moment double-red supports a color sensor for determining whether or not the restroom is occupied. When the color of the door indicator is red, that means the restroom is occupied. When the color is green the restroom is free for use.

To update the status of the restroom, post the details from the color sensor to that endpoint.

Create a Waft

In this example we'll update the status of the left bathroom from the above list. This is a contrived example of a red reading from the sensor, where red is maxed out and all other filtered colors are zero.

curl -X POST \
  -H "Content-Type: application/json" \
  --data '{
            "waft": {
              "red": 65535,
              "green": 0,
              "blue": 0,
              "temperature": 0,
              "brightness": 0
            }
          }' \
  http://localhost:4000/api/locations/33ac6da6-970e-4f3e-9be1-4189a3abd18b/wafts

Query the Current Status

To get the current status of the locations, query the status endpoint.

curl http://localhost:4000/api/status

This example response displays the left bathroom as occupied and the right as unoccupied:

{
  "data": [
    {
      "occupied": true,
      "location": "33ac6da6-970e-4f3e-9be1-4189a3abd18b"
    },
    {
      "occupied": false,
      "location": "9901dbe5-2a1b-4abb-86d3-811a1a5abe26"
    }
  ]
}

turnkey-triumph-326606_double_red's People

Contributors

barnett avatar dradford avatar paulfri avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.