Room Information Management

Last Updated on : 2026-02-25 02:19:32download

All features related to room information management correspond to the TSmartRoom class. You need to initialize them with the correct homeId. You can add, delete, update, and query rooms, manage devices and groups within a room, and sort rooms.

Functional description

Class name Description
TSmartRoom Manage information about rooms, devices, and groups in the rooms.
TSmartRoomBean Room information data model.

Room management

Add a room

API description

public async addRoomWithName(roomName: string): Promise<TSmartAtopResponse<TSmartRoomBean>>

Parameters

Parameter Description
roomName The room name.

Sample code

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);

try {
  const response = await smartRoom.addRoomWithName('Bedroom');
  if (response.success) {
    const room = response.result;
    console.log('Room created successfully, room ID:', room.roomId);
  }
} catch (error) {
  console.error('An error occurred when creating a room:', error);
}

Delete a room

API description

public async removeRoom(roomId: number): Promise<TSmartAtopResponse<boolean>>

Parameters

Parameter Description
roomId The room ID.

Sample code

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);
const roomId = 789;

try {
  const response = await smartRoom.removeRoom(roomId);
  if (response.success) {
    console.log('Deleted the room successfully');
  } else {
    console.error('Failed to delete the room:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when deleting the room:', error);
}

Update a room name

API description

public async updateRoomName(roomId: number, roomName: string): Promise<TSmartAtopResponse<boolean>>

Parameters

Parameter Description
roomId The room ID.
roomName The new room name.

Sample code

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);
const roomId = 789;

try {
  const response = await smartRoom.updateRoomName(roomId, 'Master Bedroom');
  if (response.success) {
    console.log('Updated the room name successfully');
  } else {
    console.error('Failed to update the room name:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when updating the room name:', error);
}

Sort the list of rooms

API description

Sorts the list of rooms in a home.

public async sortRoomList(roomIdList: Array<number>): Promise<TSmartAtopResponse<boolean>>

Parameters

Parameter Description
roomIdList An array of room IDs, arranged in the desired order.

Sample code

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);

// Sort rooms in the specified order
const roomIdList = [789, 790, 791];

try {
  const response = await smartRoom.sortRoomList(roomIdList);
  if (response.success) {
    console.log('Sorted rooms successfully');
  } else {
    console.error('Failed to sort rooms:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when sorting rooms:', error);
}

Query the list of rooms

API description

Queries the list of all rooms in a home.

public async getRoomList(): Promise<Array<TSmartRoomBean>>

Return values

Returns Promise<Array<TSmartRoomBean>> containing the list of rooms.

Sample code

import { TSmartRoom } from '@thingsmart/homelib';

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);

try {
  const roomList = await smartRoom.getRoomList();
  roomList.forEach((room) => {
    console.log('Room ID:', room.roomId, 'Room Name:', room.name);
  });
} catch (error) {
  console.error('An error occurred when querying the list of rooms:', error);
}

Query room snapshot

API description

Queries the room’s snapshot information, including device status snapshots and scene information.

public async fetchRoomSnapshop(roomId: number): Promise<TSmartAtopResponse<TSmartDiyHomeRoomSnapshotBean>>

Parameters

Parameter Description
roomId The room ID.

Return values

Returns Promise<TSmartAtopResponse<TSmartDiyHomeRoomSnapshotBean>>, containing the room snapshot information.

TSmartDiyHomeRoomSnapshotBean data model

Field Type Description
roomId number The room ID.
devices Array The list of device snapshots.
rules Array The list of scene rules.

Sample code

import { TSmartRoom } from '@thingsmart/homelib';

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);
const roomId = 789;

try {
  const response = await smartRoom.fetchRoomSnapshop(roomId);
  if (response.success) {
    const snapshot = response.result;
    console.log('Room snapshot:', snapshot);
    console.log('Number of devices:', snapshot.devices.length);
    console.log('Number of scenes:', snapshot.rules.length);
  } else {
    console.error('Failed to query the room snapshot:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when querying the room snapshot:', error);
}

Sort the room relationship

API description

Bulk manages and sorts the relationships between rooms, devices, and groups.

public async sortRoomRelation(romeId: number, relationList: Array<TSmartSortRoomRelationParams>): Promise<TSmartAtopResponse<boolean>>

Parameters

Parameter Description
romeId The room ID.
relationList The list of sorting parameters for room relationships.

TSmartSortRoomRelationParams data model

Field Type Description
bizId string The device ID or group ID.
bizType TSmartHomeResBizType The business type.
displayOrder number The order that the items are displayed.

Sample code

import { TSmartRoom, TSmartSortRoomRelationParams, TSmartHomeResBizType } from '@thingsmart/homelib';

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);
const roomId = 789;

