Git Product home page Git Product logo

home-automation-device-registry's Introduction

Home Automation Device Registry

Development

Running

You can start the device registry by typing make start. The service will be available at port 5001.

Testing

You can run the test suite by typing make test.

Usage

All responses will have the form:

{
    "message": "Description of what happened",
    "data": "Mixed type holding the content of the response"
}

Subsequent response definitions will only detail the expected value of the data field.

List all devices

Definition

GET /devices

Response

  • 200: success
[
    {
        "identifier": "id1",
        "name": "Device 1",
        "device_type": "switch",
        "controller_name": "controller-1",
        "room": {
            "identifier": "bedroom",
            "name": "Jake's Bedroom"
        }
    },
    {
        "identifier": "id2",
        "name": "Device 2",
        "device_type": "bulb",
        "controller_name": "controller-2",
        "room": {
            "identifier": "kitchen",
            "name": "Kitchen"
        }
    }
]

Register a new device

Definition

POST /devices

Arguments

  • "identifier":string a globally unique identifier for this device
  • "name":string a friendly name for the device
  • "device_type":string the type of the device as understood by the client
  • "room_identifier":string the globally unique identifier of the room
  • "controller_name":string the name of the device's controller

If the identifier already exists, the existing device will be overwritten.

Response

  • 400: unknown room
  • 201: created successfully

Returns the new device if successful.

{
    "identifier": "id1",
    "name": "Device 1",
    "device_type": "switch",
    "controller_name": "controller-2",
    "room": {
        "identifier": "bedroom",
        "name": "Jake's Bedroom"
    }
}

Lookup device details

Definition

GET /device/<identifier>

Response

  • 404: device not found
  • 200: success
{
    "identifier": "id1",
    "name": "Device 1",
    "device_type": "switch",
    "controller_name": "controller-1",
    "room": {
        "identifier": "bedroom",
        "name": "Jake's Bedroom"
    }
}

Delete a device

Definition

DELETE /device/<identifier>

Response

  • 404: device not found
  • 204: success

List rooms

Definition

GET /rooms

Response

  • 200: success
[
    {
        "identifier": "bedroom",
        "name": "Jake's Bedroom",
        "devices": [
            {
                "identifier": "lamp1",
                "name": "Lamp",
                "device_type": "bulb",
                "controller_name": "controller-1"
            }
        ]
    },
    {
        "identifier": "kitchen",
        "name": "Kitchen",
        "devices": [
            {
                "identifier": "tv2",
                "name": "TV",
                "device_type": "switch",
                "controller_name": "controller-2"
            }
        ]
    }
]

Register new room

Definition

POST /rooms

Arguments

  • "identifier":string a globally unique identifier for the room
  • "name":string a friendly name for the room

If the identifier already exists, the existing room will be overwritten. Devices belonging to an existing room will not be modified.

Response

  • 201: created successfully

Returns the new room is created successfully.

{
    "identifier": "bedroom",
    "name": "Jake's Bedroom",
    "devices": []
}

Lookup room details

Definition GET /room/<identifier>

Response

  • 404: room not found
  • 200: success
{
    "identifier": "bedroom",
    "name": "Jake's Bedroom",
    "devices": [
        {
            "identifier": "id1",
            "name": "Device 1",
            "device_type": "switch",
            "controller_name": "controller-1"
        }
    ]
}

Delete a room

Definition

DELETE /rooms/<identifier>

Response

  • 404: room not found
  • 204: success

home-automation-device-registry's People

Contributors

jakewright 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.