IT Nerd Space

Remotely control your HS100 timer (API)

Remotely control your HS100 timer (API)

Remotely control your HS100 timer (API)

Thanks to a comment by Jacob K. on a previous post, I looked into how to set/unset the HS100 plug timer via the TP-Link API call.

To replay the steps below, be sure to already have:

In the next step, I recommend you use Hurl.it service to test the API calls, it’s the easiest way.

First let’s retrieve the timer Rule ID

Destination:

Body:
{“method”:”passthrough”, “params”: {“deviceId”: “YOUR_DEVICE_ID_HERE”, “requestData”: “{\”count_down\”:{\”get_rules\“:null}}” }}
 Then hit the Launch Request button. The result body should look like this:
{“error_code”:0,”result”:{“responseData”:”{\”count_down\”:{\”get_rules\”:{\”rule_list\”:[{\”enable\”:0,\”id\”:\”YOUR_RULE_ID_HERE\”,\”name\”:\”\”,\“delay\”:1800,\”act\”:0}],\”err_code\”:0}}}”}}
Have a look at the id field! I call it the Rule Id (YOUR_RULE_ID_HERE). we’ll need it in the next step. I would say it never changes but I am not sure.

Now you can enable/disable the timer like this:

Destination:
Body:
{“method”:”passthrough”, “params”: {“deviceId”: “YOUR_DEVICE_ID_HERE”, “requestData”: “{\”count_down\”:{\”edit_rule\“:{\”name\”:\”\”,\”act\”:0,\”enable\”:1,\”id\”:\”YOUR_RULE_ID_HERE\”,\”delay\”:1800}}}” }}
Use the following values in your body:
  • act: (action)
    • Use 0 to power off the plug after the timer
    • Use 1 to power on the plug after the timer
  • enable:
    • Use 0 to disable the timer
    • Use 1 to enable the timer
  • delay:
    • timer delay in seconds

Have fun!!

  • Mark

    It gives me Bad JSON Formatting with the first request (even with hurl.it). This is the manual script request
    curl -XPOST -H “Content-type: application/json” -d ‘{"method":"passthrough", "params": {"deviceId": "YOUR_DEVICE_ID_HERE", "requestData": "{"count_down":{"get_rules":null}}" }}’ ‘https://eu-wap.tplinkcloud.com/?token=YOUR_TOKEN_HERE’