# Device Management

Devices are instances of products, each with a unique device number and credentials. This page covers day-to-day device operations: adding devices, monitoring status, remote control, grouping, and sharing.

## Page Guide

- **What This Page Covers**: Core operations of the Device Management module: adding devices, viewing real-time status and logs, remote control, group management, and device sharing.
- **Use Cases**: For users who have created and published a product and need to register devices and verify the device access path.
- **Prerequisites**: The platform is deployed and accessible; the target product has been created and published with a defined thing model.
- **Acceptance Criteria**: The device shows online in the list, reported thing-model data is visible on the device detail page, and service invocations reach the device with a response.

## Add a Device

1. Go to **IoT > Device Management**
2. Click **Add** and select the product it belongs to
3. Enter a device name; the system automatically generates the device number and auth key
4. Save and record the credentials

::: tip

* Adding a device is optional: for batch access, you can configure the authentication information in the firmware only — the system automatically creates the device entity after the device passes its first authentication.
* A custom device number must not contain special characters; a unique code such as the device MAC/IMEI also works.
* A device must belong to a published product; devices cannot connect under an unpublished product.
  :::

## Device Features

### Real-time Status

* **Thing Model Data**: view the real-time property values reported by the device
* **Online Status**: shows whether the device is online, plus the last online/offline time
* **Device Shadow**: caches the last known state while offline; when enabled, commands delivered during the offline period take effect as soon as the device comes back online

### Remote Control

Send commands to the device through **Service Invocation**:

1. On the device detail page, select the service to invoke
2. Enter the parameter values
3. Click send and check the device response

### Device Groups

Organize devices into groups by business logic for batch operations and data filtering.

### Device Logs

Records all operation logs of the device, including:

* Property report logs
* Service invocation logs
* Event report logs
* Online/offline logs

### Device Sharing

Share a device with other users with read-only or read-write permissions.

## Device Number and Credentials

| Item | Description |
|------|-------------|
| Device Number | Globally unique; part of the MQTT clientId (`S&deviceNumber&productId&userId` format) |
| Product ID | The product the device belongs to; carried in the clientId |
| MQTT Username | The username for the MQTT connection |
| MQTT Password | The password for the MQTT connection |

::: tip
Device credentials are shown only once at creation time — keep them safe.
:::

For the complete connection parameters when a device connects over MQTT (clientId format, simple/encrypted authentication, topics, and payload formats), see [MQTT Access](https://www.fastbee.cn/doc/en/open/v2/quickstart/mqtt.md).

## Related Documentation

* [Product Management](https://www.fastbee.cn/doc/en/open/v2/manual/product.md)
* [Thing Model](https://www.fastbee.cn/doc/en/open/v2/manual/things.md)
* [MQTT Access](https://www.fastbee.cn/doc/en/open/v2/quickstart/mqtt.md)

## FAQ

### What if a device stays offline?

Check in order: whether the product is published; whether the clientId follows the `S&deviceNumber&productId&userId` format; whether the MQTT username and password match the ones on the device detail page; whether port 1883 is allowed through the firewall; and whether the device is disabled. See the common errors section of [MQTT Access](https://www.fastbee.cn/doc/en/open/v2/quickstart/mqtt.md) for the full checklist.

### What if the device is online but reported data is not displayed?

Check that the reporting topic is `/{productId}/{deviceNum}/property/post`, that the `id` in the payload exactly matches the thing model identifier (case-sensitive), and that the `value` matches the data type (for example, bool only accepts 0/1).

### Can I still send control commands while a device is offline?

Yes, provided the device shadow is enabled. The platform still accepts commands while the device is offline; the device does not process them immediately but responds as soon as it comes back online.

### How do I connect devices in batch?

There is no need to add devices one by one. Preconfigure the device number (a unique code such as MAC/IMEI works) and the product authentication information in the firmware; once a device connects and passes authentication for the first time, the system automatically creates the corresponding device entity.
