Last Updated on : 2024-06-24 10:17:35download
Schedule a task based on the sunrise and sunset times at the device’s location. This type of schedule is suitable for outdoor lighting.
Assuming the schedule stored on the device is as follows:
Weekly recurring: from Monday to Friday.
Date | Day of week | Sunrise time | Sunset time | Schedule on/off |
---|---|---|---|---|
January 1, 2024 | Monday | 07:28 | 17:06 | On |
January 2, 2024 | Tuesday | 07:28 | 17:07 | On |
January 3, 2024 | Wednesday | 07:29 | 17:08 | On |
January 4, 2024 | Thursday | 07:29 | 17:09 | On |
January 5, 2024 | Friday | 07:30 | 17:10 | On |
January 6, 2024 | Saturday | 07:29 | 17:11 | Off |
January 7, 2024 | Sunday | 07:28 | 17:12 | Off |
… | … | … | … | … |
January 26, 2024 | Friday | 07:22 | 17:31 | On |
January 27, 2024 | Saturday | 07:22 | 17:32 | Off |
January 28, 2024 | Sunday | 07:21 | 17:33 | Off |
After the schedule is on, the device has been disconnected from the internet.
Assuming the current date is February 2, 2024.
The device will execute the weekly recurring schedule based on the last specified time until it goes online and updates the task. That is, the schedule will be executed based on the sunrise/sunset data on January 26, 2024.
After the device goes offline and loses power, it stays offline when powered on.
Assuming the power loss occurred on January 4, 2024, and the device was powered on again on January 5, 2024.
Open tuya_iot_config.h
and check if the following macro is defined.
#define ENABLE_ASTRO_TIMER 1
tuya_cloud_com_defs.h
Create a product on the Tuya Developer Platform and then enter the product development process. Click the Device Interaction tab and select a panel that supports sunrise/sunset schedules.
If the panel you have selected does not support this feature or if you are unsure which panel supports it, contact your account manager or submit a service ticket.
During device initialization, the application registers the callbacks for processing object-type and raw-type DP commands.
The TuyaOS framework initializes, adds, deletes, or modifies the scheduled task, without involving the application.
When a scheduled task is due, the framework will notify the application using the DP command callback. The command source cmd_tp
in the DP data receiving struct is DP_CMD_TIMER
.
This is because the location of the device differs from the one set for the app account. For example, if the device is in the China Data Center while the app account belongs to the Europe Data Center. In this case, the cloud retrieves and presents the sunrise and sunset times on the panel using the latitude and longitude of the device’s location (China Data Center).
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback