Rule engine scene linkage method and system based on edge gateway

The edge gateway-based rule engine system addresses IoT system issues by managing device linkage rules and conflict detection, reducing network traffic and cloud load, and ensuring scene linkage continuity.

CN119135783APending Publication Date: 2024-12-13NANJING AOTO ELECTRONICS CO LTD
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202411322030.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-23
Publication Date
2024-12-13

AI Technical Summary

Technical Problem

Existing IoT systems rely on cloud rule engines, which face issues such as high network traffic consumption, cloud load pressure, network disconnection affecting core business, fixed application scenarios requiring custom development, and failure of scene linkage during network interruptions.

Method used

A rule engine scenario linkage method and system based on an edge gateway, incorporating device linkage rule management, conflict detection, and rule execution on the edge end, allowing independent operation and reducing cloud server load.

Benefits of technology

Reduces network traffic and cloud load, enables independent operation of edge gateways, and ensures scene linkage even during network disconnections, preventing automation failures.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119135783A_ABST
    Figure CN119135783A_ABST
Patent Text Reader

Abstract

The invention discloses a rule engine scene linkage method and system based on an edge gateway, and relates to the technical field of scene linkage. The rule engine scene linkage method based on the edge gateway comprises the following steps: adding equipment linkage rule management according to a preset rule through a cloud platform; wherein the equipment linkage rule management comprises rule addition, rule deletion, rule query and rule modification; acquiring operation state information of the equipment end through the edge end, generating an equipment linkage fact, and adding the equipment linkage fact into a fact library of a preset rule engine; and matching a first equipment linkage rule below the equipment linkage rule management with the equipment linkage facts based on a preset rule engine. According to the invention, the computing pressure of the cloud server side can be reduced, and the purpose that the edge gateway independently analyzes the application rule and performs scene linkage when the edge gateway is disconnected from the cloud server is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of scene linkage technology, and in particular to a rule engine scene linkage method and system based on an edge gateway. Background Art

[0002] In the existing IoT systems, cloud rule engines are mostly used. The edge gateway transmits data to the cloud platform. The cloud platform makes decisions based on the received data and then sends the decision command to the IoT gateway. The edge gateway assembles the received decision command into a protocol frame to control the industrial equipment. In this process, if there is a network delay or disconnection, the cloud rule engine will fail. In addition, the cloud rule engine has at least the following defects: 1. In the cloud rule engine, the edge gateway needs to report all the collected data, and it is impossible to report only the valid data required by the application, resulting in a huge network transmission volume, high network bandwidth requirements, and high network traffic consumption; 2. In the cloud rule engine, a large amount of data is calculated on the cloud platform, resulting in high cloud load pressure; 3. In the cloud rule engine, the calculation results of the cloud platform must first be sent to the IoT middleware and then to the edge gateway. If the network is disconnected during the data transmission process, the core business will be affected; 4. In the cloud rule engine, the application scenario of the edge gateway is relatively fixed, and it is impossible to customize the business logic according to the rules. Custom development is required in many scenarios, which increases the application cost and difficulty of the IoT system; In addition, there are multiple audio-visual gateways in the outlets, and scene linkage needs to be executed when the external network is interrupted. This will cause the automation of some cross-gateway device linkages to fail to be triggered normally, resulting in the failure of automatic scene control. No effective solution has been proposed yet. Summary of the invention

[0003] Purpose of the invention: To provide a rule engine scenario linkage method and system based on edge gateway to at least solve one of the problems existing in the above-mentioned prior art.

[0004] Technical solution: A rule engine scenario linkage method based on an edge gateway, comprising: adding device linkage rule management according to preset rules through a cloud platform; wherein the device linkage rule management includes: rule addition, rule deletion, rule query and rule modification; obtaining the operating status information of the device end through the edge end and generating device linkage facts, and adding the device linkage facts to the fact library of the preset rule engine; matching the first device linkage rule at the bottom of the device linkage rule management with the device linkage facts based on the preset rule engine; generating a first device control instruction for controlling the corresponding device from the first device linkage rule according to the matching result; sending the first device control instruction to the corresponding device on the device end according to the communication protocol in the preset rule engine, and generating a control result and pushing it to the preset smart end.

[0005] Preferably, the operating status information of the device end is obtained through the edge end and the device linkage facts are generated, and the device linkage facts are added to the fact library of the preset rule engine, including: the edge end uses distributed rules to execute on multiple edge devices or edge gateways.

[0006] Preferably, device linkage rule management is added according to preset rules through the cloud platform; wherein, the device linkage rule management includes: rule addition, rule deletion, rule query and rule modification, including: the cloud platform classifies the rules based on the rule screening algorithm of the environmental context, and excludes redundant rules according to the preset priority and execution area after classification to generate linkage rules.

[0007] Preferably, the cloud platform classifies the rules based on the rule screening algorithm of the environmental context, and excludes redundant rules according to the preset priority and execution area of ​​the classified rules. After the linkage rules are generated, it also includes: judging the conflicts between the rules based on the conflict detection algorithm of multivariate information modeling, extracting the key information in the linkage rules, and screening out the rules with the same priority and execution area; modeling the information used for conflict detection, detecting the opposite conflicts of the defined execution actions, condition coverage conflicts, condition mutual exclusion conflicts, rule loop conflicts and environmental conflicts through the conflict detection algorithm, and checking the rule engine and execution scenario actions suitable for execution.

[0008] Preferably, the cloud platform classifies the rules based on the rule screening algorithm of the environmental context, and excludes redundant rules according to the preset priorities and execution areas of the classified rules to generate linkage rules, including: pre-classifying the linkage rules into rule types according to the functions and characteristics of the smart devices, and dividing the corresponding linkage rules into corresponding types; wherein the rule types include: smart security, environmental monitoring, brightness adjustment, audio and video control, and electrical control; by pre-setting extended information, when formulating linkage rules, it is necessary to add extended information and automatically store it in the rule screening database; wherein the extended information includes: priority and execution area; setting different priorities for rule types according to preset event requirements, and linkage rules in types with high priorities will be executed first; and dividing a pre-execution range for each device.

[0009] As a preferred method, a conflict detection algorithm based on multivariate information modeling is used to determine conflicts between rules, extract key information from linkage rules, and screen out rules with the same priority and execution area; the information used for conflict detection is modeled, and through the conflict detection algorithm, opposite conflicts of defined execution actions, condition coverage conflicts, condition mutual exclusion conflicts, rule loop conflicts, and environmental conflicts are detected, and the rule engine and execution scenario actions suitable for execution are checked, including: when the first user presets a linkage rule, corresponding Json format data is generated according to the information of the linkage rule; wherein the Json format data includes: the user ID of the linkage rule, the type of rule, the priority of the rule, and the type of the rule. Priority, rule execution area, rule execution time, sensor information and actuator information; extract important information from Json data and store it in the rule screening database; extract information related to conflict detection and model it according to preset rules to generate a rule model; based on rule characteristics, information used in modeling and relevant personnel's views on the types of conflicts generated between linkage rules, classify the conflicts generated between linkage rules according to preset requirements; based on the modeling of rules and the classification of rule conflicts, and the preset rule conflict detection algorithm, determine whether there are conflicts in opposite execution actions, condition coverage conflicts, condition mutual exclusion conflicts, environmental conflicts and rule loop conflicts between the rules.

[0010] Preferably, based on the rule characteristics, the information used in modeling and the types of conflicts between the linkage rules by relevant personnel, the conflicts between the linkage rules are classified according to preset requirements, including: when two rules are executed in the same time period and the conflict occurs on the same executor, it is defined as a direct conflict; wherein the direct conflict includes: opposite execution action conflict, condition coverage conflict and condition mutual exclusion conflict; when two rules are executed in the same time period and the conflict does not occur on the same executor, it is defined as an indirect conflict; wherein the indirect conflict includes: environmental conflict and rule loop conflict.

[0011] Preferably, based on the modeling of rules and the classification of rule conflicts, the classified data is subjected to a preset rule conflict detection algorithm to determine whether there are conflicts in opposite execution actions, condition coverage conflicts, condition mutual exclusion conflicts, environmental conflicts and rule loop conflicts between the rules, including: defining a preset algorithm, "0" represents that there is no conflict of this type, and "1" represents that there is a conflict of this type; traversing each rule in the rule screening database, and performing each type of conflict detection and judgment with the linkage rules formulated by the first user, and outputting the corresponding conflict type.

[0012] Preferably, each rule in the rule screening database is traversed, and each type of conflict is detected and judged with the linkage rules formulated by the first user. After the corresponding conflict type is output, it also includes: by detecting the conflict type, reminding the first user to select rules of different times when creating rules; when there are multiple device types, there will be multiple queues, or, when there is only one device type, the device has multiple queues, which is a multi-queue scenario; the multi-queue scenario includes a first queue, a second queue, a third queue and a fourth queue; wherein the first queue corresponds to the first available ring, the second queue corresponds to the second available ring, the third queue corresponds to the third available ring, and the fourth queue corresponds to the fourth available ring; the first queue has a first descriptor; the second queue has a second descriptor and a third descriptor; the third queue has a fourth descriptor, a fifth descriptor and a sixth descriptor; the fourth queue has a seventh descriptor and an eighth descriptor.

[0013] Preferably, each rule in the rule screening database is traversed, and each type of conflict detection and judgment is performed with the linkage rule formulated by the first user, and the corresponding conflict type is output, including: performing execution action conflict detection on the rule model; when there are multiple trigger conditions, based on the sensor ID corresponding to each first trigger condition in the rule model, sorting each first trigger condition in lexicographic order, and calculating the first hash value corresponding to each first trigger condition; at the same time, based on the sensor ID corresponding to each second trigger condition in the existing rule, sorting each second trigger condition in lexicographic order, and calculating the second hash value corresponding to each second trigger condition; if the calculated first hash value is the same as the second hash value, indicating that the trigger conditions of the rules are the same, then judging whether the execution action of the rule model is mutually exclusive with the execution action of the existing rule; determining the existing rule with the same executor ID as the corresponding executor of the rule model, and judging whether the execution action of the rule model is mutually exclusive with the execution action of the existing rule; when it is detected that the execution action of the rule model is mutually exclusive with the execution action of the existing rule, it is determined that there is an execution action conflict between the rule model and the existing rule, and the detection ends; if the execution action is not detected to be mutually exclusive, then executing the conflict detection of the next scenario type.

[0014] In order to achieve the above-mentioned purpose, according to another aspect of the present application, a rule engine scenario linkage system based on an edge gateway is provided.

[0015] According to the edge gateway-based rule engine scenario linkage system of the present application, it includes: a preset device linkage rule management module, which is used to add device linkage rule management according to preset rules through a cloud platform; wherein the device linkage rule management includes: rule addition, rule deletion, rule query and rule modification; a generation and addition module, which is used to obtain the operating status information of the device end through the edge end and generate device linkage facts, and add the device linkage facts to the fact library of the preset rule engine; a matching module, which is used to match the first device linkage rule at the bottom of the device linkage rule management with the device linkage facts based on the preset rule engine; a control module, which is used to generate a first device control instruction for controlling the corresponding device according to the matching result from the first device linkage rule; an instruction sending module, which is used to send the first device control instruction to the corresponding device on the device end according to the communication protocol in the preset rule engine, and generate a control result and push it to the preset smart end.

[0016] Beneficial effect: In the embodiment of the present application, a method based on edge gateway scene linkage is adopted, and device linkage rule management is added according to preset rules through the cloud platform; wherein, the device linkage rule management includes: rule addition, rule deletion, rule query and rule modification; the operation status information of the device end is obtained through the edge end and the device linkage fact is generated, and the device linkage fact is added to the fact library of the preset rule engine; based on the preset rule engine, the first device linkage rule at the bottom of the device linkage rule management is matched with the device linkage fact; according to the matching result, the first device linkage rule generates a first device control instruction to control the corresponding device; the first device control instruction is sent to the corresponding device on the device end according to the communication protocol in the preset rule engine, and the control result is generated and pushed to the preset intelligent end, so as to achieve the purpose of applying the existing cloud server communication protocol parsing, parsing application rules and partial positioning calculation to the edge gateway end, thereby reducing the computing pressure on the cloud server end and making the cloud server structure simple; and giving the edge gateway more functions, when the edge gateway is disconnected from the cloud server, the edge gateway independently parses the application rules; the edge protocol conversion device not only establishes In addition to the communication channel between traditional devices and the cloud, it also has the ability to operate independently. When it is offline and disconnected from the network, it can operate independently through algorithms to ensure that traditional devices can also operate safely and achieve the technical effect of scene linkage, thereby solving the current network delay or network disconnection situation, which will make the cloud rule engine invalid. In addition, the cloud rule engine has at least the following defects: in the cloud rule engine, the edge gateway needs to report all the collected data, and it is impossible to report only the valid data required by the application, resulting in huge network transmission volume, high network bandwidth requirements, and high network traffic consumption; a large amount of data is calculated on the cloud platform, resulting in high cloud load pressure; the calculation results of the cloud platform must first be sent to the Internet of Things middleware, and then to the edge gateway. If the network is disconnected during the data transmission process, the core business will be affected; the application scenarios of the edge gateway are relatively fixed, and the business logic cannot be customized according to the rules. Custom development is required in many scenarios, which increases the application cost and difficulty of the Internet of Things system; and there are multiple audio-visual gateways in the outlets, and scene linkage needs to be executed when the external network is interrupted, which will cause some cross-gateway device linkage automation to fail to trigger normally, resulting in technical problems such as failure of automatic scene control. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 It is a flow chart of a rule engine scenario linkage method based on an edge gateway according to an embodiment of the present application; Figure 2 It is a flow chart of a rule engine scenario linkage method based on an edge gateway according to a preferred embodiment of the present application; Figure 3 It is a structural diagram of a rule engine scenario linkage system based on an edge gateway according to an embodiment of the present application; Figure 4 It is a structural diagram of an electronic device according to the edge gateway-based rule engine scenario linkage method of an embodiment of the present application. DETAILED DESCRIPTION

[0018] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only embodiments of a part of the present application, rather than all of the embodiments.

[0019] It is important to know that IoT platforms usually have edge computing capabilities, which deploy edge computing nodes close to devices to process the data generated by the devices. In the case of network disconnection or poor network signal, edge computing nodes can cache device data, and automatically synchronize device data to the cloud when the network signal returns to normal. The deployment of edge computing nodes can effectively prevent the loss of device data.

[0020] The existing cloud server communication protocol parsing, parsing application rules and part of the positioning calculation are applied to the edge gateway, which reduces the computing pressure on the cloud server and simplifies the cloud server structure. It also gives the edge gateway more functions. When the edge gateway is disconnected from the cloud server, the application rules are independently parsed by the edge gateway.

[0021] The present application also discloses a network access method and an offline operation method of an acoustic and optical gateway of an edge protocol conversion device as follows: C1. The acoustic and optical gateway sends the application model of the terminal device to the cloud server.

[0022] C2. The cloud server generates application rules based on the application model, which includes the configuration information of the terminal device.

[0023] C3. The edge protocol conversion device obtains an application rule from the cloud server; parses the application rule to obtain configuration information of a device to be configured.

[0024] C4. The edge protocol conversion device stores the configuration information and sends it to the acoustic and optical gateway. The acoustic and optical gateway initiates heartbeat, network access message and other messages according to the configuration information through three-way handshake, and actively establishes a connection with the edge protocol conversion device. The device configuration and network access are completed.

[0025] C5. After the configuration of the terminal device is completed, when a failure occurs in the terminal device, the edge protocol conversion device sends the configuration information to a backup device, which has the same device type as the terminal device. C6. If the edge protocol conversion device is offline, the edge protocol conversion device automatically matches the configuration information of the device to be connected to the network according to the cached application rules, completing the device configuration and network access.

[0026] The rule engine module on the IoT platform provides data transmission and device linkage functions. Users can configure linkage rules to allow device data to be transmitted to other devices, thereby realizing device linkage. Or the data generated by different devices can be forwarded to the destination to complete tasks such as data storage and processing. Through the use of the rule engine, complex rules formulated by users can also be easily completed, which not only provides convenience for users but also greatly improves the operating efficiency of the system.

[0027] When the device behavior (referring to a certain value in the data reported by the device) or system time meets the conditions set in the rules set by the user, the actions set by these rules will be triggered, such as triggering an alarm, sending a message, etc., and these rules are called linkage rules in this article. By formulating these linkage rules, the device can automatically perform the corresponding actions, which provides great convenience for users. On trigger platforms and IoT platforms, users usually specify rules in the form of "if the condition is triggered, then perform a specific action". For example, in the smart home scenario, "if the weather is clear, then open the window", "when the temperature is below 10 degrees Celsius, then turn on the air conditioner and keep the temperature at 28 degrees Celsius".

[0028] According to the form in which these rules are formulated, they can correspond to different IoT devices, and these devices can be classified into two types: sensors and actuators. Sensors are a very broad definition here, and of course they can also be defined as triggers. In device linkage, sensors are generally responsible for sensing the environmental status around the device, or sensing the time of the system, and then judging whether these meet the conditions in the linkage rules. When the conditions in the rules set by the user are met, the actuator will be triggered to perform the corresponding actions. Examples of linkage rules corresponding to sensors include "temperature below 20 degrees Celsius", "PM2.5 above 100" or "when the brightness is 100Lux". Actuators are used to complete the actions set in the linkage rules, and the actuators correspond to linkage rules; Examples include "turn on the lights", "close the windows", or "turn on the air conditioning".

[0029] like Figure 1-2 As shown, according to an embodiment of the present invention, a rule engine scenario linkage method based on an edge gateway is provided, and the method includes the following steps S101 to S105: Step S101: adding device linkage rule management according to preset rules through the cloud platform; wherein the device linkage rule management includes: rule addition, rule deletion, rule query and rule modification; It can achieve good rule management and rule storage effects on the cloud platform, thus providing a basis and guarantee for subsequent processing.

[0030] According to an embodiment of the present invention, preferably, obtaining the running status information of the device end through the edge end and generating the device linkage fact, and adding the device linkage fact to the fact library of the preset rule engine includes: The edge end uses distributed rules to execute on multiple edge devices or edge gateways.

[0031] According to an embodiment of the present invention, preferably, device linkage rule management is added according to preset rules through a cloud platform; wherein the device linkage rule management includes: rule addition, rule deletion, rule query and rule modification, including: The cloud platform classifies the rules based on the rule screening algorithm of the environmental context, and eliminates redundant rules according to the preset priorities and execution areas after classification to generate linkage rules.

[0032] Specifically, the rule screening algorithm based on environmental context: the rules are screened and classified by analyzing the current environmental context (such as user location, device status, time, etc.). This means that the selection and processing of rules are dynamic and depend on real-time environmental information.

[0033] Rule classification: The filtering algorithm classifies rules by type or function. This classification helps the system manage and apply rules more effectively. For example, rules can be classified by application scenario, operation type, or priority.

[0034] Preset priorities and execution areas: Preset priority: Set a priority for each rule to determine the order in which the rules are processed. High-priority rules are executed before low-priority rules. Execution area: Define the scope or conditions to which the rule applies. For example, some rules may only be effective in a specific location, at a specific time, or on a specific device. Exclude redundant rules: After classification and sorting, the system excludes unnecessary or redundant rules. This helps reduce rule conflicts, improve rule execution efficiency, and avoid unnecessary calculations and operations.

[0035] Generate linkage rules: The system will generate linkage rules. These rules are screened and optimized, and can effectively respond to changes in environmental context and trigger corresponding actions or responses.

[0036] According to an embodiment of the present invention, preferably, the cloud platform classifies the rules based on the rule screening algorithm of the environmental context, and excludes redundant rules according to the preset priorities and execution areas of the classified rules to generate linkage rules, including: Pre-classify linkage rules into rule types according to the functions and characteristics of smart devices, and classify corresponding linkage rules into corresponding types; wherein the rule types include: smart security, environment monitoring, brightness adjustment, audio and video control, and electrical appliance control; Specifically, smart security: Smart security represents the safety protection within the building. The corresponding linkage rules include, "When abnormal images appear in the monitoring, the alarm system is activated", "When there is no one in the room and the doors and windows are open, a text message is sent to the user to notify him", etc.

[0037] Environmental monitoring: Environmental monitoring can sense changes in the surrounding environment through the sensors of IoT devices. The corresponding linkage rules include, "When the indoor temperature is greater than 30 degrees Celsius, automatically turn on the air conditioner to reduce the temperature to 26 degrees Celsius", "When the air humidity is less than 20%, turn on the humidifier", etc.

[0038] Brightness adjustment: Brightness adjustment can adjust the light intensity in the room. The corresponding linkage rules include, "When the indoor light is less than 20 Lux, turn on the indoor lights", "Automatically open the indoor curtains during the day", etc.

[0039] Audio and video control: Audio and video control includes controlling LED display screens, speakers, etc. The corresponding linkage rules include, "Turn on the LED display screen between 9:00-18:00", "Automatically adjust the volume of the speakers when the decibel level reaches 70 or above", etc.

[0040] Appliance control: Appliance control includes controlling smart cleaning robots, smart refrigerators, etc. The corresponding linkage rules include, "automatically clean the indoor environment between 16:00-17:00", "automatically adjust the refrigerator to energy-saving mode between 00:00-8:00", etc.

[0041] By classifying the rules into the five types mentioned above, the corresponding linkage rules can be classified into the corresponding types when creating the rules, which provides a basis for improving the efficiency of conflict detection in the future.

[0042] By presetting the extended information, when formulating linkage rules, the extended information needs to be added and automatically stored in the rule screening database; wherein the extended information includes: priority and execution area; Specifically, in order to improve the efficiency of conflict detection, this application sets extended information. When formulating linkage rules, this extended information needs to be added (on the IoT platform, users specify scene linkage rules, and users can manually select these extended conditions, such as time, execution area, device type, priority, whether emergency termination is possible, etc. If the user does not add it manually, the platform uses the default value) and automatically stores it in the rule screening database. The extended information includes two parts, as follows: 1. Priority The above five rule types have different priorities. The linkage rules in the high-priority type will be executed first, for example, "the smart security type will set its priority to 5, which means it has the highest priority." Therefore, adding different priorities to different types of rules reduces the complexity of conflict detection and greatly improves the efficiency of detection.

[0043] The specific priority settings are listed as follows: Photovoltaic power generation events of photovoltaic inverters (priority 1), value detection events of smart circuit breakers (priority 1), air conditioning state change events of air conditioners (priority 2), color temperature or brightness change events of color temperature lamps (priority 2), brightness value change events of lighting equipment (priority 2), color change events of RGB light strips (priority 2), brightness value change events of self-service devices (priority 2), position change events of curtains (priority 2), button change events of scene panels (priority 5), all-in-one air quality events of air quality sensors (priority 3), temperature and humidity change events of temperature and humidity sensors (priority 3), presence or absence events reported by human infrared motion sensors (priority 5), presence or absence events reported by human presence sensors (priority 4), light intensity events reported by light sensors (priority 4), meter value detection events reported by smart meters (priority 1), and water meter value detection events reported by smart water meters (priority 1).

[0044] 2. Execution area Under normal circumstances, only devices in the same area will have conflicts. This application divides an execution range for each device, that is, the range that the device can affect is its execution area. For example, "A1 and A2 are two different smart buildings, so the devices in these two buildings do not affect each other." Another example is, "There are 80 floors in the A1 building, but the equipment on each floor is responsible for the normal operation of the floor, so in this case, the equipment on different floors does not affect each other." In fact, the scope of the device can be further subdivided. For example, "There are different closed spaces (conference rooms, offices, cafeterias, etc.) on the 10th floor of A1, and the equipment in these different spaces does not affect each other." Therefore, based on the above situation, when performing conflict detection, it is only necessary to detect the linkage rules with the same device execution area. By establishing extended information, in subsequent rule conflict detection, it is only necessary to detect rules of the same type and the same execution area.

[0045] Set different priorities for rule types according to preset event requirements, and linkage rules in types with higher priorities will be executed first; A pre-execution scope is allocated to each device.

[0046] Step S102: acquiring the running status information of the device end through the edge end and generating a device linkage fact, and adding the device linkage fact to a fact library of a preset rule engine; It can achieve the effect of generating device linkage facts, and at the same time, it can also add the device linkage facts to the fact library of the preset rule engine, thereby achieving a good data adding effect.

[0047] Step S103: matching the first device linkage rule at the bottom of the device linkage rule management with the device linkage fact based on a preset rule engine; A good matching effect between the first device linkage rule and the device linkage fact can be achieved.

[0048] Step S104, generating a first device control instruction for controlling a corresponding device from the first device linkage rule according to the matching result; It can achieve accurate control instruction generation effect.

[0049] Specifically, rule matching: rules are matched with actual conditions based on the environmental context and current conditions. The matching results determine which rules are applicable to the current environment and device status.

[0050] Determine linkage rules for the first device: Select linkage rules applicable to the first device from the matching results. These rules define how the first device should operate or adjust under certain conditions.

[0051] Generate control instructions: Generate control instructions based on the selected first device linkage rules. These instructions detail the operations that the first device needs to perform. The instructions may include the device's on / off status, adjustment parameters, and actions to be performed.

[0052] Control the first device: Send the generated control instruction to the first device, and the device will perform the operation as required after receiving the instruction. This usually involves the design of communication protocols and instruction formats to ensure that the instructions can be correctly parsed and executed by the device.

[0053] Feedback and Adjustment: After the first device executes the control instruction, the system will receive feedback (such as status updates, execution results, etc.). Based on the feedback information, the system may need to further adjust or optimize the rules and instructions to ensure that the device works as expected.

[0054] Step S105: sending the first device control instruction to the corresponding device on the device side according to the communication protocol in the preset rule engine, and generating a control result and pushing it to the preset smart terminal; It is possible to send control instructions to the corresponding device on the device side through the communication protocol, thereby achieving a good device side control effect.

[0055] From the above description, it can be seen that the present application achieves the following technical effects: In the embodiment of the present application, a method based on edge gateway scene linkage is adopted, and device linkage rule management is added according to preset rules through the cloud platform; wherein, the device linkage rule management includes: rule addition, rule deletion, rule query and rule modification; the operation status information of the device end is obtained through the edge end and the device linkage fact is generated, and the device linkage fact is added to the fact library of the preset rule engine; based on the preset rule engine, the first device linkage rule at the bottom of the device linkage rule management is matched with the device linkage fact; according to the matching result, the first device linkage rule generates a first device control instruction to control the corresponding device; the first device control instruction is sent to the corresponding device on the device end according to the communication protocol in the preset rule engine, and the control result is generated and pushed to the preset intelligent end, so as to achieve the purpose of applying the existing cloud server end communication protocol parsing, parsing application rules and partial positioning calculation to the edge gateway end, thereby reducing the computing pressure on the cloud server end and making the cloud server structure simple; and giving the edge gateway more functions, when the edge gateway is disconnected from the cloud server, the edge gateway independently parses the application rules; the edge protocol conversion device establishes the traditional In addition to the communication channel between the device and the cloud, it also has the ability to operate independently. When it is offline and disconnected from the network, it can operate independently through algorithms to ensure that traditional devices can also operate safely and achieve the technical effect of scene linkage, thereby solving the current network delay or network disconnection situation, which will make the cloud rule engine invalid. In addition, the cloud rule engine has at least the following defects: in the cloud rule engine, the edge gateway needs to report all the collected data, and it is impossible to report only the valid data required by the application, resulting in huge network transmission volume, high network bandwidth requirements, and high network traffic consumption; a large amount of data is calculated on the cloud platform, resulting in high cloud load pressure; the calculation results of the cloud platform must first be sent to the Internet of Things middleware, and then to the edge gateway. If the network is disconnected during the data transmission process, the core business will be affected; the application scenarios of the edge gateway are relatively fixed, and the business logic cannot be customized according to the rules. Custom development is required in many scenarios, which increases the application cost and difficulty of the Internet of Things system; and there are multiple audio-visual gateways in the outlets, and scene linkage needs to be executed when the external network is interrupted, which will cause some cross-gateway device linkage automation to fail to trigger normally, resulting in technical problems such as failure of automatic scene control.

[0056] According to an embodiment of the present invention, preferably, the cloud platform classifies the rules based on the rule screening algorithm of the environmental context, and excludes redundant rules according to the preset priorities and execution areas of the classified rules, and after generating the linkage rules, further includes: The conflict detection algorithm based on multivariate information modeling determines conflicts between rules, extracts key information from linkage rules, and selects rules with the same priority and execution area; The information used for conflict detection is modeled, and through the conflict detection algorithm, the opposite conflicts of defined execution actions, condition coverage conflicts, condition mutual exclusion conflicts, rule loop conflicts and environmental conflicts are detected, and the rule engine and execution scenario actions suitable for execution are checked.

[0057] It can solve the problem that the surge in the number of rules will lead to more and more inevitable conflicts between IoT devices, which will further lead to more and more unexpected security issues.

[0058] For example, multiple users may formulate different rules on the same platform to meet their own needs based on their own situations. If two linkage rules happen to be executed in the same time period, causing the execution actions of the device to be in opposite states, conflicts will occur. If such conflicts occur in some smart security scenarios, the environment around the device will be in an unsafe state. In serious cases, it may even threaten the lives of people in the scene.

[0059] According to an embodiment of the present invention, preferably, a conflict detection algorithm based on multivariate information modeling is used to determine conflicts between rules, extract key information in the linkage rules, and screen out rules with the same priority and execution area; model the information used for conflict detection, and detect the opposite conflict of defined execution actions, condition coverage conflict, condition mutual exclusion conflict, rule loop conflict, and environment conflict through the conflict detection algorithm, and check out the rule engine and execution scenario action suitable for execution, including: When the first user presets a linkage rule, corresponding Json format data is generated according to the information of the linkage rule; wherein the Json format data includes: user ID of the linkage rule, type of rule, priority of rule, execution area of ​​rule, time of rule execution, sensor information and actuator information; Extract important information from Json data and store it in the rule screening database; Extract information related to conflict detection and model it according to preset rules to generate a rule model; Based on the rule characteristics, the information used in modeling, and the types of conflicts between linkage rules generated by relevant personnel, the conflicts between linkage rules are classified according to preset requirements; Based on the modeling of rules and the classification of rule conflicts, the classified data is subjected to a preset rule conflict detection algorithm to determine whether there are conflicts in opposite execution actions, condition coverage conflicts, condition mutual exclusion conflicts, environmental conflicts, and rule loop conflicts between the rules.

[0060] For example, when a user sets a linkage rule, "between 9:00 and 18:00, if the temperature is greater than 29 degrees Celsius, turn on the air conditioner."

[0061] The Json data contains the user ID who created the linkage rule, the rule type, the rule priority, the rule execution area, the rule execution time, sensor information, and actuator information. Based on the status field in the actuator, you can also determine whether the rule has been executed. Execution time, execution priority, and execution device are all key information. Currently, the key information is to extract the most frequently used fields. The TextRank algorithm can also be used to automatically extract important sentences or keywords in the text.

[0062] Specifically, the rule screening database: Through the Json data format, all the configuration information in the rules can be well recorded. However, in general, the Json data records a lot of information that is not related to conflict detection. Therefore, in order to improve the efficiency of conflict detection, the important information in the Json data is extracted and stored in the rule screening database. The rule screening database stores a lot of important information related to conflict detection. The rule screening database can help filter out rules with the same priority and the same execution area, reducing the complexity of subsequent conflict detection.

[0063] The rule engine needs to be triggered. When the triggering conditions of the scene linkage are reported, conflict detection is performed on all rule engines, and one independent rule or the rule with the highest priority in the conflict detection is selected for linkage processing.

[0064] The triggering process of the rule engine can be referred to as follows: The message pump is the core part of the gateway software architecture, which is mainly responsible for the business logic processing of message data. The edge gateway is regarded as a large message pump. The communication with the platform, Pad, and even the internal communication of the edge program is triggered by the message pump. Each component is abstracted as a virtual entity with message processing function. The unified management of all components realizes the communication and management of various message processors such as Business, Device, Port, etc. through the inheritance of interfaces and abstract parent classes.

[0065] The edge program is based on a message-driven mechanism, and each device service performs business logic processing on the messages of the entity manager. For example, through MQTT messages, it determines whether the message is sent by the Pad or the platform, and passes the platform instructions and device event messages to plMessageService for function distribution processing.

[0066] The event messages reported by the device are analyzed, preprocessed and cleaned in the device service class, and the database cache is updated. Then they are divided into two paths. The first path reports online and offline messages, switch messages, and event messages to the platform for the platform to update the device status. The second path reports to the core business processing class.

[0067] PlMessageServiceImpl performs scheduled distribution of device events. The distributed messages can be processed in scene linkage, uploaded to the Pad, or uploaded to other platforms.

[0068] For example, for the human presence sensing device in the cloud, EdgeService determines that it is a cloud message, and then plMessageService distributes it to eventService for processing. Then the message is forwarded to ylwlService to process the cloud device message. First, determine whether the reported message exists in the database. If not, create a device record. If it exists, after data analysis and data cleaning, determine the state change of person->no person, no person->person, and then report the device message to the platform and transmit it to the event queue in plMessageService. Finally, it is processed by the unified event queue, triggering the scene linkage and executing the command operation of turning on / off the light.

[0069] Specifically, a rule engine conflict detection method based on multivariate information modeling is proposed. First, the key information in the rules is extracted, and then the rules with the same priority and execution area are screened out. Then, the information used for conflict detection is modeled. Through conflict detection, opposite conflicts in execution actions, condition coverage conflicts, condition mutual exclusion conflicts, rule loop conflicts, and environmental conflicts are detected. Finally, through conditional judgment, the rule engine suitable for execution is checked to execute the scenario action.

[0070] ① Extraction of key information: When the platform formulates a linkage rule, the system will generate data in the corresponding JSON format based on the information of this linkage rule. For example, when a user formulates a linkage rule, "between 9:00-18:00, if there is someone in the financial management room, turn on the light switch and air conditioner", the JSON data contains the user ID who formulated the linkage rule, the type of rule, the priority of the rule, the execution area of ​​the rule, the time of rule execution, sensor information, actuator information and other related content. According to the status field in the actuator, it can also be determined whether the rule has been executed.

[0071] ② Filter the rule engine database: All configuration information in the rules is recorded in JSON data format. There is a lot of information irrelevant to conflict detection in the recorded data. In order to improve the efficiency of conflict detection, important information in the JSON data is extracted and stored in the rule filtering database. The rule filtering library stores a lot of important information related to conflict detection, which helps to filter out rules with the same priority and the same execution area, reducing the complexity of subsequent conflict detection.

[0072] ③ Rule modeling: After extracting the information related to conflict detection, a rule can be modeled in the following form: Rule_ID={Date, Sensors, Priority, En, Actuators}, where Date refers to the time period for the execution of the linkage rule; Sensors refers to sensors, which can sense whether the surrounding environment meets the user's settings. There can be multiple sensors in a rule, that is, there can be multiple conditions in a rule; Priority refers to the scene priority; En represents the environmental state of the actuator after execution; Actuators represents actuators, there can be multiple actuators in a rule, that is, there can be multiple execution actions in a rule.

[0073] ④ Rule conflict detection: Rule1 represents the rule that the user has just formulated, and Rule represents the rule that has been stored in the database. First, the algorithm defines that "0" represents the absence of this type of conflict, and "1" represents the presence of this type of conflict. Then, it will traverse the rules to filter each rule in the database to determine whether it conflicts with the current rule formulated by the user. If a conflict occurs, the corresponding conflict type will be output. When judging the circular conflict of multiple rules, when the action of Rule1 is the same as the condition of Rule, and the condition of Rule1 is different from the action of Rule, the rule matched in the database is added to the queue. Then remove them from the queue one by one, and judge whether the action in this rule is the same as the conditions of other rules in the database. If they are the same, continue to judge whether the actions of other rules in the database are the same as the conditions in Rule1. If they are the same, it means that multiple rules have been circularly conflicted. If they are different, repeat the above process until all rules are matched. Finally, when it is detected that there are no conflicts of these types, the rule is added to the corresponding rule information storage database.

[0074] Perform action conflict detection on the rule model. When there are multiple trigger conditions, sort the first trigger conditions in lexicographic order based on the sensor ID corresponding to each first trigger condition in the rule model, and calculate the first hash value corresponding to each first trigger condition. At the same time, sort the second trigger conditions in lexicographic order based on the sensor ID corresponding to each second trigger condition in the existing rule, and calculate the second hash value corresponding to each second trigger condition. The hash value calculation process can be expressed as Hash(sort({sensor_id1, surround_status1, condition1, parameter1}, {sensor_id2, surround_status2, condition2, parameter2}…)), Hash( ) represents hash value calculation, sensor_id1, sensor_id2, … respectively represent sensor IDs in different trigger conditions, surround_status1, surround_status2, … respectively represent environmental states in different trigger conditions, condition1, condition2, … respectively represent environmental changes in different trigger conditions, and parameter1, parameter2, … respectively represent trigger thresholds in different trigger conditions.

[0075] If the first hash value and the second hash value calculated above are the same, indicating that the triggering conditions of the rules are the same, then determine whether the execution action of the rule model is mutually exclusive with the execution action of the existing rule. First, determine the existing rule with the same executor ID as the rule model, and determine whether the execution action of the rule model is mutually exclusive with the execution action of the existing rule. When it is detected that the execution action of the rule model is mutually exclusive with the execution action of the existing rule, it is determined that there is an execution action conflict between the rule model and the existing rule, and the detection ends; if the execution action is not mutually exclusive, the conflict detection of the next scenario type is performed.

[0076] According to an embodiment of the present invention, preferably, based on rule features, information used in modeling, and conflict types between linkage rules generated by relevant personnel, conflicts between linkage rules are classified according to preset requirements, including: When two rules are executed in the same time period and the conflict occurs on the same executor, it is defined as a direct conflict. The direct conflict includes: conflict of opposite execution actions, conflict of condition coverage and conflict of condition mutual exclusion. When two rules are executed in the same time period and the conflict does not occur on the same executor, it is defined as an indirect conflict; wherein the indirect conflict includes: environmental conflict and rule cycle conflict.

[0077] According to an embodiment of the present invention, preferably, based on the preset conflict scenario, conflict detection is performed between the rule model and each of the existing rules in the storage set to obtain the conflict detection result.

[0078] According to an embodiment of the present invention, preferably, each first trigger condition in the rule model is sorted based on a preset order, and a first hash value corresponding to each first trigger condition is determined; Sort the second trigger conditions in the existing rules based on the preset order, and determine the second Hash value corresponding to each of the second trigger conditions; When it is detected that the first Hash value is the same as the second Hash value, determining whether the execution action of the rule model and the execution action of the existing rule are mutually exclusive; When the execution action of the rule model and the execution action of the existing rule are mutually exclusive, it is determined that there is an execution action conflict between the rule model and the existing rule.

[0079] Specifically, after the above rule modeling is completed, the conflicts generated by the linkage rules need to be classified. Only in this way can we determine what the corresponding conflicts between the rules are when performing conflict detection later. Next, this application will make a detailed classification of the conflicts generated between linkage rules based on the characteristics of the rules, the information used in modeling, and the research work of relevant personnel on the types of conflicts that may arise between linkage rules.

[0080] First, the rules are divided into direct conflicts and indirect conflicts. When two rules are executed in the same time period and the conflict occurs on the same executor, this article calls it a direct conflict; when two rules are executed in the same time period and the conflict does not occur on the same executor, this article calls it an indirect conflict. Based on the characteristics of direct conflicts and indirect conflicts, direct conflicts are further subdivided into conflict of opposite execution actions, conflict of condition coverage, and conflict of condition mutual exclusion, while indirect conflicts are subdivided into environmental conflicts and rule loop conflicts.

[0081] 1. Direct conflict a) Execution of opposite actions conflicts If the actuators in two rules are executed in the same time period and the execution actions are opposite, then the two rules will have an opposite execution action conflict. For example: "Rule 1: Automatically lock the door between 23:00-6:00; Rule 2: Open the door when movement is detected near the door". From the above example, we can see that if movement is detected around the door after 11pm, the door will have opposite execution actions. In this case, the rules are said to have an opposite execution action conflict.

[0082] b) Conditional coverage conflicts If a user defines two rules, when the condition in Rule 1 is a superset of the condition in Rule 2, Rule 2 will be ignored and will not work, which will affect the user experience of the user who set Rule 2. For example: "Rule 1: When the air humidity is greater than 50%, turn off the humidifier; Rule 2: When the air humidity is greater than 80%, turn off the humidifier."

[0083] From the above example, we can see that when rule 1 is triggered, rule 2 will never be executed, so in this case, the rules have a conditional coverage conflict.

[0084] c) Conditional mutual exclusion conflict When the rule conditions are partially opposite and the executors perform the same actions, a conditional mutual exclusion conflict will occur.

[0085] For example: "Rule 1: When the indoor brightness is less than or equal to 60 Lux, open the curtains; Rule 2: When the indoor brightness is greater than or equal to 60 Lux, open the curtains." From the above example, we can see that user 1 defines the first rule to increase the brightness by opening the curtains when the indoor brightness is too low; and user 2 defines the second rule to open the curtains when the indoor brightness is greater than 60 Lux, which means it is daylight. In this way, when the two rules appear together, the curtains will be kept open during this time period, resulting in mutually exclusive conflicts and reducing the user experience.

[0086] 2. Indirect conflict a) Environmental Conflict When the impact of a linkage rule on the environment leads to the execution of another rule, and the passively executed rule is executed in a way that the user did not expect, this application calls this an environmental conflict. For example: "Rule 1: When the humidity is greater than 60%, turn on the dehumidifier to reduce the humidity to below 30%; Rule 2: When the humidity is less than 29%, turn on the humidifier to make the humidity greater than 70%". From the above examples, it can be seen that when Rule 1 and Rule 2 appear together, the dehumidifier and humidifier will always be in working order, which will cause an environmental conflict and cause unnecessary waste of resources.

[0087] b) Rule loop conflict When two or more rules cause the actuator to work in a loop, a rule loop conflict will occur. For example: "Rule 1: When the humidifier is turned on, the window is closed; Rule 2: When the window is closed, the humidifier is turned on". From the above example, it can be seen that when the two rules appear together, the following scenario will occur: "After the humidifier is turned on, the window is closed, and after the window is closed, the humidifier is turned on again", which will cause the two actuators to be in a loop working state all the time, resulting in unnecessary waste of resources. Another example is "Rule 1: When the projector is turned on, the curtains are drawn; Rule 2: When the curtains are drawn, the lights are turned off; Rule 3: When the lights are turned off, the projector is turned on". From the above example, it can be seen that the process of the loop conflict caused by more than two rules is roughly the same as the loop conflict caused by two rules.

[0088] According to an embodiment of the present invention, preferably, based on the modeling of rules and the classification of rule conflicts, and using a preset rule conflict detection algorithm to determine whether there are opposite conflicts in execution actions, condition coverage conflicts, condition mutual exclusion conflicts, environment conflicts, and rule loop conflicts among the rules, the following is included: Define the preset algorithm, "0" means there is no conflict of this type, and "1" means there is a conflict of this type; Traverse the rules to filter each rule in the database, and perform each type of conflict detection and judgment with the linkage rules formulated by the first user, and output the corresponding conflict type.

[0089] Specifically, for example, for conflicts of time type, after sorting, some rules with lower priorities will be processed later.

[0090] For example, for conflicts in area types, especially for the same device operation, it is only executed once, and the redundant ones can be discarded.

[0091] For example, for rules with different priorities and engine linkage, you can refer to the following methods: The sensor device event queues used by the sensor devices to perform scene linkage actions are named queue 1, queue 2, ..., queue n in sequence, where n is a natural number greater than 1, and the value of n is the same as the number of sensor devices; Send the scene linkage priority of the IoT scene linkage device to the IoT scene linkage device; The control device event queues used by the sensor devices to perform scene linkage actions are named the n+1th queue, the n+2th queue, ..., the mth queue in sequence, where m is a natural number greater than n, and the value of mn is the same as the number of control devices; A priority queue is established by a complete binary tree, and the queue with the highest priority in the priority queue is processed first; According to the priority relationship, queues 1 to m are put into priority queues; Through the hierarchical traversal method, the order of taking out the highest priority events from the priority queue is used as the order of executing the scene linkage actions.

[0092] Report device events to the edge and mark the priority of the device events (such as P1-P5, where P5 has the highest priority).

[0093] ① Set a priority time queue (maximum length is 1000) in EdgeEventQueue, and create an ascending heap according to the heap sort method.

[0094] In PlMessageServiceImpl, the events at the top of the priority queue are taken out one by one for processing, ensuring that the events with the highest priority are processed as quickly as possible.

[0095] ② Set up another common event queue (maximum length is 10,000) at the same time. Temporarily store cached data. A large number of messages are reported in a short period of time. Exceeding the total length of the priority queue. Then put the device events with the lowest priority (bottom of the stack) in the priority queue into the standby queue. When waiting for the priority queue to be free, put the large data in the common event queue back into the priority queue.

[0096] ③ Considering the boundary value, the priority event queue is full and the common event queue is also full, which means that a large number of messages are reported in a short period of time and the duration is long. The edge program can clear the common event queue and discard some message event data.

[0097] According to an embodiment of the present invention, preferably, after traversing each rule in the rule screening database and performing each type of conflict detection and judgment with the linkage rule formulated by the first user and outputting the corresponding conflict type, the method further includes: By detecting the conflict type, the first user is reminded to select rules of different time periods when creating rules; When there are multiple device types, there will be multiple queues. Or, when there is only one device type, the device has multiple queues. This is a multi-queue scenario. The multi-queue scenario includes a first queue, a second queue, a third queue and a fourth queue; wherein the first queue corresponds to a first available ring, the second queue corresponds to a second available ring, the third queue corresponds to a third available ring, and the fourth queue corresponds to a fourth available ring; the first queue has a first descriptor; the second queue has a second descriptor and a third descriptor; the third queue has a fourth descriptor, a fifth descriptor and a sixth descriptor; and the fourth queue has a seventh descriptor and an eighth descriptor.

[0098] The present invention also has the following beneficial effects: 1. A method for data processing for scene linkage applied to edge gateways, which applies the existing communication protocol parsing, parsing application rules and partial positioning calculations of the cloud server to the edge gateway, which not only reduces the computing pressure on the cloud server and simplifies the cloud server structure, but also gives the edge gateway more functions. When the edge gateway is disconnected from the cloud server, the edge gateway independently parses the application rules. In addition to establishing a communication channel between traditional devices and the cloud, the edge protocol conversion device itself has the ability to operate autonomously. In the case of offline disconnection, it can operate autonomously through algorithms to ensure that traditional devices can operate safely and scene linkage can be achieved in the case of offline disconnection.

[0099] 2. The present invention introduces a lightweight rule engine module in the edge gateway, separates the business logic from the code, enables users to use predefined semantic modules to write rules, receive data, and finally make decisions based on the written rules, enables edge gateway users to define business rules according to specific scenario requirements, meets user needs, makes the edge gateway widely applicable to a variety of application scenarios, and reduces the cost of system development and maintenance.

[0100] like Figure 3 As shown, in order to achieve the above purpose, according to another aspect of the present application, a rule engine scenario linkage system based on an edge gateway is provided. The rule engine scenario linkage system based on an edge gateway includes: The preset device linkage rule management module 301 is used to add device linkage rule management according to preset rules through the cloud platform; wherein the device linkage rule management includes: rule addition, rule deletion, rule query and rule modification; It can achieve good rule management and rule storage effects on the cloud platform, thus providing a basis and guarantee for subsequent processing.

[0101] A generating and adding module 302 is used to obtain the operation status information of the device end through the edge end and generate a device linkage fact, and add the device linkage fact to the fact library of the preset rule engine; It can achieve the effect of generating device linkage facts, and at the same time, it can also add the device linkage facts to the fact library of the preset rule engine, thereby achieving a good data adding effect.

[0102] A matching module 303, configured to match the first device linkage rule at the bottom of the device linkage rule management with the device linkage fact based on a preset rule engine; A good matching effect between the first device linkage rule and the device linkage fact can be achieved.

[0103] A control module 304, configured to generate a first device control instruction for controlling a corresponding device from the first device linkage rule according to the matching result; It can achieve accurate control instruction generation effect.

[0104] The instruction sending module 305 is used to send the first device control instruction to the corresponding device on the device side according to the communication protocol in the preset rule engine, and generate a control result and push it to the preset smart terminal.

[0105] It is possible to send control instructions to the corresponding device on the device side through the communication protocol, thereby achieving a good device side control effect.

[0106] From the above description, it can be seen that the present application achieves the following technical effects: In an embodiment of the present application, a method based on edge gateway scenario linkage is adopted, and device linkage rule management is added according to preset rules through a cloud platform; wherein, the device linkage rule management includes: rule addition, rule deletion, rule query and rule modification; the operation status information of the device end is obtained through the edge end and device linkage facts are generated, and the device linkage facts are added to the fact library of the preset rule engine; based on the preset rule engine, the first device linkage rule at the bottom of the device linkage rule management is matched with the device linkage facts; according to the matching result, the first device linkage rule is generated to control the first device control instruction of the corresponding device; the first device control instruction is sent according to the communication protocol in the preset rule engine To the corresponding device on the device side, and generate a control result and push it to the preset intelligent terminal, so as to achieve the purpose of applying the existing cloud server-side communication protocol analysis, analysis of application rules and part of the positioning calculation to the edge gateway side, thereby reducing the computing pressure on the cloud server side and making the cloud server structure simple; and giving the edge gateway more functions. When the edge gateway is disconnected from the cloud server, the application rules are independently analyzed by the edge gateway; in addition to establishing a communication channel between traditional devices and the cloud, the edge protocol conversion device itself has the ability to operate independently. In the case of offline disconnection, it can operate autonomously through algorithms to ensure that traditional devices can also operate safely and solve the technical problems of scene linkage in the case of offline disconnection.

[0107] like Figure 4As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, ROM 12 and RAM 13 are connected to each other through a bus 14. The input / output (I / 0) interface 15 is also connected to the bus 14.

[0108] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0109] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the rule engine scenario linkage method based on the edge gateway.

[0110] In some embodiments, the rule engine scenario linkage method based on the edge gateway may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the rule engine scenario linkage method based on the edge gateway described above may be executed. Alternatively, in other embodiments, the processor 11 may be configured to execute the rule engine scenario linkage method based on the edge gateway in any other appropriate manner (e.g., by means of firmware).

[0111] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A rule engine scenario linkage method based on an edge gateway, characterized in that: include: Add device linkage rule management according to preset rules through the cloud platform; wherein the device linkage rule management includes: rule addition, rule deletion, rule query and rule modification; Obtaining the running status information of the device end through the edge end and generating device linkage facts, and adding the device linkage facts to the fact library of the preset rule engine; Based on a preset rule engine, a first device linkage rule from the bottom of the device linkage rule management is matched with the device linkage fact; Generate a first device control instruction for controlling a corresponding device from the first device linkage rule according to the matching result; The first device control instruction is sent to the corresponding device on the device side according to the communication protocol in the preset rule engine, and the control result is generated and pushed to the preset intelligent terminal.

2. The edge gateway-based rule engine scenario linkage method according to claim 1, characterized in that: The edge end obtains the running status information of the device end and generates the device linkage fact, and adds the device linkage fact to the fact library of the preset rule engine, including: The edge end uses distributed rules to execute on multiple edge devices or edge gateways.

3. The edge gateway-based rule engine scenario linkage method according to claim 1, characterized in that: Add device linkage rule management according to preset rules through the cloud platform; wherein, the device linkage rule management includes: rule addition, rule deletion, rule query and rule modification, including: The cloud platform classifies the rules based on the rule screening algorithm of the environmental context, and eliminates redundant rules according to the preset priorities and execution areas after classification to generate linkage rules.

