Scheduled lights-off
Updated at:
Copy as MD
This service is ideal for student dormitories. Every night at 22:00, it turns off a smart light, queries the light's status, and sends a notification to the dormitory administrator's DingTalk group to confirm the light is off.
Prerequisites
You have created a project (for example, project). For more information, see Projects.Create a product and a device
- Click the project card to go to the project's Home page. In the left-side navigation pane, click Products.
- Click Create Product, configure the parameters, and then click Confirm.
For more information about how to create a product and define its thing model, see Products.
In this example, we create a product named Smart Light. For Product Category, select Smart Life/Electrical & Lighting/Light. IoT Platform predefines a Boolean property, LightSwitch, for this product category.
For Node Type, select Directly Connected Device. For Network Connection Method, select WiFi. For Data Format, select ICA standard data format (Alink JSON). - Add a smart light device (for example, smartLights). For more information, see Devices.
- Use the device simulator to report property data. For more information, see Device Simulator.
Create a business service
- On the project's Home page, click the Business Logic tab.
- In the upper-left corner of the business service list, click .
- On the Business Logic Development page, find and click the Scheduled Lights-Off template card.
- In the Create Business Logic from Template panel, configure the basic information for the service.
Parameter Description Service Name Enter a custom name for the service. The name can contain Chinese characters, letters, digits, underscores (_), hyphens (-), and parentheses (()). It must start with a Chinese character, a letter, or a digit, and be no more than 30 characters long. One Chinese character counts as a single character.
Project Displays the project to which the service belongs: project. Description Enter a description for the service, such as its purpose. The description can be up to 100 characters long. One Chinese character counts as a single character. - Click Create with This Template.
After you create the business service, the system redirects you to the service editing page and automatically generates a business flow. Configure the node parameters as needed.

Edit the service flow
- On the service editing canvas, click the Scheduled Trigger node to configure its parameters.
Parameter Description Node Name Enter a name for the node. Trigger Mode Select Recurring Scheduled Trigger. Recurrence Period Select Day. Trigger Time Set to 22:00:00. Select Effective Time Set the time when the service starts to run. Select End Time Set the time when the service stops running. To have the service run indefinitely, select Permanent. - From the Device list on the left, drag a Smart Light product node onto the canvas to replace the empty product node. Connect the scheduled trigger node to the Smart Light node and configure the parameters.
Parameter Description Node Name Enter a name for the node. Select Device to Control Select the device that the service will control: smartLights. Select Operation Type Select Execute Device Action. Data to Send Select Property. Main Light Switch Select the static Boolean value false to turn off the light. - Replace the second empty product node with a Smart Light product node. Connect it between the first Smart Light node and the DingTalk chatbot node, and then configure its parameters.
Parameter Description Node Name Enter a name for the node. Select Device to Control Select the same device as in the previous node: smartLights. Select Operation Type Select Query Device Property. Select Property to Query Select Main Light Switch. Query Dimension Select Snapshot Value to query the switch status. - Click the DingTalk chatbot node to configure its parameters.
Parameter Description Node Name Enter a name for the node. webhook The webhook URL of the DingTalk group chatbot. For more information, see Create a DingTalk chatbot. Configuration Method Select Use Template. Select Template Select Device Property Alert. Device Data Source Select Smart Light/Main Light Switch. Notify Users Select based on your needs. This controls whether the message mentions everyone in the group or specific users. - In the upper-right corner of the page, click Save to save the settings.
Debug and publish
- On the service editing page, click the Deploy & Debug button
in the upper-right corner to deploy and start the service. - Debug the service.
- DeviceOnline debuggingReturn to the page of the project, go to the tab for the device, and start the virtual device.
- Return to the service editing page. In the upper-right corner, click the Deploy & Debug button
. In the Scheduled Debugging dialog box, set the time to 22:00:00 for any day and click Start Debugging.
The DingTalk group will receive a message with the light's switch status.
- Click Publish to publish the service.
You must publish the service to the cloud before you can invoke it.
Is this page helpful?