Thingboot 2-way intelligent composite wall switch supports direct control through HTTP interface without the need for a gateway, and is very suitable for scene-based linkage in guest rooms. The following is a practical secondary development plan from interface docking, command format to specific scenarios such as "Welcome Mode" and "One-click Leaving the Room".
Project name: Secondary development plan of guest room scenario control system based on Thingboot 2-way intelligent switch
1. Background and Objectives
In the guest room scenario of a smart hotel or smart home, traditional lighting control often requires guests to operate it one by one. Through secondary development, we can useThingboot 2-way intelligent composite wall switchThe open HTTP interface links the switch with the hotel management system (PMS), guest room tablet, or voice assistant.
Core goals:Get rid of single App control and realize scene-based automatic control such as "turn on the lights when opening the door", "turn off the lights when sleeping", and "cut off the power when leaving the room".
2. Hardware core capabilities
Before writing the code, we first confirm the foundation of this hardware (based on the [Smart Touch Wall Switch 2-way] product manual)
2 way control:This means that it can control two independent circuits (for example: one controls the spotlight/ambience light, and the other controls the main light/exhaust fan).
Open interface:Supports HTTP requests, which means that whether it is Java, Python, PHP or an applet, as long as it can make network requests, it can be controlled.
Direct network connection:No gateway required, directly connected to 2.4G WiFi. This can reduce a lot of hardware costs when deployed in hotels.
Dual control mechanism:Not only can it be controlled remotely, the physical touch buttons on the wall are still effective, which is in line with the user's operating habits.
3. Practical interface docking (secondary development core)
Since it is secondary development, we mainly connect to its API. Thingboot's interface authentication is relatively standardized, using theMD5(MD5(AppSecret) + Timestamp)way.
Step 1: Prepare parametersYou need to get from Thingboot backend:
AppID: Your application IDAppSecret:your app keyDeviceID:The device ID of this switch
Step 2: Calculate the signatureIn order to protect the interface from malicious attacks, we need a dynamic signature. The logic is as follows (this logic can be encapsulated in the back-end service):
Step 3: Issue control commandsThis is the most critical step. for this2 way switch, the format of the control instruction is as follows
| action | InstructionJSON (order) | illustrate |
|---|---|---|
| Open route 1 | {"power1":1} | Usually connected to "Basic Lighting" |
| Close Route 1 | {"power1":0} | |
| Open route 2 | {"power2":1} | Usually connected to "ambience light/TV socket" |
| Close Route 2 | {"power2":0} | |
| Fully open | {"power1":1, "power2":1} | One click welcome |
| Completely closed | {"power1":0, "power2":0} | Leave the room with one click |
Request example (using Python + Requests):
4. Core scene: guest room scene control solution
With the above interface foundation, we can build the following three most valuable scenarios:
The first scenario: Welcome mode (linked door lock)
Experience process:The guest swipes the card to open the door → the door lock signal is triggered → the guest room system automatically calls the interface → the switch No. 1 (corridor light) is on, but the curtain is not opened.
Development logic:
Trigger source:Smart door lock event (Webhook callback).
Processing logic:The backend receives the door opening signal and determines that the room status is "not checked in" or "just entered".
Execute action:Call the core step interface and send
{"power1":1}.Advanced optimization:To prevent glare during the day, it can be combined with a light sensor or time judgment. If it is 18:00 in the evening to 6:00 in the morning, turn on the lights; during the day, only the welcome music will be turned on and the lights will not be turned on.
The second scene: sleep mode and late night corridor mode
Experience process:After the guest lies down, click "Sleep" → turn off Route 1 and Route 2 (all out). When you get up in the middle of the night to go to the toilet, use the human body sensor or specific button to turn on "Way 2" with a faint light.
Development logic:
Scene trigger:Click "Sleep Mode" on the guest room tablet, or command the voice assistant.
Execute action:
Send now
{"power1":0, "power2":0}.
Night scene (special function):Utilize the "first on, then off" or timing function of the 2-way switch.
If the 2nd channel of the switch is connected to a bedside lamp or wall foot lamp, it will be called when getting up at night.
{"point2":"60000"}(Assume that the interface supports this extended command, that is, it will automatically turn off after 60 seconds). In this way, the light will automatically turn off after the guest comes back and falls asleep, so there is no need to worry about turning off the light..
The third scenario: check-out and remote operation and maintenance
Experience process:When the guest checks out → the front desk system clicks "Clear Room" → all sockets and lights in the room are powered off.
Development logic:
Management side operations:The hotel front desk PMS system operates "check-out and checkout".
automation:
Call switch interface
{"power1":0, "power2":0}Cut off the power supply to save energy and protect the environment.Note: If there is a refrigerator in the guest room, the refrigerator should be connected to an uncontrolled mains socket. Do not connect it to the second circuit of this switch to avoid power outage after check-out.
Operation and maintenance:When the cleaning staff is cleaning, they can use the handheld PDA to turn on the "cleaning mode" with one click (turn on the 1st channel lighting and turn on the exhaust fan - if the 2nd channel is connected to the exhaust fan).
5. Several practical "avoidance pitfalls" (colloquial tips)
About network stabilityBecause it uses WiFi, if the signal of the hotel AP (wireless access point) is not good, the switch will easily go offline.Solution:This switch supports setting5 sets of backup WiFi. During construction, write down the SSIDs and passwords of several surrounding APs, and it will automatically select the connection with the strongest signal..
How to do dual control (multiple control)?If the guest room is large, a switch at the bedside and a switch at the door want to control the same light. Physically changing the line is more troublesome.Solution:At the hardware level, only one physical switch is reserved for connecting the light cord, and a "free sticker" or another virtual switch is installed at the other side of the bed. Linkage through back-end logic: When receiving instructions from the bedside switch, the program automatically calls the API to control the real wall switch."Replace hardware dual control with software logic."
Private deployment (LAN)The hotel has high data security requirements and doesn’t want to use an external cloud platform?Solution:Thingboot is a set of tools that supportPrivate deploymentof. You can deploy the control service on the hotel's internal server, and the switch is not connected to the external cloud. It is purely LAN control, with lower latency and more security..
State synchronizationWhen a guest presses the switch on the wall, how does your backend (such as PMS) know whether the light is on or off?Solution:Requires device subscriptionUpward news. When the switch status changes (whether it is API control or physical button), the device will push a message to the platform. Your backend needs to receive this callback (Webhook) to ensure that the switch status on the App is synchronized with the actual physical status..
6. Summary
Through the open API of Thingboot 2-way smart switch, you can completely upgrade it from a simple switch to a smart switch in the guest room.execution terminal. Just need to get that one.MD5 signature algorithm, and then forpower1andpower2These two parameters are arranged in business logic and combined with PMS or sensors to achieve a cost-effective scenario-based control solution for guest rooms.