CATALOG

This is a solution for "2000W intelligent switch delay on-off control", which combines the open interface features of Thingboot products.

1. Why do we need this "delay" function?

Brothers, when we are actually working on projects, we often encounter a headache:"Boot surge".

Suppose you manage an entire row of servers, an entire factory of cooling towers, or dozens of fish tank pumps. If a call comes in at the same time immediately after a power outage, the instantaneous current impact will be very large, which will not only easily trip the device, but may even cause the equipment to dry out. Many times, we need to "queue to start" - for example, wait for the main device to start stably, and after 30 seconds, the secondary device will start again.

The equipment we used this time is from ThingbootAC4-10A or AC5-10A smart circuit breaker. This guy is not big, but he can carry it well.Rated power stably supports 2000W (resistive load), like headlights, motors, water heaters, rice cookers, basically everything can be done.

What we have to do is to use its open interface, write a script or integrate it into your system to achieve"Delay as long as you want"control.

2. Preparation: Get the "ID Card" of the device

Before you start, prepare these things first, none of them can be missing:

  1. Hardware equipment: Thingboot intelligent switch (ensure to support 2000W load).

  2. network environment: 2.4GHz WiFi (5G does not work, please pay attention).

  3. three key codes

    • AppID: Your application ID.

    • AppSecret: Your application key (these two can be seen in the background of the Thingboot console).

    • Device ID: It is the device number posted on the circuit breaker, which can also be found on the console..

3. Core idea: How to achieve "delay"?

Many people think that "delay control" means writing a lot of timer logic. Actually, you don’t need to. There is one in Thingboot’s interface.Hidden magic——resetOrder.

thisresetThe command is translated as"Break first and connect later". You just need to tell the device:

"Brother, disconnect for me, then delay for X milliseconds, and then connect automatically for me."

It's that simple. This is better than if you write on the serversleepThe function is much more reliable, because the timing is completed by the device hardware, even if your phone is turned off, it will automatically close when the time comes.

4. Practical tutorial: writing code step by step

Here we use it directlyHTTP requestLet’s do it, this is the most versatile, it’s the same whether you use Python, Java, PHP, or even Postman for debugging.

Step 1: Get the signature

For security reasons, the Thingboot interface needs to be signed.. The algorithm is:md5(md5(your key) + timestamp).

Although it sounds a bit convoluted, it actually means encrypting the key MD5 once, then adding the current timestamp, and then MD5 it again.

Step 2: Assemble the command

We need to call the device control interface.

  • Request address: http(s)://api.thingboot.com/{your AppID}/device/control/

  • Key parameters

    • device: Fill in your device ID.

    • order: Here is the core.

If we want to achieve"Turn off power immediately, then power on again after 30 seconds", how to write?30 seconds = 30000 milliseconds.

The command is as follows:

Step 3: Practical demonstration (Python as an example)

Suppose you want to control a 2000W fish tank water pump and turn it off first because you need to change the water, but you are worried that you forgot to turn it on and the fish will become hypoxic. You set a delay of 10 minutes (600000 milliseconds) to automatically turn on.

Additional scenes:if you want to achieve"Power on, keep power on for a period of time and then automatically power off", then usepointcommand (on first, then off).For example:"point": 5000It means it will be powered on immediately and will be automatically disconnected after 5 seconds. This is useful for testing equipment or pressing a bell..

5. Advanced gameplay: What to do if the device is not online? (MQTT)

The HTTP request used above is simple and direct. But if your server is on the intranet, or you want to know in real time whether the device has been executed, you can use the MQTT protocol.

Thingboot opened the MQTT interface

  • addressmapi.thingboot.com

  • port1883

  • operate: Publish topicapi/{AppID}/device/control.

The published content is still the JSON above. The advantage of using MQTT is that control commands can be sent quickly, and you can subscribe to the status reported by the device. For example, if you send a delay command, you can monitor whether the device is actually connected and disconnected as planned.

6. Some truths about 2000W load

Since our title mentioned 2000W, I have to remind you that this is the most common pitfall when selecting a model:

  1. Resistance vs Sensibility: This 2000W usually refers toresistive load(such as incandescent lamps, heating wires, water heaters). in the case ofInductive load(such as motors, fans, transformers), the instantaneous current at startup is very large, and it is safe to control the load within 300W..

  2. Wiring should be tightened: 2000W means that the current is close to 10A. The screws at the terminals must be tightened, otherwise the heat will be no joke.

  3. Heat dissipation: Although the shell of Thingboot is made of V0 grade fire retardant material, but if it is installed in a closed distribution box and runs at full 2000W, it is better to leave some margin. It will be safer to use 1500W-1800W.

7. Summary

Use the open interface of Thingboot to connect this 2000W switch to achieve delay control. In fact, it is just one sentence:calldevice/controlInterface, plug one in the orderresetparameter.

In this way, you not only save yourself the trouble of writing complex scheduled tasks, but also make the control very precise. Whether it is charging your electric car regularly (to prevent overcharging) or replenishing water after automatically changing the water in a fish tank, this solution is very stable.