HarmonyOS Native SDK
Device Management
Edit Device

Edit a Device

Update alias and remark

Use the unified device object:

await device.updateDeviceInfo('Living room light', 'First floor');

Or use the user manager and Device ID:

await userManager.updateDeviceInfo(deviceId, 'Living room light', 'First floor');

Read device data and state

const name: string = device.getName();
const remark: string = device.getRemark();
const deviceId = device.subscribeDeviceId().getValue();
const isBound: boolean = device.subscribeBoundState().getValue();
const snapshot = device.toJsonObject();

After success, the unified object and bound-device list are updated. Subscribe to the corresponding GizState when the UI must react to later changes instead of keeping a one-time snapshot.