## Advanced - Lighting for Sleeping

### Function Introduction
The light-aiding sleep function will start at the set time, and after a period of gradual dimming, the light will be turned off to help people fall asleep better.

- Some parameters are explained as follows:
  - Gradual dimming time: used to set the time from the start of the light-aiding sleep function to the time required to completely turn off the light. It can be set according to actual usage needs.
  - Repeat cycle: used to set a single start or a cyclical repeated start. Select any time from Monday to Sunday, and the task will be repeated at the corresponding time. If no time is selected, the default is single start, and the task will automatically turn off after one execution.
- Usage example
  - Set the time to 11:00 pm, select Monday to Friday, and set the gradual dimming time to 30 minutes. At 11:00 pm from Monday to Friday every week, the light automatically adjusts to a low brightness and low color temperature state, and gradually dims until it is completely turned off at 11:30 pm.

### DP protocol
- Wi-FI protocol DP: sleep_mode

|Serial number| Name| Number of bytes | Identifier| Data type| Field attribute| Field description|
|---|---|---|---|---|---|---|
|1| Version number| 1 |version| Enumeration | Initial version: 00 ||
|2| Number of task nodes| 1| node| Enumeration| 1 node: 01 2 nodes: 02 3 nodes: 03 4 nodes: 04 | 0x01: 1 node; 0x02: 2 nodes; 0x03: 3 nodes; 0x04: 4 nodes|
|3| Task switch| 1| on_off| Boolean value| 0: Task off 1: Task on |0x00: Task off; 0x01: Task on|
|4| Date setting| 1| date| Weekly data| Inverse calculation| If all are 0, it indicates single mode, which is effective only once; otherwise, it is cyclic mode, and the corresponding bit is judged to be 1. If it is 1, it is effective on the same day. For example, 0x42 means that the task is effective on Saturday and Monday (note that the corresponding task switch must be in the on state)|
|5| Gradient step value| 1| step| Value| Maximum value: 24 Minimum value: 1 Step distance: 1 Multiple: 0| 0x10: hex code, 5 minutes per step, 16*5=90 minutes of gradient duration. Value range: 1~24|
|6| Starting hour| 1| hour| Value| Maximum value: 23 Minimum value: 0 Step distance: 1 Multiple: 0| 0x10: hex code, 16 points. Value range: 0~23|
|7| Starting minute| 1 |minute| Value| Maximum value: 59 Minimum value: 0 Step: 1 Multiple: 0| 0x10: hex code, 16 minutes. Value range: 0~59|
|8| Hue (hundreds)| 1 |H_hundreds| Value| Maximum value: 3 Minimum value: 0 Step: 1 Multiple: 0 |0x03, 0x10: hex code. Big endian format, the first byte represents hundreds, the second byte represents tens and ones. The actual value represents 316, value range: 0~360|
|9| Hue (tens and ones)| 1 |H_tens_ones| Value| Maximum value: 99 Minimum value: 0 Step: 1 Multiple: 0 |0x03, 0x10: hex code. In big-endian format, the first byte represents hundreds, the second byte represents tens, and the units. The actual value represents 316, and the range is 0~360|
|10| Saturation percentage| 1 |S| Value| Maximum value: 100 Minimum value: 0 Step: 1 Multiple: 0| 0x10: hex code, 16%; Range: 0~100|
|11| Brightness percentage| 1 |V| Value| Maximum value: 100 Minimum value: 0 Step: 1 Multiple: 0| 0x10: hex code, 16%; Range: 0~100|
|12| Brightness percentage| 1| B| Value| Maximum value: 100 Minimum value: 0 Step: 1 Multiple: 0| 0x10: hex code, 16%; Range: 0~100|
|13| Color temperature percentage| 1| T| Value| Maximum value: 100 Minimum value: 0 Step: 1 Multiple: 0| 0x10: hex code, 16%; Value range: 0~100|
|14| Duration|1 |time_duration| Value | Maximum value: 24 Minimum value: 0 Step distance: 1 Multiple: 0| 0x10: hex code, 5 minutes per step. After the gradient is completed, the light will be turned off after the duration. Value range: 0~24, 0 means turn off the light, 24 means turn off the light after 120 minutes|

- Ble Mesh protocol DP: sleep_mode

|Serial number| Name| Number of bytes | Identification| Data type| Field attribute | Field description|
|----|----|----|----|----|----|----|
|1| Version number| 1| version | Enumeration | Initial version: 00 ||
|2 | Parameter mode | 1| data_mode | Enumeration | Lighting parameters include brightness and color temperature: 01 Lighting parameters only include color light HSV: 02 Lighting parameters include brightness and color temperature and color light: 03 | 0x01: only white light brightness and color temperature; 0x02: only color light HSV; 0x03: including white light brightness and color temperature and color light|
|3| Number of task nodes| 1 | node | Enumeration | 1 node: 01 2 nodes: 02 3 nodes: 03 4 nodes: 04 |0x01: 1 node; 0x02: 2 nodes; 0x03: 3 nodes; 0x04: 4 nodes|
|4| Task switch| 1| on_off | Boolean value |0: Task off 1: Task on| 0x00: Task off; 0x01: Task on|
|5 | Date setting| 1| date| Weekly data| Inverse calculation| If all are 0, it means single mode, which is effective only once; otherwise, it is a cyclic mode, and the corresponding bit is set to 1. Position 1 means it is effective on the same day. For example, 0x42 means that the task is effective on Saturday and Monday (note that the corresponding task switch must be in the on state)|
|6| Gradient step value| 1 |step| Value| Maximum value: 24 Minimum value: 1 Step distance: 1 Multiple: 0 |0x10: hex code, 5 minutes per step, 16*5=90 minutes of gradient duration. Value range: 1~24|
|7| Starting hour| 1 |hour| Value| Maximum value: 23 Minimum value: 0 Step: 1 Multiple: 0 |0x10: hex code, 16 points. Value range: 0~23|
|8| Starting minute| 1| minute| Value| Maximum value: 59 Minimum value: 0 Step: 1 Multiple: 0| 0x10: hex code, 16 minutes. Value range: 0~59|
|9| Brightness percentage| 1| B| Value| Maximum value: 100 Minimum value: 0 Step: 1 Multiple: 0| 0x10: hex code, 16%; Value range: 0~100|
|10| Color temperature percentage| 1| T| Value| Maximum value: 100 Minimum value: 0 Step: 1 Multiple: 0| 0x10: hex code, 16%; Value range: 0~100|

### How to develop
- Monitor, report and send DP according to UI interaction
  - [Specific monitoring and sending examples](/en/miniapp/solution-panel/ability#device-function-point-management)

### Notes
None

### Related materials
- [Function page]: 
  - None
- [Component]: 
  - None
- [Tutorial]: 
  - None
- [SDK]: 
  - None
- [API]: 
  - None