// Build a room relationship list
const relationList: Array<TSmartSortRoomRelationParams> = [
  {
    bizId: 'device_001',
    bizType: TSmartHomeResBizType.DEVICE,
    displayOrder: 0
  },
  {
    bizId: 'group_001',
    bizType: TSmartHomeResBizType.GROUP,
    displayOrder: 1
  }
];

try {
  const response = await smartRoom.sortRoomRelation(roomId, relationList);
  if (response.success) {
    console.log('Sorted room relationship successfully');
  } else {
    console.error('Failed to sort room relationship:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when sorting room relationship:', error);
}

Add room relationships

API description

Bulk adds devices or groups to the room.

public async addRoomRelation(romeId: number, relationList: Array<TSmartSortRoomRelationParams>): Promise<TSmartAtopResponse<boolean>>

Parameters

Parameter Description
romeId The room ID.
relationList The list of parameters for room relationships.

Sample code

import { TSmartRoom, TSmartSortRoomRelationParams, TSmartHomeResBizType } from '@thingsmart/homelib';

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);
const roomId = 789;

// Build a list of devices and groups to add
const relationList: Array<TSmartSortRoomRelationParams> = [
  {
    bizId: 'device_001',
    bizType: TSmartHomeResBizType.DEVICE,
    displayOrder: 0
  },
  {
    bizId: 'device_002',
    bizType: TSmartHomeResBizType.DEVICE,
    displayOrder: 1
  }
];

try {
  const response = await smartRoom.addRoomRelation(roomId, relationList);
  if (response.success) {
    console.log('Added room relationship successfully');
  } else {
    console.error('Failed to add room relationship:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when adding room relationship:', error);
}

Room, device, and group management

Add a device to a room

API description

public async addDevice(roomId: number, devId: string): Promise<TSmartAtopResponse<boolean>>

Parameters

Parameter Description
roomId The room ID.
devId The device ID.

Sample code

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);
const roomId = 789;
const devId = 'device_001';

try {
  const response = await smartRoom.addDevice(roomId, devId);
  if (response.success) {
    console.log('Added the device to the room successfully');
  } else {
    console.error('Failed to add the device to the room:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when adding the device to the room:', error);
}

Remove a device from a room

API description

public async removeDevice(roomId: number, devId: string): Promise<TSmartAtopResponse<boolean>>

Parameters

Parameter Description
roomId The room ID.
devId The device ID.

Sample code

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);
const roomId = 789;
const devId = 'device_001';

try {
  const response = await smartRoom.removeDevice(roomId, devId);
  if (response.success) {
    console.log('Removed the device from the room successfully');
  } else {
    console.error('Failed to remove the device from the room:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when removing the device from the room:', error);
}

Add a group to a room

API description

public async addGroup(roomId: number, groupId: string): Promise<TSmartAtopResponse<boolean>>

Parameters

Parameter Description
roomId The room ID.
groupId The group ID.

Sample code

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);
const roomId = 789;
const groupId = 'group_001';

try {
  const response = await smartRoom.addGroup(roomId, groupId);
  if (response.success) {
    console.log('Added the group to the room successfully');
  } else {
    console.error('Failed to add the group to the room:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when adding the group to the room:', error);
}

Remove a group from a room

API description

public async removeGroup(roomId: number, groupId: string): Promise<TSmartAtopResponse<boolean>>

Parameters

Parameter Description
roomId The room ID.
groupId The group ID.

Sample code

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);
const roomId = 789;
const groupId = 'group_001';

try {
  const response = await smartRoom.removeGroup(roomId, groupId);
  if (response.success) {
    console.log('Removed the group from the room successfully');
  } else {
    console.error('Failed to remove the group from the room:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when removing the group from the room:', error);
}

Organize devices or groups by room

API description

Bulk saves the device and group relationships in the room.

public async saveBatchRoomRelation(roomId: number, deviceGroupList: Array<string>): Promise<TSmartAtopResponse<boolean>>

Parameters

Parameter Description
roomId The room ID.
deviceGroupList The list of device IDs or group IDs.

Sample code

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);
const roomId = 789;

// List of device and group IDs
const deviceGroupList = ['device_001', 'device_002', 'group_001'];

