TimeControl App
TimeControl App 可与其他 ThingSpeak™ App 配合使用:MATLAB Analysis、ThingHTTP 或 TalkBack 在特定时间或按照定期调度执行操作。
您可以将 TimeControl 与以下项结合使用:
ThingHTTP 与设备、网站或 Web 服务进行通信。
MATLAB® 分析您的数据并采取行动。
TalkBack 用于为设备排队命令。
例如,您可以发出 ThingHTTP 请求,通过 Twilio® 呼叫某人、控制设备或连接到接受 HTTP 请求的恒温器。
注意
每个用户的 TimeControl 数量限制为 12 个。
使用 TimeControl 调度操作
登录 ThingSpeak。
选择 Apps > TimeControl。
点击 New TimeControl。
编辑时间控制设置:
Name:为此时间控制输入一个唯一的名称。
Time Zone:时区取决于您的帐户设置。要更改您的个人资料时区,请点击编辑。
Frequency:选择 TimeControl 是否运行一次或按重复间隔运行。
注意
拥有免费许可证的用户必须每 60 天至少登录 ThingSpeak 一次,以保持重复时间控制处于活动状态。
Recurrence:选择重复模式。
Week:指定的每个星期几。
Day:每天在指定的时间。
Hour:按照指定的小时间隔。当重复设置为 Hour 时,您无法为 TimeControl 指定开始时间。
Minute:以指定的分钟间隔。当重复设置为 Minute 时,您无法为 TimeControl 指定开始时间。
Time:输入 TimeControl 运行的时间。对于 Hour 和 Minute 重复,ThingSpeak 会自动安排您的 TimeControl。每次编辑时间控制时都会重新安排开始时间。保存 TimeControl 后,请务必检查开始时间和日期。
Fuzzy Time:选择 TimeControl 运行的预定时间左右的分钟数。对于 5 分钟的模糊时间,基本间隔必须至少为 12 分钟,对于 10 分钟的模糊时间,基本间隔必须至少为 30 分钟。
Action:选择满足指定参数时触发的操作。
MATLAB Analysis:运行预定的代码。
ThingHTTP:连接到网络服务器并读取或写入数据。
TalkBack:将命令排队发送到您的设备。
执行时间控制
ThingSpeak 服务器根据您的时区在指定时间自动执行 TimeControl。确保您的时区在 ThingSpeak 个人资料中指定正确。请记住,触发写入同一通道的多个 TimeControl 仍必须遵守消息更新限制。
提示
TimeControl 严格按照 24 小时周期运行。修改您的 TimeControl 来适应夏令时的变化。
更换密钥
您可以使用替换密钥将数据传递到您的 App。下表总结了您可以使用的标准和自定义替换键。有些键特定于特定类型的请求,如最后一列所示。
键 | 描述 | 示例 | 使用场合 |
---|---|---|---|
%%YOUR_CUSTOM_LABEL%% | ThingHTTP 会用触发请求中带有标签 "YOUR_CUSTOM_LABEL" 的数据来替换该自定义替换值。 | field1=%%YOUR_CUSTOM_LABEL%% POST 数据: YOUR_CUSTOM_LABEL=1234 。RESULT: field1=1234 。 | 任何请求 |
%%channel_CHANNEL_ID_ | 指定通道和字段的最后一个值。对与 ThingHTTP 请求不属于同一用户的私有通道的替换请求将返回空白值。 | The latest value is %%channel_12_field_1%%。结果: The latest value is 2.5。 | 任何请求 |
%%datetime%% | TimeControl 或 React 运行的完整日期和时间。 | The date and time the event occurred is %%日期时间%%。结果: The date and time the event occurred is 2014-09-24 下午 5:32。 | TimeControl 或 React |
%%day%% | TimeControl 运行时的星期几的名称。 | The day the event occurred is %%day%%。结果: The day the event occurred is Wednesday。 | TimeControl |
%%day_index%% | 从星期日开始的工作日的从零开始的索引。 | The number of days used this week is %%day_index%%。结果: The number of days used this week is 3。 | TimeControl |
%%hour%% | TimeControl 运行的当天小时数。 | The hour that the event occurred is %%hour%%。结果: The hour that the event occurred is 5。 | TimeControl |
%%minute%% | TimeControl 运行时的小时数。 | The minute the event occurred is %%分钟%%。结果: The minute the event occurred is 30。 | TimeControl |
%%trigger%% | 触发 React 的值。 | It is way too hot in here at %%trigger%% C . 结果: It is way too hot in here at 40 C 。 | React |
%%channel_id%% | 触发 React 的通道 ID。 | The channel that triggers is %%channel_id%%。结果: The channel that triggers is 1256。 | React |
使用 ThingHTTP 更新通道状态
此示例显示如何更新 ThingSpeak 通道 "field1"。TimeControl 触发 ThingHTTP 请求,以在指定时间使用状态消息和时间戳更新通道数据。
创建事物 HTTP 请求
在 ThingHTTP 中,输入名称 ThingSpeak Channel Updater 并使用以下参数:
URL:
https://api.thingspeak.com/update
Method:POST
Body:
api_key=THINGSPEAK_WRITE_KEY&field1=TimeControl%20test&status=Executed at %%time%%.
创建时间控件
命名 TimeControl,并输入以下参数:
选中 One Time 框。
选择当前日期。
选择不久的将来的小时和分钟。
选择 ThingHTTP 作为您的操作。
在 then perform ThingHTTP 字段中选择您创建的 ThingHTTP 来触发此 TimeControl。
保存时间控制。
在指定的小时和分钟,验证您的通道是否自动更新。
TimeControl App 与 MATLAB 分析代码错误
触发 MATLAB 分析代码错误的 TimeControls 在连续触发几个错误后会停止运行。您可以通过选中 MATLAB 分析应用程序中的 Notify me via email if this MATLAB Analysis fails when triggered by TimeControl or React 框来选择通过电子邮件接收警报。