Smart home equipment control method and device, electronic equipment and storage medium
By electing a temporary central hub in the smart home system to receive instructions and record log data, the problem of functional failure when the home network is down is solved, enabling device control and automated linkage in offline mode, and ensuring high availability and data synchronization of the system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GREE ELECTRIC APPLIANCE INC OF ZHUHAI
- Filing Date
- 2025-12-24
- Publication Date
- 2026-05-05
AI Technical Summary
When the home network is down or the home host fails, smart home systems may experience issues such as scene linkage, voice control, and automation rules, resulting in single-point failure risks and availability bottlenecks.
When the connection between the cloud and the home host is interrupted, a temporary hub is elected from the smart home devices. The temporary hub receives user commands to control the devices, records log data, and synchronizes the data when the cloud connection is restored, releasing the control authority of the temporary hub.
It ensures the basic functionality of smart home devices is available even when offline, enabling the operation and automated linkage of key devices. Once the network is restored, it automatically synchronizes the status and returns control, requiring no manual intervention from the user.
Smart Images

Figure CN121978976A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of smart home control technology, specifically relating to a control method for smart home devices, a control device for smart home devices, electronic devices, and computer-readable storage media. Background Technology
[0002] Current smart home systems heavily rely on cloud services. The home hub acts as the home's central control unit, and its workflow is roughly as follows: user commands (central control, APP) are sent to the home hub, then to the cloud server, and finally to the home hub and devices. The current process has a major flaw: when the home network is offline, several problems arise. Scene linkage, voice control, and the logical judgment and execution of automation rules all depend on the cloud. When the cloud and the home hub cannot connect properly, these functions will directly fail. In other words, once the home network is disconnected or the home hub malfunctions, the system becomes paralyzed and cannot execute any automated scenes, linkage controls, or emergency operations, posing a single point of failure risk and availability bottleneck. Summary of the Invention
[0003] The purpose of this invention is to provide a control method for smart home devices, a control device for smart home devices, an electronic device, and a corresponding computer-readable storage medium, which can solve the problem of smart home system malfunction when the home host or network is offline.
[0004] To solve the above-mentioned technical problems, the present invention is implemented as follows: In a first aspect, embodiments of the present invention provide a control method for a smart home device, the method comprising: When the connection between the cloud and the home host is interrupted, a temporary hub is elected from at least one smart home device; The temporary central hub receives user commands and controls corresponding smart home devices according to the user commands. The temporary central hub records and stores the log data of the smart home devices. When the connection between the cloud and the home host is restored to normal, the log data is uploaded to the cloud through the temporary hub, the data is synchronized through the cloud, and the control permissions of the temporary hub are released after the synchronization is completed.
[0005] Optionally, the election of a temporary hub from at least one smart home device includes: Obtain the status parameters of the at least one smart home device; the status parameters include at least one of the device power type, available computing resources, and network topology location. Based on the status parameters of the at least one smart home device, a temporary hub is elected from the at least one smart home device.
[0006] Optionally, controlling the corresponding smart home devices according to the user instructions includes: The user instruction is determined to be either a simple control instruction or a complex scenario instruction; When the user instruction is a simple control instruction, the temporary central hub sends a control command to the corresponding smart home device to control the corresponding smart home device. When the user instruction is a complex scenario instruction, the temporary central control unit controls multiple smart home devices to perform linked operations according to preset scenario logic rules and the user instruction.
[0007] Optionally, it also includes: The preset scenario logic rule is that when the cloud and the home host are connected normally, the configuration is made through the cloud and sent to the at least one smart home device through the home host.
[0008] Optionally, determining whether the user instruction is a simple control instruction or a complex scenario instruction includes: If the user command is a voice command, the voice command is recognized by a smart home device with offline voice recognition capabilities to obtain the command text; Based on the instruction text, the user instruction is determined to be either a simple control instruction or a complex scenario instruction.
[0009] Optionally, the log data includes the content of the instructions executed by the smart home device, the execution timestamp, and the status change information of the smart home device.
[0010] Optionally, the data synchronization via the cloud includes: The first state data of the smart home device stored in the cloud is compared with the second state data of the smart home device recorded in the log data. If the first state data is inconsistent with the second state data, then the state data with the most recent timestamp will be used for synchronization.
[0011] Secondly, embodiments of the present invention provide a device for controlling smart home devices, the device comprising: An election module is used to elect a temporary hub from at least one smart home device when the connection between the cloud and the home host is interrupted; The control module is used to receive user commands through the temporary central hub and control the corresponding smart home devices according to the user commands. A recording module is used to record and store the log data of the smart home devices through the temporary central hub. The synchronization module is used to upload the log data to the cloud through the temporary hub when the connection between the cloud and the home host is restored to normal, synchronize the data through the cloud, and release the control permissions of the temporary hub after the synchronization is completed.
[0012] Optionally, the election module includes: An acquisition submodule is used to acquire status parameters of the at least one smart home device; the status parameters include at least one of device power type, available computing resources, and network topology location. An election submodule is used to elect a temporary hub from the at least one smart home device based on the status parameters of the at least one smart home device.
[0013] Optionally, the control module includes: The determination submodule is used to determine whether the user instruction is a simple control instruction or a complex scenario instruction; The first control submodule is used to send control commands to the corresponding smart home devices through the temporary central hub when the user instruction is a simple control instruction, so as to control the corresponding smart home devices. The second control submodule is used to control multiple smart home devices to perform linkage operations through the temporary central hub according to preset scene logic rules and the user instruction when the user instruction is a complex scene instruction.
[0014] Optionally, it also includes: The preset scenario logic rule is that when the cloud and the home host are connected normally, the configuration is done through the cloud. The sending submodule is used to send the preset scene logic rules to the at least one smart home device through the home host.
[0015] Optionally, the determining submodule includes: The recognition unit is configured to, if the user instruction is a voice instruction, recognize the voice instruction through a smart home device with offline voice recognition function to obtain the instruction text; The determination unit module is used to determine whether the user instruction is a simple control instruction or a complex scenario instruction based on the instruction text.
[0016] Optionally, the log data includes the content of the instructions executed by the smart home device, the execution timestamp, and the status change information of the smart home device.
[0017] Optionally, the synchronization module includes: The comparison submodule is used to compare the first state data of the smart home device stored in the cloud with the second state data of the smart home device recorded in the log data. The synchronization submodule is used to synchronize with the state data that has the most recent timestamp if the first state data is inconsistent with the second state data.
[0018] Thirdly, embodiments of the present invention provide an electronic device including a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps of the method described in the first aspect.
[0019] Fourthly, embodiments of the present invention provide a readable storage medium on which a program or instructions are stored, which, when executed by a processor, implement the steps of the method described in the first aspect.
[0020] The embodiments of the present invention have the following advantages: This invention provides a method for controlling smart home devices, including: when the connection between the cloud and the home host is interrupted, electing a temporary hub from at least one smart home device; receiving user commands through the temporary hub and controlling the corresponding smart home device according to the user commands; recording and storing log data of the smart home device through the temporary hub; when the connection between the cloud and the home host is restored, uploading the log data to the cloud through the temporary hub, synchronizing the data through the cloud, and releasing the control authority of the temporary hub after synchronization is completed. By delegating intelligent decision-making capabilities to local smart home devices, and automatically forming a temporary control network for coordination and cooperation among devices through election, the host can control smart home devices to perform key device operations and automated linkages even when offline. After the network is restored, the status is automatically synchronized and control is returned, eliminating the need for manual intervention by the user during the network outage and recovery phases. Attached Figure Description
[0021] Figure 1 This is a flowchart illustrating the steps of a control method for a smart home device provided in an embodiment of the present invention; Figure 2 This is a flowchart of another method for controlling a smart home device provided in an embodiment of the present invention; Figure 3 This is a structural block diagram of a control device for a smart home device provided in an embodiment of the present invention. Detailed Implementation
[0022] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0023] The terms "first," "second," etc., used in the specification and claims of this invention are used to distinguish similar objects and are not used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention can be implemented in orders other than those illustrated or described herein. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0024] The following description, in conjunction with the accompanying drawings, details a control method for a smart home device, a control device for a smart home device, an electronic device, and a computer-readable storage medium provided by the embodiments of the present invention, through specific examples and application scenarios.
[0025] Reference Figure 1 The diagram illustrates a flowchart of a control method for a smart home device according to an embodiment of the present invention. The method may specifically include the following steps: Step 101: When the connection between the cloud and the home host is interrupted, elect a temporary hub from at least one smart home device; In a typical smart home environment, the following devices are typically deployed: The cloud-based system is primarily responsible for managing and distributing rules, storing and compiling complex automated scenarios and linkage logic set by users (such as "away mode turns off all lights and appliances"), and distributing them to the home host; remote access and control, allowing users to view home status or send control commands from anywhere via the internet using a mobile app; and data aggregation and analysis, collecting system-wide operation logs and device data for big data analysis, optimization, and providing value-added services.
[0026] The home hub is the central processing unit within a home LAN. Specifically, it can be a device with computing and connectivity capabilities, such as a smart speaker, smart TV, dedicated home gateway, or high-performance router. Under normal network conditions, it is responsible for receiving instructions from the cloud or the user's app and forwarding them to the corresponding controlled devices. It can also store pre-compiled rules from the cloud and interpret and execute them locally, reducing real-time reliance on the cloud. It maintains a list, status, and connection information for all smart devices within the home LAN and maintains a heartbeat connection with the cloud to synchronize device status. When it fails or loses network access, the system triggers an election process to create a temporary hub to take over its responsibilities.
[0027] Multiple smart home devices, including both candidate temporary hubs with computing capabilities and devices without computing power, receive instructions and generate specific physical actions. Examples include smart lights, smart sockets, smart curtain motors, and air conditioners; and sensors such as human body sensors, door and window sensors, and temperature and humidity sensors. In offline mode, they receive direct control from the "temporary hub" to ensure the availability of basic functions.
[0028] Among the various smart home devices, the candidate temporary hub can also be edge devices. These typically refer to smart devices that, in addition to basic control functions, possess additional computing power, storage space, and a stable power supply, such as high-performance smart speakers, smart TVs, and even some high-end gateways. When the network is normal, they act like a home host, caching pre-compiled rules from the cloud. When the home host is offline, these eligible devices participate in the election of the "temporary hub." If successfully elected, they are promoted to temporary hub, taking on the responsibility of coordinating and controlling other devices during offline periods.
[0029] In some embodiments provided by this invention, a user control terminal may also be included, which serves as the interface for human-system interaction. Specifically, it may be a mobile app, a smart panel, or a voice assistant (such as the microphone of a smart speaker). It receives user input (touch, voice) and converts it into control commands that the system can understand. In offline mode, these terminals (especially apps supporting local area networks and offline voice recognition) become the channel for communication between the user and a temporary central control unit, ensuring uninterrupted human-computer interaction.
[0030] In one embodiment, step 101 may include the following sub-steps: Sub-step S11: Obtain the status parameters of the at least one smart home device; the status parameters include at least one of the following: device power type, available computing resources, and network topology location; When the system detects an interruption in the connection between the home host and the cloud server through mechanisms such as heartbeat timeout (e.g., the loss of more than three consecutive heartbeat packets), it enters an offline emergency state. At this time, the system will initiate a distributed temporary central election process to ensure the rapid construction of an independently operating offline autonomous control network without coordination from the cloud and the main central hub.
[0031] Specifically, after the election is triggered, all smart home devices eligible to participate in the election (such as smart speakers, smart TVs, high-performance gateways, etc.) will proactively broadcast or respond to queries, reporting their key status parameters. These status parameters are the objective basis for assessing whether a device is suitable to serve as a temporary central hub, and mainly include: Device power type: Differentiate between wired power supply (such as smart TVs and embedded gateways) and battery power supply (such as some sensors and mobile devices). In terms of stability, wired power supply devices have a higher priority because they have no risk of power outages.
[0032] Available computing resources include current CPU idle rate, available memory size, and local storage space. The more abundant the computing resources, the better capable the system is of interpreting and executing complex rules, coordinating multi-device operations, and recording operation logs.
[0033] Network topology location: This is determined by evaluating the device's signal strength (RSSI) within the home LAN, the number of hops in connection with other critical devices, or the reliability of the network medium (e.g., prioritizing devices with wired Ethernet connections). Devices located centrally within the network and with high-quality connections can communicate more efficiently with other devices on the network.
[0034] Sub-step S12: Based on the status parameters of the at least one smart home device, elect a temporary hub from the at least one smart home device.
[0035] Based on a pre-set election algorithm, the collected device status parameters are comprehensively weighted and scored.
[0036] In one embodiment of this invention, a base score is assigned to each type of status parameter. For example, wired power supply is 10 points, battery power supply is 3 points, CPU idle rate > 50% is 5 points, and so on; direct connection to the main router is 8 points. Different weighting coefficients are assigned to different parameters based on the device type and the actual condition of the home network. For example, in a scenario where stability is prioritized, the power type has the highest weight. The total score of each candidate device is calculated, and the device with the highest total score exceeding a preset threshold is selected as the temporary hub.
[0037] In one embodiment of the present invention, the selected smart home device will broadcast its leadership status as a temporary central hub to the local area network, and the other smart home devices will recognize it as a member, thereby forming an autonomous control network with the temporary central hub as its core.
[0038] This election mechanism ensures that in the event of a network outage, the most stable, capable, and best-connected device automatically takes over system control, achieving seamless and intelligent switching of the control center and providing a solid foundation for subsequent offline high-availability control.
[0039] Step 102: Receive user instructions through the temporary central hub and control the corresponding smart home devices according to the user instructions; In one embodiment of this invention, when the network is interrupted and a temporary central hub is elected, the system enters an offline autonomous mode. In the offline state, users can issue commands through control terminals that still maintain a local connection with the temporary central hub. These terminals include, but are not limited to: local control apps running on smartphones or tablets located on the same local area network; smart panels and remote controls with local area network communication capabilities; and voice interaction devices such as smart speakers and home consoles that integrate offline voice recognition modules. Commands are transmitted to the temporary central hub via local area network protocols (such as Wi-Fi, Bluetooth Mesh, Zigbee, or Ethernet). The temporary central hub employs different execution strategies depending on the command type.
[0040] In one embodiment, step 102 may include the following sub-steps: Sub-step S21: Determine whether the user instruction is a simple control instruction or a complex scenario instruction; In some embodiments provided by the present invention, after receiving a user instruction, the temporary central hub first determines its type in order to select an appropriate execution path. The main basis for the determination is the semantic meaning of the instruction, the resources to be called, and whether multi-device coordination is involved.
[0041] Specifically, simple control commands refer to those that involve only a single smart home device and perform a single state change operation. These commands do not rely on predefined complex logic rules, nor do they require coordination between multiple devices. Examples include "turn on the main living room light," "set the air conditioner to 26 degrees Celsius," and "turn off the TV." Their core characteristics are a clear target and a single action. The temporary control center parses the commands; if it identifies that the command contains only a clear device identifier (such as device ID or device name) and a clear basic operation command (such as on / off or setting a value), it classifies it as a simple control command.
[0042] Complex scene instructions refer to those that trigger a series of predefined operation sequences or rely on specific conditional logic. They typically correspond to user-preset automation scenarios or linkage rules, requiring the coordination of multiple smart home devices to work collaboratively according to a specific order, condition, or state. Examples include "start movie viewing mode," "activate home security arming," and "execute goodnight scene." These instructions usually correspond to a scene name or a triggering condition, which is linked to a rule chain consisting of multiple sub-instructions and logical judgments.
[0043] The temporary central processing unit first matches the received instructions against the locally cached intermediate rule code library. If the instruction content (or keyword) matches a cached scene rule identifier or meets the triggering condition of a certain condition rule, it is determined to be a complex scene instruction.
[0044] In one embodiment, sub-step S21 may include the following sub-steps: Sub-step S211: If the user instruction is a voice instruction, the voice instruction is recognized by a smart home device with offline voice recognition function to obtain the instruction text; In one embodiment of the present invention, the user command can be a voice command to adapt to the convenient and natural interaction needs in a smart home environment. Especially in situations where the network is interrupted or the home central hub cannot connect to cloud voice services, the system ensures the availability of basic voice control functions through localized voice processing capabilities.
[0045] When a user issues a voice command (such as "turn on the living room lights"), their voice signal is captured by the microphone array of one or more smart home devices with offline voice recognition capabilities within the home network. These devices are typically smart speakers, smart control screens, or gateway devices with similar capabilities that integrate dedicated voice processing chips and local voice model libraries.
[0046] The captured voice signal is first processed locally on the offline voice device, including noise reduction, echo cancellation, and voice endpoint detection. Then, the device uses its built-in offline speech recognition engine to recognize the processed voice signal. This offline recognition capability covers a predefined set of core voice commands related to device control and scene triggering, ensuring that key voice commands can still be accurately understood even when the network is offline.
[0047] The generated instruction text is encapsulated into a structured request message via a local area network communication protocol and sent to the temporary central hub currently responsible for system coordination. Upon receiving the request, the temporary central hub processes it as if it were a text instruction received from another control terminal (such as an app): that is, it determines the instruction type; if it is a simple control instruction, it issues it directly; if it is a complex scenario instruction, it retrieves, interprets, and executes the corresponding intermediate code cached locally.
[0048] Sub-step S212: Determine whether the user instruction is a simple control instruction or a complex scene instruction based on the instruction text.
[0049] In some embodiments provided by the present invention, after receiving a user instruction, such as a text instruction from a mobile APP, a trigger signal from a smart panel, or text converted by offline speech recognition, the temporary central hub needs to first parse and judge the instruction text to determine whether it is a simple control instruction or a complex scenario instruction, and then select the appropriate execution path.
[0050] A predefined keyword library for complex scene commands is maintained in the cloud, containing features such as "mode," "scene," and "linkage," as well as all user-configured scene names, such as "watching a movie," "leaving home," and "sleeping." Command text is matched against this library. If the command text matches exactly or its core part matches a cached scene name, it is determined to be a complex scene command. Otherwise, it is initially determined to be a simple control command.
[0051] For instructions that do not match directly, the module analyzes their grammatical structure. Simple control instructions typically have a concise structure of an action verb plus a device object or a parameter. Instructions involving complex logic may contain more complex expressions such as conditional clauses or parallel actions. Analyzing sentence components can aid in the determination.
[0052] As a final confirmation step, especially when initially determined to be a complex scenario instruction or an ambiguous instruction, the parsing module will immediately search the locally cached intermediate rule code (such as a JSON rule description chain) to check if a rule named with the instruction text or its keywords exists. If a corresponding executable rule is found, it is confirmed as a complex scenario instruction; otherwise, it is processed as a simple control instruction or an error message is returned.
[0053] Sub-step S22: When the type of the user instruction is a simple control instruction, a control command is sent to the corresponding smart home device through the temporary hub to control the corresponding smart home device; For simple control commands, the temporary central hub directly sends control commands to the target smart home device via the local area network protocol according to the command content. The corresponding smart home device receives the command, performs the corresponding operation, and feeds back the execution result to the temporary central hub.
[0054] Specifically, the temporary hub parses the identifier of the target device (such as device ID or logical address) and the operation command to be executed from the instruction; the temporary hub encapsulates the parsed operation command into a control message that the device can recognize according to the local communication protocol agreed with the target device; the temporary hub directly sends the control message to the target smart home device through the constructed offline autonomous network (such as a local link based on Wi-Fi or Bluetooth Mesh).
[0055] Furthermore, the target smart home device receives and executes the commands in the control message to complete the state change. The smart home device can also feed back the execution result or state confirmation information to the temporary central hub.
[0056] In this process, the temporary central hub acts as an offline command forwarding and control coordination node, replacing the original home host or cloud-based system. Because simple control commands do not require querying or interpreting complex scenario logic rules, they exhibit low processing latency and high reliability, effectively ensuring users' basic need for emergency control of critical equipment in abnormal situations such as network outages.
[0057] Sub-step S23: When the type of the user instruction is a complex scene instruction, the temporary central hub controls multiple smart home devices to perform linkage operations according to the preset scene logic rules and the user instruction.
[0058] For complex scenario commands, the temporary central hub retrieves the corresponding scenario logic rule from the local cache. The temporary central hub's interpretation engine parses and executes the rule, and according to the logic, order, and parameters defined in the rule, it coordinates and sends control commands to multiple related smart home devices in sequence, thereby completing the linked scenario.
[0059] Specifically, for complex scenario commands, the temporary central control unit does not directly issue the original command. Instead, based on the scenario identifier matched by the command, it retrieves the corresponding intermediate rule code (such as a JSON-formatted rule description) from the local cache. Then, the temporary central control unit's local rule interpretation engine parses and executes this intermediate code line by line. This process may include: checking preset conditions (such as time, sensor status), sending control commands to multiple devices sequentially or in parallel, waiting for device status feedback, and determining subsequent steps based on the feedback. Throughout the entire execution process, the temporary central control unit acts as a coordinator, ensuring that multiple devices complete the linkage correctly and orderly according to the rule definition.
[0060] In other embodiments provided by this invention, the temporary central processing unit first parses the instruction and extracts scene identifiers, such as "movie viewing mode" or "away from home arming." Then, it retrieves a rule description chain matching the identifier from its locally cached intermediate rule code library. After finding the corresponding rule, the temporary central processing unit sequentially interprets and executes the steps in the rule description chain. The rule defines the linkage logic, execution conditions, and sequence of operations between multiple devices.
[0061] For example, the intermediate code for the rule to activate the movie-watching mode might contain the following logic in sequence: check the current ambient light sensor value; first, instruct the smart curtain motor to close the curtains; second, dim the main lighting fixtures to the preset brightness; and finally, turn on the audio-visual equipment and switch to the specified input source. The temporary central control unit will, according to this logic, send control commands sequentially to the curtain motor, lighting fixtures, and audio-visual equipment via local area network protocols (such as MQTT, CoAP, etc.), and monitor the response status of each device.
[0062] Taking the movie-watching mode as an example, after the user issues the command via a mobile app or voice, the temporary central hub (such as the elected smart TV) retrieves the corresponding JSON-formatted rule description chain. The interpretation engine executes the following steps in sequence: first, it queries the living room light sensor for values (if the light is too strong, it triggers the next step); then, it sends a "close" command to the smart curtains; next, it adjusts the brightness of the main living room light to 20%; and finally, it turns on the TV and switches it to the HDMI 1 signal source. This series of operations is all coordinated locally by the temporary central hub, without cloud intervention.
[0063] In one embodiment, step 102 may further include: The preset scenario logic rule is that when the cloud and the home host are connected normally, the configuration is made through the cloud and sent to the at least one smart home device through the home host.
[0064] The preset scene logic rules can be configured and defined by the user on the management interface (such as a mobile APP or web console) provided by the cloud server. These rules describe the automated linkage logic between devices, such as "if the light sensor detects that the light value is lower than the threshold, the specified light fixture will be automatically turned on". When the network connection between the cloud and the home host is normal, the cloud server standardizes and encapsulates these configured scene logic rules and actively sends them to the home host through a secure communication link (such as HTTPS).
[0065] The home host acts as the control hub within the home LAN, responsible for receiving these rules and further distributing them to one or more smart home devices with local caching capabilities (such as smart speakers, smart TVs, or smart gateways). Through this process, scene logic rules are configured in the cloud, relayed through the home host, and ultimately distributed and stored on multiple local smart home devices, laying the data foundation for subsequent offline autonomous execution.
[0066] Step 103: Record and store the log data of the smart home device through the temporary central hub; During the operation of the offline autonomous network, in order to ensure the traceability of all control operations and provide a data foundation for subsequent state synchronization, the temporary hub will systematically record and store relevant log data.
[0067] Specifically, the log data includes at least: operation instruction content, recording specific information of the executed instruction, such as instruction type, instruction target device identifier, and instruction parameters; execution result, recording whether the target device successfully responded to the instruction and the device status change after execution; timestamp, accurately recording each time point when the instruction was received, processed, and responded to by the device at the temporary hub, which is a key basis for subsequent conflict resolution in the cloud; and context information, which may selectively record the source that triggered the instruction (such as which control terminal or voice device it came from), the device identifier of the temporary hub, and the network topology snapshot at that time.
[0068] Furthermore, the temporary hub writes the aforementioned log data in a structured format to its local non-volatile memory in real time. This design ensures that even if the temporary hub device experiences an unexpected power outage, the recorded log data will not be lost. After network connectivity is restored, a complete and organized offline operation log can be provided to the cloud. Cloud services can use this log, rather than fragmented status reports from individual devices, to efficiently and accurately reconstruct all state changes that occurred during the offline period and compare and synchronize it with the expected historical state in the cloud.
[0069] In other embodiments provided by this invention, regardless of whether the instruction execution is successful or fails, the temporary central processing unit will generate an execution record, which will be stored locally as part of the log data. This record includes at least: instruction content, instruction type, execution timestamp, target device identifier, and execution result status (success / failure / timeout). This log is used for subsequent network recovery for state synchronization and conflict resolution.
[0070] Step 104: When the connection between the cloud and the home host is restored to normal, the log data is uploaded to the cloud through the temporary hub, the data is synchronized through the cloud, and the control permissions of the temporary hub are released after the synchronization is completed.
[0071] When the network connection is restored, i.e., the communication link between the cloud and the home host is re-established, the system executes the following sequential process to achieve reliable data synchronization and a smooth transfer of control. First, network recovery detection and triggering: the temporary central hub continuously monitors the network status. Once reachability to the cloud is detected—for example, by successfully receiving a heartbeat response from the cloud or establishing a secure connection—it is determined that the connection has been "restored to normal." This detection can be initiated proactively by the temporary central hub or triggered after receiving a specific synchronization command from the cloud.
[0072] Next, log uploads are performed. The temporary central hub encrypts and uploads the log data recorded locally during the offline period—that is, the complete operation records with timestamps—to the cloud server via the restored network connection. After receiving the logs, the cloud server initiates the data synchronization process, the core of which is to execute the conflict resolution algorithm.
[0073] Specifically, the cloud compares its internally maintained "expected device state" based on the last known online state with the "actual execution state" recorded in the logs. It identifies potential state conflicts. For example, during offline periods, a user manually turns off the living room light via a local switch (recorded in the logs), but at the same time, a locally cached "sunset light on" automation rule is also triggered (also recorded in the logs), resulting in a conflicting "off" and "on" operation on the same device.
[0074] The conflict resolution strategy involves automatically resolving conflicts using predefined methods. A typical implementation is based on a latest timestamp priority strategy. The cloud compares all log entries affecting the same device state, and the record with the latest timestamp is taken as the final valid state of the device. For example, if the timestamp of manually turning off the light is later than the timestamp of automatically turning on the light, the final state is confirmed as "off".
[0075] Furthermore, after resolving all identified conflicts, the cloud calculates a consistent global final state and updates its internal device state database. After completing state synchronization and updating, the cloud sends a synchronization completion confirmation command to the temporary central hub. Upon receiving the confirmation command, the temporary central hub automatically releases its control permissions, stops processing new control commands (or forwards them), and broadcasts a notification to other devices in the network that its temporary central hub function has terminated.
[0076] Finally, switching back to normal mode, the original home host (or designated main hub) regains control of the system after sensing the release of temporary hub permissions. The system smoothly transitions back to normal operation mode where the home host directly manages and responds to cloud commands. Afterward, all new commands and automation rules are again determined by the home host or executed in collaboration with the cloud.
[0077] In one embodiment, the method may further include: The log data includes the content of the instructions executed by the smart home device, the execution timestamp, and the status change information of the smart home device.
[0078] In some embodiments provided by the present invention, log data typically includes instruction content, execution timestamp, identifier of the user or device that initiated the instruction, identifier of the controlled device and its status change results, etc. This process ensures that the cloud obtains the entire operation history during offline periods.
[0079] In one embodiment, step 104 may include the following sub-steps: Sub-step S31: Compare the first state data of the smart home device stored in the cloud with the second state data of the smart home device recorded in the log data. Once the network is restored, the temporary central hub uploads the log data recorded during the offline period to the cloud. The cloud then performs a data synchronization and conflict resolution process, specifically including: comparing the cloud's stored first-state data, representing the smart home device's state before or theoretically expected to be offline, with the second-state data recorded in the log data, representing the device's actual operations during the offline period. If the comparison finds inconsistencies, it indicates that there may have been state conflicts during the offline period due to factors such as user manual intervention, automated rule triggering, or network latency.
[0080] Sub-step S32: If the first state data and the second state data are inconsistent, then synchronize with the state data with the most recent timestamp.
[0081] To resolve this conflict, the cloud employs a timestamp-based conflict resolution strategy. This involves comparing the recorded timestamps of the operations corresponding to inconsistent states. Regardless of whether the operation originates from a rule issued from the cloud (first state) or a locally executed instruction (second state), the state data with the most recent timestamp is taken as the final valid state, and state synchronization is performed on all relevant devices accordingly. This strategy ensures that the system state remains consistent with the actual, latest user intent or device response, effectively preventing functional malfunctions caused by state discrepancies.
[0082] For example, during a network outage, a user manually turned off the living room light at 20:05 via a local switch (this operation was recorded in the second state data), while a preset "automatically turn on the light at 20:00" automation rule should have been triggered at 20:00 (its expected state exists in the first state data). After the network was restored, the cloud comparison found a conflict between the living room light's state being "on" (expected) and "off" (actual). By comparing timestamps (20:05 is later than 20:00), the cloud determined that the "off" state with the most recent timestamp was the final valid state and synchronized it to the system, ensuring that the device state was consistent with the actual scenario.
[0083] In some other embodiments provided by the present invention, the final interpretation right of the logic rests with the cloud, because cloud data is continuous while local data is not. If a temporary central hub is converted into a main central hub and data inconsistency occurs, the data subsequently sent from the cloud shall prevail to avoid the escalation of conflicts.
[0084] This invention provides a method for controlling smart home devices, including: when the connection between the cloud and the home host is interrupted, electing a temporary hub from at least one smart home device; receiving user commands through the temporary hub and controlling the corresponding smart home device according to the user commands; recording and storing log data of the smart home device through the temporary hub; when the connection between the cloud and the home host is restored, uploading the log data to the cloud through the temporary hub, synchronizing the data through the cloud, and releasing the control authority of the temporary hub after synchronization is completed. By delegating intelligent decision-making capabilities to local smart home devices, and automatically forming a temporary control network for coordination and cooperation among devices through election, the host can control smart home devices to perform key device operations and automated linkages even when offline. After the network is restored, the status is automatically synchronized and control is returned, eliminating the need for manual intervention by the user during the network outage and recovery phases.
[0085] Reference Figure 2 This document illustrates a flowchart of another smart home device control method provided by an embodiment of the present invention. Specifically, it can be divided into three states: State 1 is a flowchart of a device control and home host control scenario under normal network conditions; State 2 is a flowchart of a local device autonomously electing a temporary home control hub and constructing an offline autonomous network under offline conditions; State 3 is a flowchart of uploading the information of the temporary home hub to the cloud after network recovery, and the cloud performing conflict resolution and state synchronization operations. The specific method is as follows: The implementation of this invention relies on intelligent hub devices deployed within a home local area network, such as dedicated host computers, smart speakers, smart TVs, or gateway devices with computing capabilities, as well as various controlled terminal devices such as smart lights, switches, and sensors. Each intelligent hub device needs to have the system's software modules pre-installed and possess a certain level of local storage and computing capabilities. As shown in the flowchart of State 1, under normal network conditions, the cloud server pre-compiles the user-configured automation scenarios and linkage rules (such as "trigger an alarm if door / window sensors are open and no one is home") to generate a lightweight, locally interpretable and executable intermediate code (such as a rule description chain based on JSON format). This intermediate code is proactively pushed and distributedly cached to the local non-volatile memory of the home hub and various edge devices (such as smart speakers and smart TVs) via a secure link. Simultaneously, the hub and edge devices periodically exchange heartbeat data packets via a local area network (such as Wi-Fi or Ethernet) to continuously synchronize the real-time status of each device (including online status, power type, CPU load, memory usage, and network signal strength RSSI). As shown in the flowchart of state two, regarding interruption detection and autonomous network construction: When a device detects a connection interruption with the cloud or main hub through a heartbeat timeout mechanism (e.g., the loss of 3 consecutive heartbeat packets), edge devices that meet the preset conditions will proactively initiate an election. The election weight comprehensively considers power type (wired power supply takes priority), available computing resources (CPU, memory), and network topology location. For example, a specific algorithm could assign one-quarter weight to each of the power, CPU, memory, and network location, with each weight ranging from 0 to 25, using a scoring system. The final priority is determined by the score. Ultimately, the most stable device is elected as the temporary hub. The new temporary hub broadcasts its leadership and takes over system control, building an offline autonomous network, and performing offline command execution and logging.
[0086] During network outages, user commands are issued via control terminals within the local area network (such as mobile apps or smart panels) or voice commands. Upon receiving a command, the temporary central hub determines its type: for simple control commands (such as "turn on the living room lights"), they are executed directly via local area network protocols (such as MQTT); for complex command scenarios (such as "start movie viewing mode"), the hub retrieves and interprets locally cached intermediate code rules to coordinate related devices; for voice commands, edge devices with offline voice recognition engines (such as smart speakers) first recognize the command before requesting the temporary central hub to coordinate execution. All successfully executed operations are recorded locally by the temporary central hub in the form of a timestamped log. As shown in the state three flowchart, regarding network recovery and state synchronization: Once the network connection is restored, the temporary hub will upload the complete operation logs recorded during the offline period to the cloud server. The cloud service call conflict resolution algorithm will employ a strategy based on the latest timestamp as a priority.
[0087] Specifically, the conflict resolution algorithm mainly makes decisions based on data uploaded locally from the cloud. The cloud has some operation logs, and the local machine has also uploaded some operation logs. The algorithm compares the latest timestamp of the operation between the two, and the one with the latest timestamp is the optimal solution. However, when comparing timestamps, it will determine whether the current operation is legal. If it is not legal, it will be determined that the current operation does not comply with the rules, and the optimal solution will be another one.
[0088] Next, the expected state in the cloud is compared with the local execution logs to handle potential command conflicts (such as a user manually turning off a light during a network outage, but an automation rule simultaneously triggering the light to turn on). Finally, a consistent global final state is calculated. After the state synchronization is complete, the temporary central hub actively releases control, and the system smoothly switches back to the normal mode managed by the original main central hub, thus ensuring the continuity of control behavior and the consistency of the state.
[0089] This invention constructs a highly available smart home system with offline priority. It primarily achieves this by decentralizing intelligent decision-making capabilities to the local device and dynamically networking devices, enabling a usable distributed control system even in offline conditions. This solves the problem of the home host being unable to perform critical emergency operations on certain devices when offline, allowing the host to perform simple but essential emergency tasks even when offline.
[0090] It should be noted that the control method for smart home devices provided in this embodiment of the invention can be executed by a control device for the smart home device, or a control module within the control device for executing a method for loading control of the smart home device. This embodiment of the invention uses the execution of a method for loading control of the smart home device by a control device for the smart home device as an example to illustrate the control method for smart home devices provided in this embodiment of the invention.
[0091] Reference Figure 3 The diagram illustrates a structural block diagram of a control device for a smart home device according to an embodiment of the present invention, which may specifically include the following modules: Election module 301 is used to elect a temporary hub from at least one smart home device when the connection between the cloud and the home host is interrupted; The control module 302 is used to receive user instructions through the temporary central hub and control the corresponding smart home devices according to the user instructions; The recording module 303 is used to record and store the log data of the smart home device through the temporary central hub. The synchronization module 304 is used to upload the log data to the cloud through the temporary hub when the connection between the cloud and the home host is restored to normal, synchronize the data through the cloud, and release the control authority of the temporary hub after the synchronization is completed.
[0092] In one embodiment, the election module includes: An acquisition submodule is used to acquire status parameters of the at least one smart home device; the status parameters include at least one of device power type, available computing resources, and network topology location. An election submodule is used to elect a temporary hub from the at least one smart home device based on the status parameters of the at least one smart home device.
[0093] In one embodiment, the control module includes: The determination submodule is used to determine whether the user instruction is a simple control instruction or a complex scenario instruction; The first control submodule is used to send control commands to the corresponding smart home devices through the temporary central hub when the user instruction is a simple control instruction, so as to control the corresponding smart home devices. The second control submodule is used to control multiple smart home devices to perform linkage operations through the temporary central hub according to preset scene logic rules and the user instruction when the user instruction is a complex scene instruction.
[0094] In one embodiment, the device further includes: The preset scenario logic rule is that when the cloud and the home host are connected normally, the configuration is done through the cloud. The sending submodule is used to send the preset scene logic rules to the at least one smart home device through the home host.
[0095] In one embodiment, the determining submodule includes: The recognition unit is configured to, if the user instruction is a voice instruction, recognize the voice instruction through a smart home device with offline voice recognition function to obtain the instruction text; The determination unit module is used to determine whether the user instruction is a simple control instruction or a complex scenario instruction based on the instruction text.
[0096] In one embodiment, the log data includes the content of the instructions executed by the smart home device, the execution timestamp, and the status change information of the smart home device.
[0097] In one embodiment, the synchronization module includes: The comparison submodule is used to compare the first state data of the smart home device stored in the cloud with the second state data of the smart home device recorded in the log data. The synchronization submodule is used to synchronize with the state data that has the most recent timestamp if the first state data is inconsistent with the second state data.
[0098] The control device for smart home devices in this embodiment of the invention can be a device, or a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. For example, mobile electronic devices can be mobile phones, tablets, laptops, PDAs, in-vehicle electronic devices, wearable devices, ultra-mobile personal computers (UMPCs), netbooks, or personal digital assistants (PDAs), etc., while non-mobile electronic devices can be servers, network-attached storage (NAS), personal computers (PCs), televisions (TVs), ATMs, or self-service machines, etc. This embodiment of the invention does not impose specific limitations.
[0099] The control device for the smart home device in this embodiment of the invention can be a device with an operating system. This operating system can be Android, iOS, or other possible operating systems; this embodiment of the invention does not impose specific limitations.
[0100] The control device for smart home devices provided in this embodiment of the invention can achieve Figures 1 to 2 The various processes implemented by the control device of the smart home device in the method embodiment will not be described again here to avoid repetition.
[0101] This invention provides a control device for smart home devices, comprising: an election module for electing a temporary hub from at least one smart home device when the connection between the cloud and the home host is interrupted; a control module for receiving user instructions through the temporary hub and controlling the corresponding smart home device according to the user instructions; a recording module for recording and storing log data of the smart home device through the temporary hub; and a synchronization module for uploading the log data to the cloud through the temporary hub when the connection between the cloud and the home host is restored, synchronizing the data through the cloud, and releasing the control authority of the temporary hub after synchronization is completed. By delegating intelligent decision-making capabilities to local smart home devices, the devices automatically form a temporary control network for coordination and cooperation through election, enabling the host to control smart home devices to perform key device operations and automated linkages even when offline. After the network is restored, the status is automatically synchronized and control is returned, eliminating the need for manual intervention by the user during network outages and recovery. This invention also provides a readable storage medium storing a program or instructions that, when executed by a processor, implement the various processes of the above-described smart home device control method embodiments and achieve the same technical effects. To avoid repetition, these will not be described further here.
[0102] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0103] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of the present invention is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0104] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0105] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of the present invention.
Claims
1. A control method for a smart home device, characterized in that, include: When the connection between the cloud and the home host is interrupted, a temporary hub is elected from at least one smart home device; The temporary central hub receives user commands and controls corresponding smart home devices according to the user commands. The temporary central hub records and stores the log data of the smart home devices. When the connection between the cloud and the home host is restored to normal, the log data is uploaded to the cloud through the temporary hub, the data is synchronized through the cloud, and the control permissions of the temporary hub are released after the synchronization is completed.
2. The control method for smart home devices according to claim 1, characterized in that, The selection of a temporary hub from at least one smart home device includes: Obtain the status parameters of the at least one smart home device; the status parameters include at least one of the device power type, available computing resources, and network topology location. Based on the status parameters of the at least one smart home device, a temporary hub is elected from the at least one smart home device.
3. The control method for smart home devices according to claim 1, characterized in that, The step of controlling the corresponding smart home devices according to the user instructions includes: The user instruction is determined to be either a simple control instruction or a complex scenario instruction; When the user instruction is a simple control instruction, the temporary central hub sends a control command to the corresponding smart home device to control the corresponding smart home device. When the user instruction is a complex scenario instruction, the temporary central control unit controls multiple smart home devices to perform linked operations according to preset scenario logic rules and the user instruction.
4. The control method for smart home devices according to claim 3, characterized in that, Also includes: The preset scenario logic rule is that when the cloud and the home host are connected normally, the configuration is made through the cloud and sent to the at least one smart home device through the home host.
5. The control method for smart home devices according to claim 3, characterized in that, Determining whether the user instruction is a simple control instruction or a complex scenario instruction includes: If the user command is a voice command, the voice command is recognized by a smart home device with offline voice recognition capabilities to obtain the command text; Based on the instruction text, the user instruction is determined to be either a simple control instruction or a complex scenario instruction.
6. The control method for smart home devices according to claim 1, characterized in that, The log data includes the content of the instructions executed by the smart home device, the execution timestamp, and the status change information of the smart home device.
7. The control method for smart home devices according to claim 6, characterized in that, The data synchronization via the cloud includes: The first state data of the smart home device stored in the cloud is compared with the second state data of the smart home device recorded in the log data. If the first state data is inconsistent with the second state data, then the state data with the most recent timestamp will be used for synchronization.
8. A device for controlling smart home devices, characterized in that, include: An election module is used to elect a temporary hub from at least one smart home device when the connection between the cloud and the home host is interrupted; The control module is used to receive user commands through the temporary central hub and control the corresponding smart home devices according to the user commands. A recording module is used to record and store the log data of the smart home devices through the temporary central hub. The synchronization module is used to upload the log data to the cloud through the temporary hub when the connection between the cloud and the home host is restored to normal, synchronize the data through the cloud, and release the control permissions of the temporary hub after the synchronization is completed.
9. An electronic device, characterized in that, It includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein the program or instructions, when executed by the processor, implement the steps of the control method for the smart home device as described in claims 1-7.
10. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the control method for the smart home device as described in claims 1-7.