Space Service

Last Updated on : 2024-05-27 04:09:32download

This topic describes the space service, allowing you to operate spaces and get information about devices associated with a space.

Check if the space system is used through IUser.getSpaceType(), with 1 for the space system and 2 for the asset system.

Common properties

ISpace

Method Description
getSpaceId(): String The unique identifier of the space.
getSpaceName(): String The name of the space.
getParentSpaceId(): String The unique identifier of the parent space.
getPermission(): String The space permissions.
  • all: All permissions on spaces.
  • read: Read-only permission on spaces.
getCurrentSubSpaceNum(): Int The number of sub-spaces.
getCurrentSpaceDeviceNum(): Int The number of devices in spaces.
getUserDefinedPath(): String The space path.

ISpaceDeviceListResult

Method Description
getDevices(): List The list of devices.
getHasMore(): Boolean Whether more devices exist.
getLastRowKey(): String The RowKey of the last row, used for pagination.
getTotal(): Int The total number of devices.

ISpaceDevice

Method Description
getDeviceId(): String The device ID.
getDeviceName(): String The name of the device.
isOnline(): Boolean Indicates whether the device is online on the LAN or internet.
getIcon(): String The icon of the device.
getActiveTime(): Long The time when the device is activated.
getSpaceId(): String The ID of the space.
getCategoryName(): String The name of the product category.
getCategory(): String The code of the product category.
getIsGateWay(): Boolean Whether it is a gateway.
getSub(): Boolean Whether a sub-device exists.
getProductName(): String The name of the product.
getTimeZone(): String The time zone of the device.

IDeviceStatistic

Method Description
getStatisticType(): String The statistic type.
getTotal(): Long The total number of devices.
getTypeValue(): String The display name of the statistic type.

Add space

Parameters

Parameter Type Required Description
name String Yes The name of the space.
parentSpaceId String No The ID of the parent space.
callback IndustryCallBack Yes The callback.

Example

SpaceService.create("name", "parentSpaceId", new IndustryCallBack() {
            @Override
            public void onSuccess() {
                Log.d(TAG, "onSuccess: ");
            }

            @Override
            public void onError(int i, String s) {
                Log.d(TAG, "onError: ");

            }
        });

Rename space

Parameters

Parameter Type Required Description
spaceId String Yes The ID of the target space.
name String Yes The new name.
callback IndustryCallBack Yes The callback.

Example

SpaceService.update("spaceId", "name", new IndustryCallBack() {
            @Override
            public void onSuccess() {
                Log.d(TAG, "onSuccess: ");

            }

            @Override
            public void onError(int i, String s) {
                Log.d(TAG, "onError: ");

            }
        });

Delete space

Parameters

Parameter Type Required Description
spaceId String Yes The ID of the target space.
callback IndustryCallBack Yes The callback.

Example

SpaceService.remove("spaceId", new IndustryCallBack() {
            @Override
            public void onSuccess() {
                Log.d(TAG, "onSuccess: ");

            }

            @Override
            public void onError(int i, String s) {
                Log.d(TAG, "onError: ");

            }
        });

Get the property of a single space

Parameters

Parameter Type Required Description
spaceId String Yes The ID of the target space.
callback IndustryValueCallBack Yes The callback.

Example

SpaceService.space("spaceId", new IndustryValueCallBack<ISpace>() {
            @Override
            public void onSuccess(ISpace iSpace) {
                Log.d(TAG, "onSuccess: ");
            }

            @Override
            public void onError(int i, String s) {
                Log.d(TAG, "onError: ");

            }
        });

Get the list of sub-space properties

Parameters

Parameter Type Required Description
spaceId String? No The ID of the target space. If the value is nil, all sub-spaces will be queried.
callback IndustryValueCallBack<List> Yes The callback, returning the list of sub-spaces.

Example

SpaceService.subSpaces("spaceId", new IndustryValueCallBack<List<ISpace>>() {
            @Override
            public void onSuccess(List<ISpace> iSpaces) {
                Log.d(TAG, "onSuccess: ");

            }

            @Override
            public void onError(int i, String s) {
                Log.d(TAG, "onError: ");

            }
        });

Get the list of device statistics

Parameters

Parameter Type Required Description
spaceId String No The ID of the target space.
callback IndustryValueCallBack<List> Yes The callback, returning the list of device statistics.

Example

SpaceService.statistics("spaceId", new IndustryValueCallBack<List<IDeviceStatistic>>() {
            @Override
            public void onSuccess(List<IDeviceStatistic> result) {
                Log.d(TAG, "onSuccess: ");
            }

            @Override
            public void onError(int i, String s) {
                Log.d(TAG, "onError: ");

            }
        });

Get the list of devices

Parameters

Parameter Type Required Description
spaceId String Yes The ID of the target space.
lastRowKey String? No The RowKey of the last row returned from the previous query, used for pagination.
callback IndustryValueCallBack Yes The callback, returning the list of devices.

Example

SpaceService.devices("spaceId", "lastRowKey", new IndustryValueCallBack<ISpaceDeviceListResult>() {
            @Override
            public void onSuccess(ISpaceDeviceListResult iSpaceDeviceListResult) {
                Log.d(TAG, "onSuccess: ");
            }

            @Override
            public void onError(int i, String s) {
                Log.d(TAG, "onError: ");

            }
        });

Parameters

Parameter Type Required Description
spaceId String No The ID of the target space.
statisticsType String No The statistic type IDeviceStatistic.getStatisticType.
lastRowKey String? No The RowKey of the last row returned from the previous query, used for pagination.
pageSize Int Yes The number of items returned per page.
callback IndustryValueCallBack Yes The callback, returning the list of devices.

Example

SpaceService.devices("spaceId", null, 20, "lastRowKey", new IndustryValueCallBack<ISpaceDeviceListResult>() {
            @Override
            public void onSuccess(ISpaceDeviceListResult iSpaceDeviceListResult) {
                Log.d(TAG, "onSuccess: ");
            }

            @Override
            public void onError(int i, String s) {
                Log.d(TAG, "onError: ");

            }
        });

Query the list of devices

Parameters

Parameter Type Required Description
spaceId String No The ID of the target space.
lastRowKey String? No The RowKey of the last row returned from the previous query, used for pagination.
deviceName String Yes The name of the device.
pageSize Int Yes The number of items returned per page.
callback IndustryValueCallBack Yes The callback, returning the list of devices.

Example

SpaceService.search("spaceId", "Light", 20, "lastRowKey", new IndustryValueCallBack<ISpaceDeviceListResult>() {
            @Override
            public void onSuccess(ISpaceDeviceListResult iSpaceDeviceListResult) {
                Log.d(TAG, "onSuccess: ");
            }

            @Override
            public void onError(int i, String s) {
                Log.d(TAG, "onError: ");

            }
        });

Get the management instance of a single space

Parameters

Parameter Type Required Description
spaceId String Yes The ID of the target space.

Example

ISpaceManager manager = SpaceService.assetManager("spaceId");