Room

Rooms can contain some data that would potentially be helpful for automation, including turning related items on and off by room.

Note that a room can be a kitchen, or even something like a garden. Simply a markov blanket for space… er, a place.

eranaAPI.views_room.roomsList(self, request, *args, **kwargs)
GET /api/v1/rooms/

This gets the list of all rooms.

Returns
[
    {
        "id": 1,
        "name": "Throne Room",
        "is_occupied": true,
        "castle": {
          "id": 1,
          "name": "Speilburg Castle",
          "homekit_id": "Steve & Steve's Homekit id",
          "is_primary": true
        }
    },
    {
        "id": 2,
        "name": "Secret Passageway",
        "is_occupied": false,
        "castle": {
          "id": 1,
          "name": "Speilburg Castle",
          "homekit_id": "Steve & Steve's Homekit id",
          "is_primary": true
        }
    }
]
Raises
400 on bad request
Return type
Collection (Array of Objects)
eranaAPI.views_room.roomDetail(self, request, *args, **kwargs)
GET /api/v1/room/<str:pk>/

This gets the data from an individual room.

Parameters
pk (string) – REQUIRED. This is the id of the room we want from database. Place in the URL string.
Returns
{
    "id": 1,
    "name": "Throne Room",
    "castle": {
      "id": 1,
      "name": "Speilburg Castle",
      "homekit_id": "Steve & Steve's Homekit id",
      "is_primary": true,
      "room_id": 1
    },
    "is_occupied": true
}
Raises
400 on bad request
Return type
Object
eranaAPI.views_room.roomsCreate(self, request, *args, **kwargs)
POST /api/v1/rooms-create/

This creates a room or rooms from digital nothingness. It must always be bundled as a collection.

Parameters
  • name (string) – This is the name of our room.
  • is_occupied (boolean) – Whether this room is currently occupied. By default is false.
  • castle (float) – The primary key of the castle this room is in.
[
    {
        "name": "Throne Room",
        "is_occupied": true,
        "castle": 1
    },
    {
        "name": "Secret Passageway",
        "castle": 1
    }
]
Returns
Confirmation of our castle(s)
[
    {
        "id": 1,
        "name": "Throne Room",
        "castle": {
          "id": 1,
          "name": "Speilburg Castle",
          "homekit_id": "Steve & Steve's Homekit id",
          "is_primary": true,
        },
        "is_occupied": true
    },
    {
        "id": 2,
        "name": "Secret Passageway",
        "castle": {
          "id": 1,
          "name": "Speilburg Castle",
          "homekit_id": "Steve & Steve's Homekit id",
          "is_primary": true,
        },
        "is_occupied": false
    }
]
Raises
400 on bad request
Return type
Collection (Array of Objects)
eranaAPI.views_room.roomsUpdate(self, request, *args, **kwargs)
PATCH /api/v1/rooms-update/

This updates information on our room(s). It must always be bundled as a collection.

Parameters
id (integer) – REQUIRED. This database id of our room(s) must always be included.
[
    {
        "id": 1,
        "name": "Celebration Room"
    },
    {
        "id": 2,
        "is_occupied": true,
    }
]
Returns
Confirmation of our room(s) update
[
    {
        "id": 1,
        "name": "Celebration Room",
        "castle": {
          "id": 1,
          "name": "Speilburg Castle",
          "homekit_id": "Steve & Steve's Homekit id",
          "is_primary": true,
        },
        "is_occupied": true
    },
    {
        "id": 2,
        "name": "Secret Passageway",
        "castle": {
          "id": 1,
          "name": "Speilburg Castle",
          "homekit_id": "Steve & Steve's Homekit id",
          "is_primary": true,
        },
        "is_occupied": true
    }
]
Raises
400 on bad request
Return type
Collection (Array of Objects)
eranaAPI.views_room.roomsDelete(self, request, *args, **kwargs)
DELETE /api/v1/rooms-delete/

All good things must come to an end. It must always be bundled as a collection. Unlike the castle deletion, this
deletion sets any dependent models references to this room (so if you have lights currently in the room) to null,
instead of outright deleting the reference. This should help if you move things around. Be sure when you create a new
room to assign it’s id to any items manually.

Parameters
id (integer) – REQUIRED. This database id of our room(s) must always be included.
[
    {
        "id": 1
    }
]
Returns
Confirmation of our room(s) deletion.
"Rooms(s) successfully deleted!"
Raises
400 on bad request
Return type
String