try {
  const response = await smartRoom.saveBatchRoomRelation(roomId, deviceGroupList);
  if (response.success) {
    console.log('Bulk saved room relationship successfully');
  } else {
    console.error('Failed to bulk save room relationship:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when bulk saving room relationship:', error);
}

Query the list of devices in a room

API description

Queries all devices in a specified room.

public getRoomDevList(mRoomId: number): Promise<Array<TSmartDeviceModel>>

Parameters

Parameter Description
mRoomId The room ID.

Return values

Returns Promise<Array<TSmartDeviceModel>>, containing the list of devices in the room.

Sample code

import { TSmartRoom } from '@thingsmart/homelib';

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);
const roomId = 789;

try {
  const deviceList = await smartRoom.getRoomDevList(roomId);
  deviceList.forEach((device) => {
    console.log('Device ID:', device.devId, 'Device Name:', device.name);
  });
} catch (error) {
  console.error('An error occurred when querying the list of devices in the room:', error);
}

Query device and group relationships

API description

Queries the relationship information between devices and groups in the room.

public async getDeviceGroupInfo(romeId: number): Promise<TSmartAtopResponse<TSmartRoomRelationEntityBean>>

Parameters

Parameter Description
romeId The room ID.

Return values

Returns Promise<TSmartAtopResponse<TSmartRoomRelationEntityBean>>, containing relationship information about devices and groups in the room.

Sample code

import { TSmartRoom } from '@thingsmart/homelib';

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);
const roomId = 789;

try {
  const response = await smartRoom.getDeviceGroupInfo(roomId);
  if (response.success) {
    const relationInfo = response.result;
    console.log('Room relation information:', relationInfo);
  } else {
    console.error('Failed to query room relationship:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when querying room relationship:', error);
}

Query the list of groups in a room

API description

Synchronously gets all groups in the specified room.

public getRoomDevGroupListSync(roomId: number): Array<TSmartGroupModel>

Parameters

Parameter Description
roomId The room ID.

Return values

Returns Array<TSmartGroupModel>, containing the list of groups in the room.

Sample code

import { TSmartRoom } from '@thingsmart/homelib';

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);
const roomId = 789;

try {
  const groupList = smartRoom.getRoomDevGroupListSync(roomId);
  groupList.forEach((group) => {
    console.log('Group ID:', group.groupId, 'Group Name:', group.name);
  });
} catch (error) {
  console.error('An error occurred when querying the list of groups in the room:', error);
}

Room tag management

Query the list of room tags

API description

Gets all room tags in the home.

public async getRoomTagList(): Promise<TSmartAtopResponse<Array<TSmartRoomTagBean>>>

Return values

Returns Promise<TSmartAtopResponse<Array<TSmartRoomTagBean>>>, containing the list of room tags.

TSmartRoomTagBean data model

Field Type Description
roomTagId number The ID of the room tag.
name string The name of the specified tag.
displayOrder number The order that the items are displayed.
homeId number The home ID.

Sample code

import { TSmartRoom } from '@thingsmart/homelib';

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);

try {
  const response = await smartRoom.getRoomTagList();
  if (response.success) {
    const tagList = response.result;
    tagList.forEach((tag) => {
      console.log('Tag ID:', tag.roomTagId, 'Tag Name:', tag.name);
    });
  } else {
    console.error('Failed to query the list of room tags:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when querying the list of room tags:', error);
}

Create a room tag

API description

Creates a room tag.

public async createRoomTag(roomTagName: string): Promise<TSmartAtopResponse<boolean>>

Parameters

Parameter Description
roomTagName The name of the room tag.

Sample code

import { TSmartRoom } from '@thingsmart/homelib';

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);

try {
  const response = await smartRoom.createRoomTag('Floor 1');
  if (response.success) {
    console.log('Created a room tag successfully');
  } else {
    console.error('Failed to create a room tag:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when creating a room tag:', error);
}

Delete a room tag

API description

Deletes the specified room tag.

public async deleteRoomTag(roomTagId: number): Promise<TSmartAtopResponse<boolean>>

Parameters

Parameter Description
roomTagId The ID of the room tag.

Sample code

import { TSmartRoom } from '@thingsmart/homelib';

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);
const tagId = 1001;

try {
  const response = await smartRoom.deleteRoomTag(tagId);
  if (response.success) {
    console.log('Deleted the room tag successfully');
  } else {
    console.error('Failed to delete the room tag:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when deleting the room tag:', error);
}

Rename a room tag

API description

Renames the specified room tag.

public async updateRoomTagName(roomTagId: number, roomTagName: string): Promise<TSmartAtopResponse<boolean>>

Parameters

Parameter Description
roomTagId The ID of the room tag.
roomTagName The new tag name.

Sample code

import { TSmartRoom } from '@thingsmart/homelib';

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);
const tagId = 1001;

