CATALOG

This is a more practical access solution. I will combine the interface characteristics of Thingboot to explain clearly how to turn this 5-digit master control PDU from a "manual switch" into an "intelligent device that obeys your program commands."

Brothers, let’s talk about something dry today.

If you have already got the Thingboot unit in your hand,5-digit master control PDU(That's the UNI-PDU-ZK-5), or if you are planning to use it to manage equipment in the computer room, studio or even home, you may soon encounter a pain point:

Although this thing can connect to the Internet, it can't always let me hold the phone and click on the app, right? i want itAutomatic linkage——For example, when the temperature is high, the air conditioner automatically restarts, or when the network is disconnected, the optical modem is automatically powered off and restarted. I even want to write a script to link it to my business system.

Can this be done? Of course you can.

Today we are going to talk about how to useThingboot’s open interface, transforming this PDU from an "obedient soldier" into a "commander who can think automatically."

core products: Thingboot 5-digit master control PDU (UNI-PDU-ZK-5)core weapons: HTTP open interface, single control/batch control, status query

Step 1: Understand your "weapon"—the interface capabilities of the PDU

Before we start writing code, we must first figure out what words this PDU can understand.

According to the official manual, although this 5-digit master control PDU looks like a power strip, it has a built-in WiFi module. You don’t need to buy any gateway, just connect it to the Internet, and it will wait for your instructions on the LAN or even the Internet..

It mainly supports the following "saucy operations":

  1. Single hole position control: For example, only the third hole is closed.

  2. Fully open/fully closed: One-click power off, simple and crude.

  3. batch control: One command controls the opening of channel 1 and channel 3 at the same time.

  4. Custom linkage: This is our protagonist today.

Step 2: Preparation before the war - get the key to the "remote control"

To control it remotely, you need to get three things first, none of which are essential.

  1. AppID/AppSecret: Equivalent to your account password. Log in to the Thingboot console and find it in "Development Settings".

  2. Device ID: That is the ID card of your PDU. You can see that series of numbers in the device list.

  3. Signature algorithm: This is to prevent others from tampering with your device. The algorithm announcement is quite simple:sign = md5( md5(AppSecret) + ts ). In fact, it is to MD5 the AppSecret once, add the current timestamp, and MD5 the whole thing again.

Tips: The error of the timestamp cannot be too large and can be obtained dynamically when writing code.

Step 3: Core tactics - how to implement "custom linkage logic"?

Many friends will ask: "What I want is not to press the switch manually. What I want is 'if... then...'. How can I do this?"

In fact, the logic is very simple:Your server serves as the brain, and the PDU serves as the hands and feet.

You need to write a piece of logic (that is, a script) in your business system. This logic is responsible for monitoring various conditions. Once the conditions are triggered, the HTTP interface of Thingboot will be called.

Let’s look directly at how to adjust the interface.

1. Issue a command: cut off power to a certain jack

Suppose you detect that the server temperature is too high and you need to immediately turn off the cooling fan connected to "jack 1" and then restart it (that is, first off and then on), you can directly send a POST request.

  • interface addresshttps://api.thingboot.com/{Your AppID}/device/control/?sign={Signature}&ts={Timestamp}

  • Request body format (JSON)

  • power1Represents the 1st jack. If it is to control the second one, it ispower2.

  • 0means closed,1Represents open.

Actual scenario walkthrough:Suppose you want to restart the optical modem (plugged into port 1), you need to power off first, wait 5 seconds and then power on again. Your Python code logic probably looks like this:

2. Batch operation: leave work or go to work with one click

If you are leaving get off work and want to turn off all devices except the "router" jack, you don't need to send 3 commands.

you candeviceOnly one device ID is written in the parameter, but inorderHere, the status of all roads is defined at once:

It's even simpler. If you want to turn it off completely, just send{"power":"off"}It's also possible.

3. Actual linkage: building a "watchdog" system

This is the most classic way to play PDU. For example, if the network in your home or computer room is unstable, and you want the PDU to automatically restart the dial-up device, you can't get up in the middle of the night and unplug it, right?

Logical design:

  1. Monitoring script:Run a script on your server every 1 minutepingCheck Baidu (or your gateway).

  2. Judgment logic: If ping fails for three consecutive times, it is determined as a "network failure".

  3. perform action

    • Call the interface to turn off the jack where the "optical modem" and "main router" are located (for example, jacks 3 and 4).

    • Wait 10 seconds.

    • Call the interface to open jacks 3 and 4.

    • Send a notification to your mobile phone (Business WeChat/DingTalk/Bark, etc.).

In this way, you will have aSmart computer room with self-healing capabilities.

Step 4: Advanced gameplay - asynchronous messages and complex linkage

If you feel that it is too laborious to query every 1 minute, or you want to do more complex linkage (for example, press the button of the A socket, and the B socket lights up), you can use Thingboot'sPush messagemechanism.

Simply put, when the status of the PDU changes (for example, you press a physical button on the power strip, or the current overload trips), the cloud will actively push this event to the server address you configured.

You can take advantage of this:scene: When your PDU connected to the main circuit detects that the power is lower than 10W (indicating that the connected computer is shut down), it will automatically power off all slave circuit devices such as monitors, printers, and speakers next to it, truly achieving zero standby power consumption.

A Guide to Avoiding Pitfalls

This part is based on my experience and can help you save a lot of debugging time:

  1. About signature: The signature string splicing must follow the official documentation. Many people report errors because the timestamp is not processed properly.tslocation. If you are not sure, test it with Postman before writing the code..

  2. About feedback: Call the interface and returncode 200does not representThe power strip is really powered on! It just means "the order was issued". If the device is disconnected or the relay is stuck, you won't know.

    • solution: If you want to ensure that the operation is really successful, use the query interface or directly read the current status of the device.

  3. Power limit: Although this row of plugs is marked with a single hole of 1500W and a total power of 2500W-3000W, if it is an inductive load (such as a motor or compressor), the instantaneous current may be very large, leaving a margin..

Summarize

To put it bluntly, accessing the 5-digit PDU of Thingboot is actually adjusting an HTTP interface.

There are only three steps to your development:

  1. Go backstage and get itAppIDandSecret.

  2. Write the function that generates the signature.

  3. Writtenorder={"powerX": 0/1}business logic.

When you complete these three steps, you will give this PDU "wisdom". It is no longer just a power strip, but the "last line of defense" in your entire automated operation and maintenance system - the capable person who can physically cut off power and help you solve the crash problem.

If you have any unresolved signature verification issues, or if you want to see specific Python/Java code snippets, you can communicate again at any time!

插排产品方案:
数据中心机柜电源能耗管理:如何将机柜分控PDU5位集成到项目中
查看 >>
怎样在共享麻将馆设备机柜电源控制中集成智能硬件来实现8路设备电源总控
查看 >>
仓储设备机柜电源管理:怎么将8位机柜总控PDU对接到自己的项目中
查看 >>
怎样二次开发8位远程控制分控PDU来实现过流自动断电控制
查看 >>
企业机房机柜设备电源控制:怎么将8位智能分控PDU对接到软件项目中
查看 >>
联动场景方案:
怎么在智能家居人体感应照明中集成智能设备以实现场景联动控制
查看 >>
怎样在无人值守门店机柜电源控制中对接智能设备以实现多设备联动控制
查看 >>
怎么在共享台球厅人体感应联动中集成智能设备以实现故障告警通知
查看 >>
如何在弱电间空调联动中接入智能设备以实现空调风力调节
查看 >>
怎样在活动现场人体感应与火灾预警中接入智能设备以实现消防预警联动
查看 >>
逻辑用途方案:
怎么在创客项目电源控制场景中集成智能设备以实现自定义联动逻辑控制
查看 >>
怎样二次开发3路智能墙壁开关以实现自定义联动逻辑控制
查看 >>
怎样对接智能直流控制器4路以实现联动场景逻辑控制
查看 >>
怎样接入50A带计量智能断路器以实现自定义联动逻辑控制
查看 >>
怎样在智能办公交流电路控制中接入智能设备来实现联动场景逻辑控制
查看 >>