Skip to content

Latest commit

 

History

History
213 lines (142 loc) · 4.58 KB

File metadata and controls

213 lines (142 loc) · 4.58 KB

RoomService

A list of all methods in the RoomService service. Click on the method name to view detailed information about that method.

Methods Description
getRooms List all available rooms
createRoom Create a new room
getRoom Get details of a single room from its given {roomId}
updateRoom Update a single room from its given {roomId}
deleteRoom Delete a single room from its given {roomId}

getRooms

List all available rooms

  • HTTP Method: GET
  • Endpoint: /clip/v2/resource/room

Return Type

GetRoomsOkResponse

Example Usage Code Snippet

import { OpenHue } from 'open-hue';

(async () => {
  const openHue = new OpenHue({
    apiKey: 'YOUR_API_KEY',
  });

  const { data } = await openHue.room.getRooms();

  console.log(data);
})();

createRoom

Create a new room

  • HTTP Method: POST
  • Endpoint: /clip/v2/resource/room

Parameters

Name Type Required Description
body RoomPut The request body.

Return Type

CreateRoomOkResponse

Example Usage Code Snippet

import { OpenHue, ResourceIdentifier, RoomPut } from 'open-hue';

(async () => {
  const openHue = new OpenHue({
    apiKey: 'YOUR_API_KEY',
  });

  const rtype = Rtype.device;

  const resourceIdentifier: ResourceIdentifier = {
    rid: '42edd1f5-9538-4180-9ced-2d9e07f26d0f',
    rtype: rtype,
  };

  const roomArchetype = RoomArchetype.living_room;

  const roomPutMetadata: RoomPutMetadata = {
    name: 'name',
    archetype: roomArchetype,
  };

  const input: RoomPut = {
    type_: 'type',
    children: [resourceIdentifier],
    metadata: roomPutMetadata,
  };

  const { data } = await openHue.room.createRoom(input);

  console.log(data);
})();

getRoom

Get details of a single room from its given {roomId}

  • HTTP Method: GET
  • Endpoint: /clip/v2/resource/room/{roomId}

Parameters

Name Type Required Description
roomId string ID of the room

Return Type

GetRoomOkResponse

Example Usage Code Snippet

import { OpenHue } from 'open-hue';

(async () => {
  const openHue = new OpenHue({
    apiKey: 'YOUR_API_KEY',
  });

  const { data } = await openHue.room.getRoom('roomId');

  console.log(data);
})();

updateRoom

Update a single room from its given {roomId}

  • HTTP Method: PUT
  • Endpoint: /clip/v2/resource/room/{roomId}

Parameters

Name Type Required Description
body RoomPut The request body.
roomId string ID of the room

Return Type

UpdateRoomOkResponse

Example Usage Code Snippet

import { OpenHue, ResourceIdentifier, RoomPut } from 'open-hue';

(async () => {
  const openHue = new OpenHue({
    apiKey: 'YOUR_API_KEY',
  });

  const rtype = Rtype.device;

  const resourceIdentifier: ResourceIdentifier = {
    rid: '42edd1f5-9538-4180-9ced-2d9e07f26d0f',
    rtype: rtype,
  };

  const roomArchetype = RoomArchetype.living_room;

  const roomPutMetadata: RoomPutMetadata = {
    name: 'name',
    archetype: roomArchetype,
  };

  const input: RoomPut = {
    type_: 'type',
    children: [resourceIdentifier],
    metadata: roomPutMetadata,
  };

  const { data } = await openHue.room.updateRoom('roomId', input);

  console.log(data);
})();

deleteRoom

Delete a single room from its given {roomId}

  • HTTP Method: DELETE
  • Endpoint: /clip/v2/resource/room/{roomId}

Parameters

Name Type Required Description
roomId string ID of the room

Return Type

DeleteRoomOkResponse

Example Usage Code Snippet

import { OpenHue } from 'open-hue';

(async () => {
  const openHue = new OpenHue({
    apiKey: 'YOUR_API_KEY',
  });

  const { data } = await openHue.room.deleteRoom('roomId');

  console.log(data);
})();