try {
  const response = await smartRoom.updateRoomTagName(tagId, 'Floor 2');
  if (response.success) {
    console.log('Renamed the room tag successfully');
  } else {
    console.error('Failed to rename the room tag:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when renaming the room tag:', error);
}

Sort room tags

API description

Sorts the room labels.

public async sortRoomTagIds(roomTagIds: Array<number>): Promise<TSmartAtopResponse<boolean>>

Parameters

Parameter Description
roomTagIds The list of tag IDs after sorting.

Sample code

import { TSmartRoom } from '@thingsmart/homelib';

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);

// Arrange the label IDs in the new order
const sortedTagIds = [1001, 1003, 1002];

try {
  const response = await smartRoom.sortRoomTagIds(sortedTagIds);
  if (response.success) {
    console.log('Sorted room tags successfully');
  } else {
    console.error('Failed to sort room tags:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when sorting room tags:', error);
}

Query the relationship

API description

Gets the relationship between rooms and tags.

public async getRoomTagRelationship(): Promise<TSmartAtopResponse<TSmartRoomTagListRelationBean>>

Return values

Returns Promise<TSmartAtopResponse<TSmartRoomTagListRelationBean>>, containing the relationship between rooms and tags.

TSmartRoomTagListRelationBean data model

Field Type Description
rooms Array The list of tag IDs.
roomGroupResultMap Map<number, Array>> The mapping relationship between tags and rooms. The key is the tag ID, and the value is a list of room IDs.

Sample code

import { TSmartRoom } from '@thingsmart/homelib';

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);

try {
  const response = await smartRoom.getRoomTagRelationship();
  if (response.success) {
    const relationship = response.result;
    console.log('Room tag relationship:', relationship);
    console.log('Tag list:', relationship.rooms);
    console.log('Tag-room mapping:', relationship.roomGroupResultMap);
  } else {
    console.error('Failed to query room tag relationship:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when querying room tag relationship:', error);
}

Modify the relationship

API description

Bulk manages the relationship between rooms and tags.

public async manageRoomTagRelationship(roomRelationship: Map<number, Array<number>>, roomTagIds: Array<number>): Promise<TSmartAtopResponse<boolean>>

Parameters

Parameter Description
roomRelationship The mapping relationship between tags and rooms. The key is the tag ID, and the value is a list of room IDs.
roomTagIds The list of tag IDs.

Sample code

import { TSmartRoom } from '@thingsmart/homelib';

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);

// Create a mapping between tags and rooms
const roomRelationship = new Map<number, Array<number>>();
// Tag 1001 is associated with rooms 789 and 790
roomRelationship.set(1001, [789, 790]);
// Tag 1002 is associated with room 791
roomRelationship.set(1002, [791]);

const roomTagIds = [1001, 1002];

try {
  const response = await smartRoom.manageRoomTagRelationship(roomRelationship, roomTagIds);
  if (response.success) {
    console.log('Modified room tag relationship successfully');
  } else {
    console.error('Failed to modify room tag relationship:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when modifying room tag relationship:', error);
}

Create a room with tag

API description

Specifies a tag when creating a room.

public async addRoomWithNameAndTag(roomName: string, roomTagId: number): Promise<TSmartAtopResponse<TSmartRoomBean>>

Parameters

Parameter Description
roomName The room name.
roomTagId The ID of the room tag.

Sample code

import { TSmartRoom } from '@thingsmart/homelib';

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);

try {
  const response = await smartRoom.addRoomWithNameAndTag('Master Bedroom', 1001);
  if (response.success) {
    const room = response.result;
    console.log('Created a room with tag successfully, room ID:', room.roomId);
  } else {
    console.error('Failed to create a room:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when creating a room:', error);
}

Recommended rooms and default rooms

Query the list of recommended rooms

API description

Gets the list of rooms recommended by the system, which can be used to quickly create a room.

public async getRecommenRoomList(): Promise<TSmartAtopResponse<Array<TSmartRecommendRoomBean>>>

Return values

Returns Promise<TSmartAtopResponse<Array<TSmartRecommendRoomBean>>>, containing the list of recommended rooms.

TSmartRecommendRoomBean data model

Field Type Description
name string The name of a recommended room.
icon string The room icon.
type string The room type.

Sample code

import { TSmartRoom } from '@thingsmart/homelib';

// Set homeId to 0 when querying recommended rooms
const smartRoom = TSmartRoom.getInstance(0);

try {
  const response = await smartRoom.getRecommenRoomList();
  if (response.success) {
    const recommendList = response.result;
    recommendList.forEach((room) => {
      console.log('Recommended Room:', room.name, 'Type:', room.type);
    });
  } else {
    console.error('Failed to query the list of recommended rooms:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when querying the list of recommended rooms:', error);
}

Query the list of default rooms

API description

Gets the list of the system’s default rooms.

public async getDefaultRoomList(): Promise<TSmartAtopResponse<Array<TSmartDefaultRoomBean>>>

Return values

Returns Promise<TSmartAtopResponse<Array<TSmartDefaultRoomBean>>>, containing the list of default rooms.

TSmartDefaultRoomBean data model

Field Type Description
name string The name of a default room.
icon string The room icon.

Sample code

import { TSmartRoom } from '@thingsmart/homelib';

// Set homeId to 0 when querying the default room
const smartRoom = TSmartRoom.getInstance(0);

try {
  const response = await smartRoom.getDefaultRoomList();
  if (response.success) {
    const defaultList = response.result;
    defaultList.forEach((room) => {
      console.log('Default room:', room.name);
    });
  } else {
    console.error('Failed to query the list of default rooms:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when querying the list of default rooms:', error);
}

Room scene management

Add scenes to a room

API description

Adds one or more scenes to the specified room.

public async addScenes(roomId: number, ruleIds: string[]): Promise<TSmartAtopResponse<boolean>>

Parameters

Parameter Description
roomId The room ID.
ruleIds An array of scene IDs.

Sample code

import { TSmartRoom } from '@thingsmart/homelib';

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);
const roomId = 789;
const sceneIds = ['scene_001', 'scene_002', 'scene_003'];

try {
  const response = await smartRoom.addScenes(roomId, sceneIds);
  if (response.success) {
    console.log('Added the scene to the room successfully');
  } else {
    console.error('Failed to add the scene to the room:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when adding the scene to the room:', error);
}

Save scenes to multiple rooms

API description

Saves multiple scenes to multiple rooms in bulk.

public async batchSaveScenesToRooms(roomIds: string[], ruleIds: string[]): Promise<TSmartAtopResponse<boolean>>

Parameters

Parameter Description
roomIds An array of room IDs.
ruleIds An array of scene IDs.

Sample code

import { TSmartRoom } from '@thingsmart/homelib';

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);

// Save multiple scenes to multiple rooms
const roomIds = ['789', '790', '791'];
const sceneIds = ['scene_001', 'scene_002'];

try {
  const response = await smartRoom.batchSaveScenesToRooms(roomIds, sceneIds);
  if (response.success) {
    console.log('Bulk saved scenes successfully');
  } else {
    console.error('Failed to bulk save scenes:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when bulk saving scenes:', error);
}

Sort scenes in a room

API description

Sorts the scenes in the room.

public async sortSceneForRoomId(roomId: string, ruleIds: string[]): Promise<TSmartAtopResponse<boolean>>

Parameters

Parameter Description
roomId The room ID.
ruleIds The list of sorted smart scenes.

Sample code

import { TSmartRoom } from '@thingsmart/homelib';

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);
const roomId = '789';

// Arrange scene IDs in the new order
const sortedSceneIds = ['scene_003', 'scene_001', 'scene_002'];

try {
  const response = await smartRoom.sortSceneForRoomId(roomId, sortedSceneIds);
  if (response.success) {
    console.log('Sorted room scenes successfully');
  } else {
    console.error('Failed to sort room scenes:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when sorting room scenes:', error);
}

Remove scenes from a room

API description

Removes one or more scenes from the specified room.

public async removeSceneForRoomId(roomId: string, ruleIds: string[]): Promise<TSmartAtopResponse<boolean>>

Parameters

Parameter Description
roomId The room ID.
ruleIds An array of IDs for the scenes to be removed.

Sample code

import { TSmartRoom } from '@thingsmart/homelib';

const homeId = 123456;
const smartRoom = TSmartRoom.getInstance(homeId);
const roomId = '789';
const sceneIdsToRemove = ['scene_001', 'scene_002'];

try {
  const response = await smartRoom.removeSceneForRoomId(roomId, sceneIdsToRemove);
  if (response.success) {
    console.log('Removed the scene from the room successfully');
  } else {
    console.error('Failed to remove the scene from the room:', response.errorMsg);
  }
} catch (error) {
  console.error('An error occurred when removing the scene from the room:', error);
}