TimeControl App
The TimeControl app works with other ThingSpeak™ apps: MATLAB
Analysis, ThingHTTP, or TalkBack to perform an action at a specific time or on a regular schedule.
You can use TimeControl with:
ThingHTTP to communicate with devices, websites, or web services.
MATLAB® Analysis to act on your data.
TalkBack to queue up commands for a device.
For example, you can make a ThingHTTP request that calls someone via Twilio®, controls a device, or connects to a thermostat that accepts HTTP requests.
Note
The number of TimeControls is limited to 12 per user.
Schedule Actions with TimeControl
Sign into ThingSpeak.
Select Apps > TimeControl.
Click New TimeControl.
Edit TimeControl settings:
Name: Enter a unique name for this TimeControl.
Time Zone: The time zone is based on your account settings. To change your profile time zone, click edit.
Frequency: Choose whether TimeControl runs once or at recurring intervals.
Note
Users with a free license must log in to ThingSpeak at least once every 60 days to keep recurring time controls active.
Recurrence: Choose a recurrence pattern.
Week: Every week day specified.
Day: At a specified time daily.
Hour: At a specified hourly interval. You cannot specify start time for your TimeControl when the recurrence is set to Hour.
Minute: At a specified minute interval. You cannot specify start time for your TimeControl when the recurrence is set to Minute.
Time: Enter the time at which TimeControl runs. For Hour and Minute recurrence, ThingSpeak schedules your TimeControl automatically. The start time is rescheduled each time you edit your TimeControl. Be sure to check the start time and date after saving your TimeControl.
Fuzzy Time: Select the number of minutes around a scheduled time for TimeControl to run. The base interval must be at least 12 minutes for a 5 minute fuzzy time, and at least 30 minutes for a 10 minute fuzzy time.
Action: Select the action to trigger when the specified parameters are met.
MATLAB Analysis: Run scheduled code.
ThingHTTP: Connect to a web server and read or write data.
TalkBack: Queue commands to send to your device.
Execute a TimeControl
ThingSpeak servers automatically execute a TimeControl at the specified time, based on your time zone. Make sure that your time zone is correctly specified in your ThingSpeak profile. Keep in mind that multiple TimeControls that trigger writing to the same channel must still adhere to the message update limits.
Tip
TimeControl runs in a strict 24–hour cycle. Modify your TimeControl to account for daylight saving time changes.
Replacement Keys
You can pass data to your apps using replacement keys. The following table summarizes the standard and custom replacement keys you can use. Some keys are specific to a particular type of request, as indicated in the last column.
Key | Description | Example | Use With |
---|---|---|---|
%%YOUR_CUSTOM_LABEL%% | ThingHTTP replaces this custom replacement value with data in the trigger request that has the label "YOUR_CUSTOM_LABEL". | field1=%%YOUR_CUSTOM_LABEL%% POST data: YOUR_CUSTOM_LABEL=1234 .RESULT: field1=1234 . | Any request |
%%channel_CHANNEL_ID_ | The last value of the specified channel and field. Replacement requests to private channels not owned by the same user as the ThingHTTP request return blank values. | The latest value is %%channel_12_field_1%%.RESULT: The latest value is 2.5. | Any request |
%%datetime%% | The full date and time when the TimeControl or React ran. | The date and time the event occurred is %%datetime%%.RESULT: The date and time the event occurred is 2014-09-24 5:32 p.m. | TimeControl or React |
%%day%% | The name of the weekday when TimeControl ran. | The day the event occurred is %%day%%.RESULT: The day the event occurred is
Wednesday. | TimeControl |
%%day_index%% | The zero-based index of the weekday starting on Sunday. | The number of days used this week is %%day_index%%.RESULT: The number of days used
this week is 3. | TimeControl |
%%hour%% | The hour of the day when TimeControl ran. | The hour that the event occurred is %%hour%%.RESULT: The hour that the event occurred is 5. | TimeControl |
%%minute%% | The minute of the hour when the TimeControl ran. | The minute the event occurred is %%minute%%.RESULT: The minute the event occurred is
30. | TimeControl |
%%trigger%% | The value that triggered React. | It is way too hot in here at %%trigger%% C .RESULT: It is way too hot in here at 40 C . | React |
%%channel_id%% | The channel ID that triggered React. | The channel that triggers is %%channel_id%%.RESULT: The channel that
triggers is 1256. | React |
Update Channel Status Using ThingHTTP
This example shows how to update a ThingSpeak channel "field1". A TimeControl triggers a ThingHTTP request to update channel data at a specified time with a status message and timestamp.
Create a ThingHTTP Request
In ThingHTTP, enter the name ThingSpeak Channel Updater with these parameters:
URL:
https://api.thingspeak.com/update
Method: POST
Body:
api_key=THINGSPEAK_WRITE_KEY&field1=TimeControl%20test&status=Executed at %%time%%.
Create a TimeControl
Name the TimeControl, and enter these parameters:
Check the One Time box.
Select the current day.
Select an hour and minute in the near future.
Select ThingHTTP as your action.
In the then perform ThingHTTP field select the ThingHTTP you created to trigger this TimeControl.
Save the TimeControl.
At the specified hour and minute, verify that your channel updates automatically.
TimeControl App with MATLAB Analysis Code Errors
TimeControls that trigger MATLAB Analysis code with errors stops running after several consecutive errors are triggered. You can choose to receive an alert via email by checking the box Notify me via email if this MATLAB Analysis fails when triggered by TimeControl or React in the MATLAB Analysis app.