4. The edge gateway-based rule engine scenario linkage method according to claim 3 is characterized in that: The cloud platform classifies the rules based on the rule screening algorithm of the environmental context, and excludes redundant rules according to the preset priority and execution area. After the linkage rules are generated, they also include: The conflict detection algorithm based on multivariate information modeling determines conflicts between rules, extracts key information from linkage rules, and selects rules with the same priority and execution area; The information used for conflict detection is modeled, and through the conflict detection algorithm, the opposite conflicts of defined execution actions, condition coverage conflicts, condition mutual exclusion conflicts, rule loop conflicts and environmental conflicts are detected, and the rule engine and execution scenario actions suitable for execution are checked.

5. The edge gateway-based rule engine scenario linkage method according to claim 3, characterized in that: The cloud platform classifies the rules based on the rule screening algorithm of the environmental context, and excludes redundant rules according to the preset priority and execution area after classification, and generates linkage rules, including: Pre-classify linkage rules into rule types according to the functions and characteristics of smart devices, and classify corresponding linkage rules into corresponding types; wherein the rule types include: smart security, environment monitoring, brightness adjustment, audio and video control, and electrical appliance control; By presetting the extended information, when formulating the linkage rules, the extended information needs to be added and automatically stored in the rule screening database; wherein the extended information includes: priority and execution area; Set different priorities for rule types according to preset event requirements, and linkage rules in types with higher priorities will be executed first; A pre-execution scope is allocated to each device.

6. The edge gateway-based rule engine scenario linkage method according to claim 4, characterized in that: The conflict detection algorithm based on multivariate information modeling determines conflicts between rules, extracts key information from linkage rules, and screens out rules with the same priority and execution area; models the information used for conflict detection, and uses the conflict detection algorithm to detect conflicts in opposite execution actions, condition coverage conflicts, condition mutual exclusion conflicts, rule loop conflicts, and environmental conflicts, and checks out rule engines and execution scenario actions that are suitable for execution, including: When the first user presets a linkage rule, corresponding Json format data is generated according to the information of the linkage rule; wherein the Json format data includes: user ID of the linkage rule, type of rule, priority of rule, execution area of ​​rule, time of rule execution, sensor information and actuator information; Extract important information from Json data and store it in the rule screening database; Extract information related to conflict detection and model it according to preset rules to generate a rule model; Based on the rule characteristics, the information used in modeling, and the types of conflicts between linkage rules generated by relevant personnel, the conflicts between linkage rules are classified according to preset requirements; Based on the modeling of rules and the classification of rule conflicts, the classified data is subjected to a preset rule conflict detection algorithm to determine whether there are conflicts in opposite execution actions, condition coverage conflicts, condition mutual exclusion conflicts, environmental conflicts, and rule loop conflicts between the rules.

7. The edge gateway-based rule engine scenario linkage method according to claim 6, characterized in that: Based on the rule characteristics, the information used in modeling, and the types of conflicts between linkage rules generated by relevant personnel, the conflicts between linkage rules are classified according to preset requirements, including: When two rules are executed in the same time period and the conflict occurs on the same executor, it is defined as a direct conflict. The direct conflict includes: conflict of opposite execution actions, conflict of condition coverage and conflict of condition mutual exclusion. When two rules are executed in the same time period and the conflict does not occur on the same executor, it is defined as an indirect conflict; wherein the indirect conflict includes: environmental conflict and rule cycle conflict.

8. The edge gateway-based rule engine scenario linkage method according to claim 6, characterized in that: Based on the modeling of rules and the classification of rule conflicts, the classified data is subjected to a preset rule conflict detection algorithm to determine whether there are conflicts in opposite execution actions, condition coverage conflicts, condition mutual exclusion conflicts, environmental conflicts, and rule loop conflicts between the rules, including: Define the preset algorithm, "0" means there is no conflict of this type, "1" means there is a conflict of this type; Traverse the rules to filter each rule in the database, and perform each type of conflict detection and judgment with the linkage rules formulated by the first user, and output the corresponding conflict type.

9. The edge gateway-based rule engine scenario linkage method according to claim 8, characterized in that: Traverse each rule in the rule screening database, and perform each type of conflict detection and judgment with the linkage rule set by the first user, and output the corresponding conflict type, and also include: By detecting the conflict type, the first user is reminded to select rules of different time periods when creating rules; When there are multiple device types, there will be multiple queues. Or, when there is only one device type, the device has multiple queues. This is a multi-queue scenario. The multi-queue scenario includes a first queue, a second queue, a third queue and a fourth queue; wherein the first queue corresponds to a first available ring, the second queue corresponds to a second available ring, the third queue corresponds to a third available ring, and the fourth queue corresponds to a fourth available ring; the first queue has a first descriptor; the second queue has a second descriptor and a third descriptor; the third queue has a fourth descriptor, a fifth descriptor and a sixth descriptor; and the fourth queue has a seventh descriptor and an eighth descriptor.

10. The edge gateway-based rule engine scenario linkage method according to claim 8, characterized in that: Traverse the rules to filter each rule in the database, and perform each type of conflict detection and judgment with the linkage rules set by the first user, and output the corresponding conflict type, including: Perform execution action conflict detection on the rule model. When there are multiple trigger conditions, sort the first trigger conditions in lexicographic order based on the sensor ID corresponding to each first trigger condition in the rule model, and calculate the first hash value corresponding to each first trigger condition; at the same time, sort the second trigger conditions in lexicographic order based on the sensor ID corresponding to each second trigger condition in the existing rule, and calculate the second hash value corresponding to each second trigger condition; if the calculated first hash value is the same as the second hash value, indicating that the trigger conditions of the rules are the same, then determine whether the execution action of the rule model is mutually exclusive with the execution action of the existing rule; determine the existing rule with the same executor ID as the corresponding executor of the rule model, and determine whether the execution action of the rule model is mutually exclusive with the execution action of the existing rule; when it is detected that the execution action of the rule model is mutually exclusive with the execution action of the existing rule, it is determined that there is an execution action conflict between the rule model and the existing rule, and the detection ends; if no execution action is detected to be mutually exclusive, perform conflict detection for the next scenario type.

11. The rule engine scenario linkage system based on edge gateway is characterized by: include: A preset device linkage rule management module is used to add device linkage rule management according to preset rules through the cloud platform; wherein the device linkage rule management includes: rule addition, rule deletion, rule query and rule modification; A generation and adding module is used to obtain the operation status information of the device end through the edge end and generate device linkage facts, and add the device linkage facts to the fact library of the preset rule engine; A matching module, configured to match the first device linkage rule from the lower part of the device linkage rule management with the device linkage fact based on a preset rule engine; A control module, configured to generate a first device control instruction for controlling a corresponding device from the first device linkage rule according to the matching result; The instruction sending module is used to send the first device control instruction to the corresponding device on the device side according to the communication protocol in the preset rule engine, and generate a control result and push it to the preset intelligent terminal.

Citation Information

Cited By

  • End-cloud collaborative intelligent linkage method and system for cloud Internet of Things equipment

    CN121531012A

  • An end-cloud cooperative cloud internet of things device intelligent linkage method and system

    CN121531012B

  • A multi-protocol adaptive access internet of things intelligent control gateway and an intelligent scene linkage method thereof

    CN122741571A

  • A multi-protocol adaptive access internet of things intelligent control gateway and an intelligent scene linkage method thereof

    CN122741571B