Equipment control method and device, storage medium and equipment
By receiving message data from multiple target data sources and using the rule engine to judge scenario trigger conditions, the smart home system can provide more accurate and comprehensive information, meet the complex needs of users, and improve device control efficiency.
Patent Information
- Application Number
- CN202411634389.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-14
- Publication Date
- 2025-03-04
AI Technical Summary
The existing smart home system can only report a single target data source based on the device status, resulting in the data source being instable, reducing the efficiency of controlling other devices, and unable to meet the various complex needs of users.
By receiving the message data sent by at least one of the multiple target data sources, the data type is obtained, and the target scenario is obtained in the subscription relationship between the preset data type and the scene. Based on the rule engine, it determines whether the message data meets the scene triggering condition. If it is satisfied, the scene-related device and action information are obtained and sent to the scene-related device to perform the action.
Through message data from multiple target data sources, accurate and comprehensive information is provided for scene triggering, meeting various complex needs of users and improving user experience and device control efficiency.
Smart Images

Figure CN119556580A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and more specifically, to a device control method, apparatus, storage medium and device in the field of computer technology. Background Art
[0002] With the development of science and technology, smart homes have been integrated into the daily lives of some people, bringing great convenience to people's lives. However, the existing smart home system can only report a single target data source based on the device status. If the device fails, the data source will be unstable, reducing the efficiency of controlling other devices and failing to meet the various complex needs of users. At the same time, the underlying code of the existing smart home system has a set of judgment logic for the triggering of each scenario, which reduces the efficiency of device control. Summary of the invention
[0003] The present application provides a device control method, apparatus, storage medium and device. The method can provide accurate and comprehensive information for scene triggering through message data from multiple target data sources, meet various complex needs of users, and improve the user experience. When the message data is received, it can respond in a timely manner and judge whether the message data meets the scene triggering conditions based on the rule engine, thereby improving the efficiency of device control.
[0004] In a first aspect, a device control method is provided, the method comprising: receiving first message data sent by at least one target data source among multiple target data sources, and obtaining a first data type of the first message data; in a subscription relationship between a preset data type and a scene, obtaining a target scene corresponding to the first data type; if it is determined based on a rule engine that the first message data satisfies a target scene trigger condition corresponding to the target scene, obtaining a scene-associated device corresponding to the target scene and action information corresponding to the scene-associated device; and sending the action information to the scene-associated device to control the scene-associated device to execute the action information.
[0005] Through the above technical solution, the first message data sent by at least one target data source among multiple target data sources is received, the first data type is obtained from the first message data, and then the target scene corresponding to the first data type is obtained in the subscription relationship between the preset data type and the scene. If it is determined based on the rule engine that the first message data meets the target scene trigger condition corresponding to the target scene, the scene-associated device corresponding to the target scene and the action information corresponding to the scene-associated device are obtained, the action information is sent to the scene-associated device, and the scene-associated device is controlled to execute the action information. Through the message data from multiple target data sources, accurate and comprehensive information is provided for the scene trigger, which meets the various complex needs of users and improves the user experience. After receiving the message data, it can respond in time, and judge whether the message data meets the scene trigger condition based on the rule engine, which improves the efficiency of device control.
[0006] In a second aspect, a device control apparatus is provided, the apparatus comprising:
[0007] A message data receiving unit, configured to receive first message data sent by at least one target data source among a plurality of target data sources, and obtain a first data type of the first message data;
[0008] A target scene acquisition unit, configured to acquire a target scene corresponding to the first data type in a subscription relationship between a preset data type and a scene;
[0009] an action information acquisition unit, configured to acquire a scene-associated device corresponding to the target scene and action information corresponding to the scene-associated device if it is determined based on the rule engine that the first message data meets a scene trigger condition corresponding to the target scene;
[0010] The action execution unit is used to send the action information to the scene-related device to control the scene-related device to execute the action information.
[0011] In a third aspect, a computer device is provided, the computer device comprising: a memory for storing executable program code;
[0012] A processor is used to call and run executable program code from a memory to execute the method in the above-mentioned first aspect or any possible implementation manner of the first aspect.
[0013] In a fourth aspect, a computer program product is provided, comprising: a computer program code, which, when executed on a computer, enables the computer to execute the method in the first aspect or any possible implementation of the first aspect.
[0014] In a fifth aspect, a computer-readable storage medium is provided, which stores a computer program code. When the computer program code runs on a computer, the computer executes the method in the above-mentioned first aspect or any possible implementation manner of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 It is a system architecture diagram of a device control method provided in an embodiment of the present application;
[0016] Figure 2 It is a flow chart of a device control method provided in an embodiment of the present application;
[0017] Figure 3 It is a flow chart of a device control method provided in an embodiment of the present application;
[0018] Figure 4 It is a flowchart of a method for creating a new scene trigger condition provided in an embodiment of the present application;
[0019] Figure 5 It is a flowchart of a method for updating a scene trigger condition provided in an embodiment of the present application;
[0020] Figure 6 It is a flow chart of a device control method provided in an embodiment of the present application;
[0021] Figure 7 It is a structural schematic diagram of a device control device provided in an embodiment of the present application;
[0022] Figure 8 It is a structural schematic diagram of a device control device provided in an embodiment of the present application;
[0023] Fig. 9 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0024] The technical solution in the present application will be described clearly and in detail below in conjunction with the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B: "and / or" in the text is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0025] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features.
[0026] See also Figure 1 , Figure 1 is a system architecture diagram of a device control method provided in an embodiment of the present application. Figure 1 As shown, the device control method provided in the embodiment of the present application can be applied to the IoT smart home scene. The system may include at least one terminal device 10, a cloud 20, a message hub 30, a scene execution service 40 and at least one scene-related device 50, wherein the terminal device 10 includes but is not limited to mobile phones, personal computers, laptops, wearable devices and other user terminals with networking functions. The cloud 20 has a large amount of storage space, which can store various types of data of the device, and can remotely monitor, diagnose faults and perform predictive maintenance on the device to improve the efficiency and reliability of the device. The message hub 30 is a message processing system for message subscription, message forwarding and message processing, which is specifically used to save the subscription relationship between the data type of the message data and the scene, and receive the first message data sent by the target data source, obtain the first data type from the first message data, filter out the corresponding target scene according to the first data type, and forward the first message data to the scene execution service 40. The scene execution service 40 includes a rule engine 41. After receiving the first message data, the scene execution service 40 inputs the first message data into the rule engine 41. The rule engine 41 includes a database 411. The database 411 can store scene trigger conditions of various scenes of the IoT smart home. When the rule engine 41 receives the first message data input by the scene execution service, it calls the target scene trigger condition corresponding to the target scene to determine whether the first message data meets the target scene trigger condition. If it does, the scene-associated device 50 corresponding to the target scene and the action information corresponding to the scene-associated device 50 are obtained, and the action information is sent to the scene-associated device 50. The scene execution service 40 controls the scene-associated device 50 to execute the action information. The terminal device 10 can also be used to execute all steps executed by the cloud 20, the message hub 30 and the scene execution service 40.
[0027] based on Figure 1 The system architecture diagram shown below will be combined with Figure 2-Figure 6 , the device control method provided in the embodiment of the present application is introduced in detail.
[0028] See also Figure 2 , Figure 2 is a flow chart of a device control method provided in an embodiment of the present application. Figure 2As shown, the method of the embodiment of the present application may include the following steps S101-S104.
[0029] S101, receiving first message data sent by at least one target data source among multiple target data sources, and acquiring a first data type of the first message data;
[0030] Specifically, the embodiment of the present application may provide multiple target data sources, receive the first message data sent by at least one of the multiple target data sources, and obtain the first data type of the first message data. Among them, the target data source may be at least one of a clock data source, a home appliance data source, a terminal device data source, and a cloud data source. The clock data source comes from a scheduled task set by a user or the cloud, and when the task time is reached, the time information is pushed to the message center. The home appliance data source is the device status of the home appliance, and the home appliance includes but is not limited to air conditioners, coffee machines, bread machines, ovens, smart speakers, smart door locks and other devices. The terminal device data source includes but is not limited to users directly controlling home appliances through terminal devices, or the terminal device receives push information related to weather and schedules. The cloud data source may be a module customized by developers for users in the cloud that can obtain the weather, time or home appliance status of the user's area, or it may be a third-party cloud. The cloud data source may include the clock data source, the home appliance data source, and all message data that can be sent by the terminal device data source. The first message data is message data including at least one of time, weather, indoor environment or device status. In the first message data, information such as time, weather, indoor environment or device status is sent to the message hub in the form of a key-value pair. The key-value pair consists of a unique key and a corresponding value, wherein the key is used to uniquely identify a data type, and the value is a parameter value associated with the key. The message hub can obtain the first data type of the first message data according to the key in the key-value pair in the first message data. The message hub is a message processing system for message subscription, message forwarding, and message processing, which can be used to receive message data sent by a target data source and obtain data types from the message data.
[0031] S102, obtaining a target scene corresponding to a first data type in a preset subscription relationship between a data type and a scene;
[0032] Specifically, after the first data type of the first message data is obtained, the target scene corresponding to the first data type is obtained in the subscription relationship between the preset data type and the scene. Among them, the scene is a task preset by the user, which can be triggered by the user or automatically triggered by the system, and then the scene-associated device corresponding to the scene is controlled to execute the corresponding action information. The subscription relationship is the correspondence between the data type and the scene, which is established and saved in the message hub. It can be established by the manufacturer and shipped by the IoT home system, or it can be added or updated by the user according to his own needs during use. It should be noted that the subscription relationship between the data type and the scene can be a one-to-one, one-to-many, many-to-one or many-to-many relationship. Therefore, the target scene is at least one scene.
[0033] S103, if it is determined based on the rule engine that the first message data meets the target scenario trigger condition corresponding to the target scenario, then obtaining the scenario-associated device corresponding to the target scenario and the action information corresponding to the scenario-associated device;
[0034] Specifically, based on the rule engine, it is determined whether the first message data satisfies the scene trigger condition corresponding to the target scene. If it is determined that the first message data satisfies the scene trigger condition corresponding to the target scene, the scene-associated device corresponding to the target scene and the action information corresponding to the scene-associated device are obtained. Among them, the scene trigger condition refers to the prerequisite for a scene to occur. When the condition occurs, the scene can be triggered. In the embodiment of the present application, the scene trigger condition is a rule expression stored in the database of the rule engine, and the scene-associated device is at least one device corresponding to the target scene. There is a linkage relationship between multiple devices. For example, if the power state of the air-conditioning device is taken as the first data type, the corresponding target scene is the switch control for smart windows, smart curtains and air humidifiers. Then, the scene-associated devices corresponding to the target scene are smart windows, smart curtains and air humidifiers. When the power state of the air-conditioning device is turned on, the action information for smart windows and smart curtains is to detect whether the smart windows and smart curtains are closed. If not, they are closed; the action information for the air humidifier is to detect whether the air humidifier is turned on. If not, it is turned on.
[0035] S104: Send the action information to the scene-associated device to control the scene-associated device to execute the action information.
[0036] Specifically, the acquired action information is sent to the scene-related device to control the scene-related device to execute the action information. If there are multiple scene-related devices, each scene-related device has corresponding action information, and each action information is sent to the corresponding scene-related device to control each scene-related device to execute the corresponding action information.
[0037] In an embodiment of the present application, by receiving the first message data sent by at least one target data source among multiple target data sources, the first data type is obtained from the first message data, and then in the subscription relationship between the preset data type and the scene, the target scene corresponding to the first data type is obtained. If it is determined based on the rule engine that the first message data meets the target scene trigger condition corresponding to the target scene, the scene-associated device corresponding to the target scene and the action information corresponding to the scene-associated device are obtained, the action information is sent to the scene-associated device, and the scene-associated device is controlled to execute the action information. Through the message data from multiple target data sources, accurate and comprehensive information is provided for the scene trigger, which meets the various complex needs of users and improves the user experience. When the message data is received, it can respond in time, and judge whether the message data meets the scene trigger condition based on the rule engine, thereby improving the efficiency of device control.
[0038] See also Figure 3 , Figure 3 is a flow chart of a device control method provided in an embodiment of the present application. Figure 3 As shown, the method of the embodiment of the present application may include the following steps S201-S209.
[0039] S201, receiving first message data sent by at least one target data source among multiple target data sources;
[0040] Specifically, the embodiment of the present application can provide multiple target data sources, provide accurate and comprehensive information for scene triggering, and ensure the timeliness of device control. The first message data sent by at least one target data source among the multiple target data sources is received through the message hub. Among them, the scene is a task preset by the user, which can be triggered by the user or automatically triggered by the system, and then the action information is executed. The first message data is message data including at least one of time, weather, indoor environment or device status. The message hub is a message processing system for message subscription, message forwarding and message processing, which can be used to receive message data sent by the target data source and obtain data type from the message data. The target data source can be at least one of a clock data source, a home appliance data source, a terminal device data source and a cloud data source. The clock data source comes from a scheduled task set by the user or the cloud. When the task time is reached, the time information is pushed to the message hub. For example, the time set by the user for the wake-up scene is 7:00 in the morning. When the clock points to 7:00, the first message data with the current time of 7:00 is sent to the message hub. The data source of home appliances is the device status of home appliances. Home appliances include but are not limited to air conditioners, coffee machines, bread machines, ovens, smart speakers, smart door locks and other devices. Taking air conditioners as an example, if the user turns on the air conditioner, the air conditioner will send its own power status to the message center as on. The data source of terminal devices includes but is not limited to users directly controlling home appliances through terminal devices, or terminal devices receiving push information related to weather and schedules. For example, if the terminal device receives weather information that it will rain at 2:00 this afternoon, the weather information will be sent to the message center. The cloud data source can be a module customized by developers for users in the cloud that can obtain the weather, time or status of home appliances in the user's area, or it can be a third-party cloud. The cloud data source may include a clock data source, a home appliance data source, and all message data that can be sent by the terminal device data source. For example, the cloud module can also obtain weather information in the user's area in real time and send the weather information to the message center.
[0041] S202, obtaining a key-value pair in the first message data, and determining the key in the key-value pair as a first data type of the first message data;
[0042] Specifically, in the first message data, information such as time, weather, indoor environment or device status is sent to the message hub in the form of a key-value pair. The key-value pair consists of a unique key and a corresponding value, where the key is used to uniquely identify a data type, and the value is a parameter value associated with the key. The message hub can obtain the key-value pair in the first message data and determine the key in the key-value pair as the first data type of the first message data. For example, if the first message data is the device status information sent by the home appliance data source, when the message hub receives the first message data as data exchange (JavaScript Object Notation), the message hub will receive the data exchange information. Notation, JSON) formatted string {"applianceCode":175921860444638,"status":"{\"power\":\"on\",\"b5_next_frame\":0,\"version\":57}", the string is parsed to obtain the key-value pairs in the string. The key-value pairs are the basic elements that constitute a JSON object or array. In the JSON formatted string, each pair of key-value pairs is separated by "," and the key and value in each pair of key-value pairs are separated by ":". Therefore, from the above string, it can be seen that the first message data is sent by the home appliance data source to the message The device code of the home appliance is "175921860444638". The home appliance reports three states to the message hub, namely "power", "b5_next_frame" and "version". The three states are the keys in the key-value pair. Therefore, from the first message data, the first data types "power", "b5_next_frame" and "version" can be obtained, among which "power" can be used to indicate the power state of the home appliance, "b5_next_frame" can be used to indicate the control system of the home appliance, and "version" can be used to indicate the software version number of the home appliance.
[0043] S203, acquiring a target scene corresponding to the first data type in a preset subscription relationship between the data type and the scene;
[0044] Specifically, after the first data type of the first message data is obtained, the target scene corresponding to the first data type is obtained in the subscription relationship between the preset data type and the scene. The subscription relationship is the corresponding relationship between the data type and the scene, which is established and saved in the message hub. It can be established by the manufacturer and shipped by the IoT home system, or it can be added or updated by the user according to his own needs during use. It should be noted that the subscription relationship between the data type and the scene can be a one-to-one, one-to-many, many-to-one or many-to-many relationship. Therefore, the target scene is at least one scene. Taking the first message data listed in step S202 as an example, the message hub receives {"applianceCode":175921860444638,"status":"{\"power\":\"on\",\"b5_next_frame\":0,\"version\":57} sent by the home appliance, parses the first message data, and obtains the first data types of "power", "b5_next_frame" and "version", and finds the target scenes corresponding to the three data types of "power", "b5_next_frame" and "version" from the subscription relationship. For example, if the home appliance is an air conditioner, the target scene corresponding to "power" can be the switch control of linkage devices such as smart windows, smart curtains and air humidifiers, while the target scenes corresponding to "b5_next_frame" and "version" can be detecting whether the air conditioning function complies with the version, and "b5_next_frame" and "version" may not correspond to any target scene, but only serve as additional information sent by the home appliance.
[0045] S204, converting the first message data into second message data based on a data format corresponding to the rule engine;
[0046] Specifically, it can be seen from step S202 that the data format of the first message data is JSON format, and the rule engine usually defines or executes rules based on a specific data structure, and converts the first message data in JSON format into the second message data in the data format corresponding to the rule engine through the scenario execution service. Among them, the data format corresponding to the rule engine is the mapping data (MAP) format. The data structure of the MAP format is more intuitive, which improves the traversal efficiency of the rule engine. At the same time, the MAP format allows dynamic deletion or addition of key-value pairs, which provides higher flexibility for the embodiment of the present application. The JSON format involves complex nested structures and data type conversions. By converting the JSON format to the MAP format, the rule engine is prevented from making mistakes when parsing the message data, and the stability of data parsing is improved. Taking the JSON format string listed in step S202 as an example, converting it to a MAP format string can obtain {"device":{"status":{"175921860444638":{"power":"on","b5_next_frame":0,"version":57}}}}.
[0047] S205, extracting a first parameter value corresponding to the first data type from the second message data;
[0048] Specifically, after the scenario execution service converts the first message data into the second message data, the second message data is input into the rule engine. The rule engine receives the second message data, iterates the key-value pairs in the second message data, and extracts the first parameter value corresponding to the first data type, where the first parameter value is the value in the key-value pair. Taking the second message data {"device":{"status":{"175921860444638":{"power":"on","b5_next_frame":0,"version":57}}}} in step S204 as an example, the first data types are "power", "b5_next_frame" and "version", so the corresponding first parameter values are "on", "0" and "57", respectively.
[0049] S206, obtaining a comparison operator in a target scenario trigger condition corresponding to the target scenario based on the rule engine, and comparing the first parameter value with the target parameter value in the target scenario trigger condition based on the comparison operator;
[0050] Specifically, the database of the rule engine stores the scene trigger conditions of each scene. The scene trigger condition refers to the prerequisite for a scene to occur. When the condition occurs, the scene can be triggered. In the embodiment of the present application, the scene trigger condition is a rule expression. After the message hub screens out the target scene, the scene execution service will query the target scene trigger condition of the target scene from the rule engine. The rule engine calls the target scene trigger condition from the database, obtains the comparison operator in the target scene trigger condition, and compares the first parameter value with the target parameter value in the target scene trigger condition based on the comparison operator. Taking the target scene corresponding to the first data type "power" as an example, the target scene trigger condition of the target scene is "device.status.175921860444638.power=='on'", it can be seen that the comparison operator of the target scene trigger condition is "==", the target parameter value is "on", and the first parameter value is also "on", that is, "on==on", and the comparison result is true.
[0051] If the comparison operator in the target scene trigger condition is ">" or "<", taking ">" as an example, if the target scene is to turn on the air conditioner, and the target scene trigger condition is that the indoor temperature is greater than 30°C, the target parameter value is 30. If the first message data is that the current indoor temperature is 32, then the first parameter value is 32. According to the rule engine, the expression "32>30" can be obtained. This expression is correct, so the comparison result is true; if the first message data is that the current indoor temperature is 26, then the first parameter value is 26. According to the rule engine, the expression "26>30" can be obtained. This expression is wrong, so the comparison result is false.
[0052] Among them, the database of the rule engine can be a relational database, a NoSQL database or an in-memory database. Relational databases, such as MySQL, Oracle and other databases, are the types of databases commonly used by rule engines, support complex query operations, and have good data consistency and integrity constraints. NoSQL databases, such as MongoDB, Cassandra and other databases, provide higher flexibility and scalability for rule engines, and are more suitable for rule engines that need to process large amounts of unstructured data. In-memory databases, such as Redis, Memcached and other databases, can be used by rule engines to store temporary data, so that the rule engine has a faster access speed and improves the performance of the rule engine. The device control method provided in this application focuses more on meeting the ever-changing needs of users. Therefore, the database of the rule engine can be a NoSQL database, preferably, it can be a MongoDB database. The MongoDB database has rich query functions, is easy to expand, and has strong fault recovery capabilities.
[0053] S207, if the comparison result output by the rule engine is true, determining that the first message data meets the target scenario trigger condition corresponding to the target scenario;
[0054] Specifically, the rule engine outputs a comparison result between the first parameter value and the target parameter value, and determines whether the first message data meets the target scenario trigger condition corresponding to the target scenario according to the comparison result. The comparison result is a Boolean value of True or False. If the comparison result output by the rule engine is true, that is, the rule engine outputs True, it is determined that the first message data meets the target scenario trigger condition corresponding to the target scenario.
[0055] In a feasible implementation, if the comparison result output by the rule engine is false, it is determined every Tuesday that the first message data does not meet the target scene trigger condition corresponding to the target scene, and there is no need to control the scene-associated device corresponding to the target scene to execute the corresponding action information.
[0056] S208, obtaining a scene-associated device corresponding to the target scene and action information corresponding to the scene-associated device;
[0057] Specifically, after determining that the first message data meets the scene triggering condition corresponding to the target scene, the scene-associated device corresponding to the target scene and the action information corresponding to the scene-associated device can be obtained. Among them, the scene-associated device is at least one device corresponding to the target scene, and there is a linkage relationship between multiple devices. For example, taking air-conditioning equipment as an example, "power" is used as the first data type. If the target scene corresponding to "power" is the switch control of linkage devices such as smart windows, smart curtains and air humidifiers, then the scene-associated devices corresponding to the target scene are smart windows, smart curtains and air humidifiers. When the first message data meets the target scene triggering condition of the target scene corresponding to "power", the action information for smart windows and smart curtains should be to detect whether the smart windows and smart curtains are closed, and if not, close them; the action information for the air humidifier is to detect whether the air humidifier is turned on, and if not, turn it on. Further, if the first message data also includes the temperature and mode of the air conditioner, the humidification mode of the air humidifier can also be controlled.
[0058] S209, sending the action information to the scene-associated device through multi-threading and / or asynchronous programming to control the scene-associated device to execute the action information.
[0059] Specifically, since the scene-associated device may be multiple devices, when there are multiple scene-associated devices corresponding to the target scene, the action information corresponding to each scene-associated device is sent to the scene-associated device through multi-threading and / or asynchronous programming to control each scene-associated device to execute the corresponding action information. Among them, each thread in the multi-threading is an execution path in the program, and can also be considered as a sub-task that runs independently in the program. The action information corresponding to each scene-associated device is regarded as a sub-task, and the program can run multiple sub-tasks at the same time through multi-threading. Asynchronous programming allows the program to execute multiple sub-tasks, and the suspension of one sub-task will not affect the progress of other sub-tasks. Taking the smart windows, smart curtains and air humidifiers listed in step S208 as an example, the corresponding action information is sent to the smart windows, smart curtains and air humidifiers at the same time through multi-threading and / or asynchronous programming, ensuring that multiple scene-associated devices can be executed simultaneously in linkage, thereby improving the efficiency of device control.
[0060] In an embodiment of the present application, by receiving the first message data sent by at least one target data source among multiple target data sources, the key in the key-value pair of the first message data is determined as the first data type of the first message data, and then the target scene corresponding to the first data type can be obtained in the subscription relationship between the preset data type and the scene. The first message data is converted into the second message data based on the data format corresponding to the rule engine, and the first parameter value corresponding to the first data type is extracted from the second message data. The comparison operator in the target scene trigger condition corresponding to the target scene is obtained based on the rule engine, and the first parameter value is compared with the target parameter value in the target scene trigger condition based on the comparison operator. If the comparison result output by the rule engine is true, it is determined that the first message data meets the target scene trigger condition corresponding to the target scene, and the scene-related device corresponding to the target scene and the action information corresponding to the scene-related device are obtained. The action information is sent to the scene-related device through multi-threading and / or asynchronous programming to control the scene-related device to execute the action information. Through the message data from multiple target data sources, accurate and comprehensive information is provided for the scene trigger, which meets the various complex needs of users and improves the user experience. When the message data is received, it can respond in time, and the message data is judged based on the rule engine whether it meets the scene trigger condition, which improves the efficiency of device control. Converting JSON format to MAP format prevents the rule engine from making mistakes when parsing message data, improving the stability of data parsing. Multithreading and / or asynchronous programming ensures that multiple scene-related devices can be executed simultaneously, improving the efficiency of device control.
[0061] See also Figure 4 , Figure 41 is a flow chart of a method for creating a new scene trigger condition provided in an embodiment of the present application. Figure 4 As shown, the method of the embodiment of the present application may include the following steps S301-S305.
[0062] S301, receiving a new scene set by a terminal device and new scene condition data corresponding to the new scene;
[0063] Specifically, users can create new scenes in the IoT Home APP according to their own needs and input the new scene condition data. The cloud receives the new scene set by the terminal device where the IoT Home APP is located and the new scene condition data corresponding to the new scene. Among them, the scene is a task preset by the user in the IoT Home APP. The task can be triggered by the user or automatically triggered by the system, and then the scene-related device corresponding to the scene is controlled to execute the corresponding action information. The new scene condition data includes at least one type of data. The IoT Home APP can provide users with the option of setting the logical relationship between multiple new scene condition data.
[0064] S302, encapsulating the newly created scene condition data into a first rule expression, determining the first rule expression as a newly created scene trigger condition corresponding to the newly created scene, and saving the newly created scene trigger condition into a database of a rule engine;
[0065] Specifically, after the cloud receives the newly created scene and the newly created scene condition data, the expression language (MVFlex Expression Language, MVEL) is used to encapsulate the newly created scene condition data into a first rule expression according to the logical relationship between one or more newly created scene condition data set by the user, and the first rule expression is determined as the newly created scene trigger condition corresponding to the newly created scene, and the newly created scene trigger condition is saved in the database of the rule engine. MVEL is a dynamic / static embeddable expression language that allows expressions to be dynamically calculated and executed at runtime. In the rule engine, MVEL can be used to write expressions. If the newly created scene received by the cloud is that after the air conditioner is turned on, the smart windows and smart curtains are closed, and the air humidifier is turned on at the same time, based on this, the new scene condition data entered by the user is that the air conditioner is turned on, and the cloud receives a string {"conditions":[{"applianceCode":175921860444638,"status":{"$and":[{"power":"on"}]}}]}, which is in JSON format. In a string in JSON format, each pair of key-value pairs is separated by "," and the key and value in each pair of key-value pairs are separated by ":". Therefore, from the above string, It is known that the key-value pair in the newly created scene condition data is "power":"on", "power" is the key, which can be used to indicate the power status of the air-conditioning device, and "on" is the value, indicating that the air-conditioning device is currently in the on state. At the same time, since the newly created scene has only one newly created scene condition data, the cloud does not need to consider logical operators when encapsulating the first rule expression, but only needs to determine the comparison operator used, and the comparison operator corresponding to the air-conditioning status is "==". Therefore, the encapsulated first rule expression is device.status.175921860444638.power=='on', and the first rule expression is saved in the database of the rule engine.
[0066] Among them, the database of the rule engine can be a relational database, a NoSQL database or an in-memory database. Relational databases, such as MySQL, Oracle and other databases, are the types of databases commonly used by rule engines, support complex query operations, and have good data consistency and integrity constraints. NoSQL databases, such as MongoDB, Cassandra and other databases, provide higher flexibility and scalability for rule engines, and are more suitable for rule engines that need to process large amounts of unstructured data. In-memory databases, such as Redis, Memcached and other databases, can be used by rule engines to store temporary data, so that the rule engine has a faster access speed and improves the performance of the rule engine. The device control method provided in this application focuses more on meeting the ever-changing needs of users. Therefore, the database of the rule engine can be a NoSQL database, preferably, it can be a MongoDB database. The MongoDB database has rich query functions, is easy to expand, and has strong fault recovery capabilities.
[0067] S303: Obtain a second data type of the newly created scene condition data, and establish a subscription relationship between the second data type and the newly created scene.
[0068] Specifically, obtain the key-value pair of the newly created scene condition data, determine the key in the key-value pair as the second data type, establish and save the subscription relationship between the second data type and the newly created scene in the message hub. Taking the newly created scene and the newly created scene condition data {"conditions":[{"applianceCode":175921860444638,"status":{"$and":[{"power":"on"}]}}]} in step S302 as an example, establish a subscription relationship between the air conditioning status and the switch status of smart windows, smart curtains and air humidifiers in the message hub.
[0069] S304, querying at least one data source corresponding to the second data type, and determining each data source in the at least one data source as a target data source;
[0070] Specifically, after obtaining the second data type of the newly created scene condition data, at least one data source corresponding to the second data type can be queried based on the second data type. The data source can obtain and send message data of the second data type, and each of the at least one data source is determined as a target data source, providing multiple message data sources for the device control method of the embodiment of the present application. For example, the newly created scene set by the user in the IoT Home APP is a waking scene, and the newly created scene condition data is that the current time is 7:00 am Beijing time. The second data type is a time type. The data source queried in the cloud can be the terminal device of the user logged in by the IoT Home APP, or it can be a clock module or electronic clock built into the IoT Home system. It can also be a cloud internal or third-party cloud that obtains time data through the network time protocol or operating system, and all of these data sources are determined as target data sources.
[0071] S305: Establish a communication connection with a target data source to receive message data sent by the target data source.
[0072] Specifically, a communication connection is established with the target data source to receive the message data sent by the target data source. If the target data source is a device included in the IoT home system, a communication connection can be established with the target data source through communication protocols such as Wi-Fi, Bluetooth, ZigBee, LoRa, etc.; if the target data source is inside the cloud, the message data can be obtained directly from the cloud; if the target data source is a third-party cloud, a communication connection can be established with the third-party cloud through the network, domain name or IP address.
[0073] In an embodiment of the present application, a user can create a new scene and input the new scene condition data. The cloud receives the new scene set by the terminal device and the new scene condition data corresponding to the new scene, encapsulates the new scene condition data into a first rule expression, determines the first rule expression as the new scene trigger condition corresponding to the new scene, saves the new scene trigger condition into the database of the rule engine, obtains the second data type of the new scene condition data, and establishes a subscription relationship between the second data type and the new scene in the message hub. When the new scene and the new scene condition data sent by the terminal device are received, the new scene condition data is encapsulated into a first rule expression, and the first rule expression is determined as the new scene trigger condition of the new scene. There is no need to write complex code, which reduces the amount of code and development costs. By querying the data source and determining multiple target data sources, the timeliness and accuracy of the message data are guaranteed, and precise control of the device is further achieved.
[0074] See also Figure 5 , Figure 5 1 is a flow chart of a method for updating a scene trigger condition provided in an embodiment of the present application. Figure 5As shown, the method of the embodiment of the present application may include the following steps S401-S403.
[0075] S401, if updated scene condition data added by the terminal device for the updated scene is received, encapsulating the added updated scene condition data into a second regular expression;
[0076] Specifically, users can update the set scenes at any time, and add scene condition data to the set scenes. When users add scene condition data to the set scenes in the IoT Home APP, the scene can be determined as an updated scene. When the cloud receives the updated scene condition data added for the updated scene in the terminal device where the IoT Home APP is located, the added updated scene condition data is encapsulated as a second regular expression. Among them, the scene is a task preset by the user in the IoT Home APP. The task can be triggered by the user or automatically triggered by the system, and then the scene-associated device corresponding to the scene is controlled to execute the corresponding action information. The updated scene condition data includes at least one type of data. After the cloud receives the updated scene and the updated scene condition data, it uses MVEL to encapsulate the updated scene condition data into a second regular expression according to the logical relationship between one or more updated scene condition data set by the user.
[0077] S402, assembling the second regular expression with the update scenario triggering condition corresponding to the update scenario to obtain a third regular expression, and updating the update scenario triggering condition to the third regular expression;
[0078] Specifically, the scene execution service queries the update scene trigger condition corresponding to the update scene from the rule engine, and inputs the second rule expression into the rule engine; the rule engine assembles the second rule expression with the update scene trigger condition according to the logical relationship between the update scene condition data set by the user and the update scene trigger condition to obtain a third rule expression; and updates the update scene trigger condition corresponding to the update scene to the third rule expression in the database of the rule engine.
[0079] If the user adds a waking up scene trigger condition for the waking up scene, the waking up scene is determined as the update scene, the original update scene trigger condition is that the clock points to 7:00 am, and the update scene associated devices corresponding to the update scene are smart curtains, coffee machines, and bread machines. When the user wants to make the update scene trigger condition of the update scene be that the clock points to 7:00 am, or the alarm rings, or the outdoor light intensity reaches the preset light intensity threshold, the user needs to input the update scene condition data of the alarm ringing or the outdoor light intensity reaching the preset light intensity threshold into the IoT home APP, and select the logical relationship between the two as "or", and the logical relationship between the two and the original update scene condition data as "or". After the cloud receives the update scene and update scene condition data set by the user, it encapsulates the alarm ringing and the outdoor light intensity reaching the preset light intensity threshold into the second rule expression, and inputs the two second rule expressions and the logical relationship between them and the original update scene trigger condition into the rule engine. The rule engine uses the "||" logical relationship to assemble the two second rule expressions and the original scene trigger condition into the third rule expression.
[0080] S403: Acquire a third data type of the update scenario condition data, and add a subscription relationship between the third data type and the update scenario.
[0081] Specifically, after updating the update scene trigger conditions of the update scene, it is also necessary to update the subscription relationship between the update scene and the message data in the message hub. Therefore, obtain the key-value pair of the update condition data, determine the key in the key-value pair as the third data type of the update scene condition data, and add the subscription relationship between the third data type and the update scene in the message hub.
[0082] Optionally, after obtaining the third data type of the update scene condition data, query at least one data source corresponding to the third data type. If the target data source does not include the data source corresponding to the third data type, determine the data source corresponding to the third data type as a newly added target data source, and establish a communication connection with the newly added target data source to receive message data from the newly added target data source, thereby further increasing the source of message data. For example, if the update scene is a waking scene, and the update scene condition data is that in summer, the current time is 7:00 a.m. Beijing time; in winter, the current time is 7:30 a.m. Beijing time, and the third data type is a time type and a season type, and the target data source already includes a data source corresponding to the time type, then the data source that can obtain the season data is determined as the newly added target data source.
[0083] In an embodiment of the present application, a user can update a scene and a scene trigger condition of the scene. When the cloud receives the updated scene condition data added by the terminal device for the updated scene, the added updated scene condition data is encapsulated into a second rule expression, and the second rule expression is assembled with the updated scene trigger condition corresponding to the updated scene to obtain a third rule expression, and the updated scene trigger condition is updated to the third rule expression, and the third data type of the updated scene condition data is obtained, and a subscription relationship between the third data type and the updated scene is added. When adding a scene trigger condition for a certain updated scene, the added updated scene condition data can be directly encapsulated into a second rule expression, assembled with the original updated scene trigger condition, and the assembled third rule expression is determined as the updated scene trigger condition, without the need to modify a large amount of code, reducing the workload of developers and reducing the coupling degree of the underlying code.
[0084] See also Figure 6 , Figure 6 is a flow chart of a device control method provided in an embodiment of the present application. Figure 6 As shown, users can create new scenes in the IoT home APP based on their own needs, and input the new scene condition data of the new scene. After the cloud receives the new scene condition data, the new scene condition data is assembled into a first rule expression, and the first rule expression is determined as the new scene trigger condition of the new scene, so as to save the new scene and the new scene trigger condition in the database of the rule engine, and at the same time, a subscription relationship between the new data type of the new scene condition data and the new scene is established in the message hub. When the message hub receives the first message data from at least one target data source among multiple target data sources, the message hub selects the target scene corresponding to the first data type from the established subscription relationship through the first data type of the first message data, and forwards the first message data to the scene execution service. The scene execution service queries the target scene trigger condition of the target scene from the database of the rule engine, and determines whether the first message data meets the target scene trigger condition of the target scene based on the rule engine. If it is determined that the first message data meets the target scene trigger condition, the scene-associated device corresponding to the target scene is controlled to execute the corresponding action information; if it is determined that the first message data does not meet the target scene trigger condition, the process ends.
[0085] based on Figure 1 The system architecture will be combined with Figure 7 , the device control device provided in the embodiment of the present application is introduced in detail. It should be noted that, Figure 7 The device control device in the present application is used to execute Figure 2-Figure 6 For the convenience of explanation, only the part related to the embodiment of the present application is shown. For the specific technical details not disclosed, please refer to the present application. Figure 2-Figure 6 The embodiment shown.
[0086] See also Figure 7 , Figure 7 Schematic diagram of a device control device provided in an embodiment of the present application. Figure 7 As shown, the device control apparatus 1000 of the embodiment of the present application may include: a message data receiving unit 1001, a target scene acquisition unit 1002, an action information acquisition unit 1003 and an action execution unit 1004.
[0087] The message data receiving unit 1001 is used to receive first message data sent by at least one target data source among multiple target data sources, and obtain a first data type of the first message data;
[0088] The target scene acquisition unit 1002 is used to acquire the target scene corresponding to the first data type in the subscription relationship between the preset data type and the scene;
[0089] The action information acquisition unit 1003 is used to acquire the scene-associated device corresponding to the target scene and the action information corresponding to the scene-associated device if it is determined based on the rule engine that the first message data meets the target scene trigger condition corresponding to the target scene;
[0090] The action execution unit 1004 is used to send the action information to the scene-associated device to control the scene-associated device to execute the action information.
[0091] In an embodiment of the present application, by receiving the first message data sent by at least one target data source among multiple target data sources, the first data type is obtained from the first message data, and then in the subscription relationship between the preset data type and the scene, the target scene corresponding to the first data type is obtained. If it is determined based on the rule engine that the first message data meets the scene trigger condition corresponding to the target scene, the scene-associated device corresponding to the target scene and the action information corresponding to the scene-associated device are obtained, the action information is sent to the scene-associated device, and the scene-associated device is controlled to execute the action information. Based on the rule engine, it is determined whether the first message data meets the scene trigger condition corresponding to the target scene, and the scene is separated from the application code through the rule engine, which reduces the code coupling and meets the complex needs of users.
[0092] See also Figure 8 , Figure 8 Schematic diagram of a device control device provided in an embodiment of the present application. Figure 8As shown, the device control device 1000 of the embodiment of the present application may include: a new scene data receiving unit 1009, a first expression encapsulation unit 1010, a subscription relationship establishment unit 1011, a data source query unit 1012, a connection unit 1013, a message data receiving unit 1001, a target scene acquisition unit 1002, a data format conversion unit 1005, a parameter value extraction unit 1006, a parameter value comparison unit 1007, a trigger determination unit 1008, an action information acquisition unit 1003, an action execution unit 1004, a second expression encapsulation unit 1014, an expression assembly unit 1015, a condition update unit 1016 and a subscription relationship addition unit 1017.
[0093] A newly created scene data receiving unit 1009 is used to receive a newly created scene set by a terminal device and newly created scene condition data corresponding to the newly created scene;
[0094] A first expression encapsulation unit 1010 is used to encapsulate the newly created scene condition data into a first regular expression, determine the first regular expression as a newly created scene trigger condition corresponding to the newly created scene, and save the newly created scene trigger condition into a database of a rule engine;
[0095] A subscription relationship establishing unit 1011, used to obtain a second data type of the newly created scene condition data, and establish a subscription relationship between the second data type and the newly created scene;
[0096] A data source query unit 1012, configured to query at least one data source corresponding to the second data type, and determine each of the at least one data source as a target data source;
[0097] The connection unit 1013 is used to establish a communication connection with a target data source to receive message data sent by the target data source;
[0098] The message data receiving unit 1001 is used to receive first message data sent by at least one target data source among multiple target data sources, and obtain a first data type of the first message data;
[0099] Optionally, the message data receiving unit 1001 is specifically configured to obtain a key-value pair in the first message data, and determine the key in the key-value pair as the first data type of the first message data.
[0100] The target scene acquisition unit 1002 is used to acquire the target scene corresponding to the first data type in the subscription relationship between the preset data type and the scene;
[0101] A data format conversion unit 1005, configured to convert the first message data into the second message data based on a data format corresponding to the rule engine;
[0102] A parameter value extraction unit 1006, configured to extract a first parameter value corresponding to a first data type from the second message data;
[0103] A parameter value comparison unit 1007, configured to obtain a comparison operator in a target scenario trigger condition corresponding to the target scenario based on a rule engine, and compare the first parameter value with a target parameter value in the target scenario trigger condition based on the comparison operator;
[0104] A trigger determination unit 1008, configured to determine that the first message data satisfies a target scenario trigger condition corresponding to the target scenario if the comparison result output by the rule engine is true;
[0105] The action information acquisition unit 1003 is used to acquire the scene-associated device corresponding to the target scene and the action information corresponding to the scene-associated device if it is determined based on the rule engine that the first message data meets the target scene trigger condition corresponding to the target scene;
[0106] The action execution unit 1004 is used to send the action information to the scene-related device to control the scene-related device to execute the action information;
[0107] Optionally, the action execution unit 1004 is specifically used to send the action information to the scene-associated device through multi-threading and / or asynchronous programming to control the scene-associated device to execute the action information.
[0108] The second expression encapsulation unit 1014 is configured to encapsulate the added update scene condition data into a second regular expression if update scene condition data added by the terminal device for the update scene is received;
[0109] An expression assembling unit 1015, configured to assemble the second regular expression with an update scenario triggering condition corresponding to the update scenario to obtain a third regular expression;
[0110] A condition updating unit 1016, configured to update the update scenario triggering condition to a third regular expression;
[0111] The subscription relationship adding unit 1017 is used to obtain the third data type of the update scenario condition data and add a subscription relationship between the third data type and the update scenario.
[0112] In an embodiment of the present application, by receiving the first message data sent by at least one target data source among multiple target data sources, the key in the key-value pair of the first message data is determined as the first data type of the first message data, and then the target scene corresponding to the first data type can be obtained in the subscription relationship between the preset data type and the scene. The first message data is converted into the second message data based on the data format corresponding to the rule engine, and the first parameter value corresponding to the first data type is extracted from the second message data. The comparison operator in the target scene trigger condition corresponding to the target scene is obtained based on the rule engine, and the first parameter value is compared with the target parameter value in the target scene trigger condition based on the comparison operator. If the comparison result output by the rule engine is true, it is determined that the first message data meets the target scene trigger condition corresponding to the target scene, and the scene-related device corresponding to the target scene and the action information corresponding to the scene-related device are obtained. The action information is sent to the scene-related device through multi-threading and / or asynchronous programming to control the scene-related device to execute the action information. Through the message data from multiple target data sources, accurate and comprehensive information is provided for the scene trigger, which meets the various complex needs of users and improves the user experience. When the message data is received, it can respond in time, and the message data is judged based on the rule engine whether it meets the scene trigger condition, which improves the efficiency of device control. The embodiment of the present application provides multiple target data sources, providing accurate and comprehensive information for scene triggering, and ensuring the timeliness of device control. Converting the JSON format to the MAP format prevents the rule engine from making mistakes when parsing message data, thereby improving the stability of data parsing. Multi-threaded and / or asynchronous programming ensures that multiple scene-related devices can be executed in conjunction with each other at the same time, thereby improving the efficiency of device control. When receiving the new scene and new scene condition data sent by the terminal device, the new scene condition data is encapsulated into a first rule expression, and the first rule expression is determined as the new scene trigger condition of the new scene. There is no need to write complex code, thereby reducing the amount of code and development costs. When adding a scene trigger condition for a certain update scene, the added update scene condition data can be directly encapsulated into a second rule expression, assembled with the original update scene trigger condition, and the assembled third rule expression is determined as the update scene trigger condition. There is no need to modify the code a lot, thereby reducing the workload of developers and the coupling degree of the underlying code.
[0113] See also Fig. 9 , Fig. 9 It is a structural diagram of a computer device provided in an embodiment of the present application.
[0114] For example, Fig. 9 As shown, the computer device 900 includes: a processor 901 and a memory 902, wherein the processor 901 is electrically connected to the memory 902.
[0115] The processor 901 is the control center of the computer device 900 and may include one or more processing cores. The processor 901 uses various interfaces and lines to connect various parts of the entire computer device, and executes various functions of the computer device and processes data by running or calling computer programs stored in the memory 902, and calling data stored in the memory 902, so as to control the computer device 900 as a whole. Optionally, the processor 901 can be implemented in at least one hardware form of digital signal processing (DSP), field programmable gate array (FPGA), and programmable logic array (PLA). The processor 901 can integrate one or a combination of CPU, graphics processing unit (GPU), modem, etc. Among them, the CPU mainly processes the operating system, user pages, and applications; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 901, but may be implemented separately through a communication chip.
[0116] The memory 902 may be used to store software programs and modules, and the processor 901 executes various functional applications and data processing by running computer programs and modules stored in the memory 902. The memory 902 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, a computer program required for at least one function, etc.; the data storage area may store data created according to the use of the computer device 900, etc.
[0117] In addition, the memory 902 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 902 may also include a memory controller to provide the processor 901 with access to the memory 902.
[0118] In this embodiment, the processor 901 in the computer device 900 loads instructions corresponding to the processes of one or more computer programs into the memory 902 according to the following steps, and the processor 901 runs the computer program stored in the memory 902 to implement various functions, as follows:
[0119] Receiving first message data sent by at least one target data source among multiple target data sources, and acquiring a first data type of the first message data;
[0120] In the subscription relationship between the preset data type and the scene, obtaining the target scene corresponding to the first data type;
[0121] If it is determined based on the rule engine that the first message data meets the target scenario trigger condition corresponding to the target scenario, then the scenario-associated device corresponding to the target scenario and the action information corresponding to the scenario-associated device are obtained;
[0122] The action information is sent to the scene-associated device to control the scene-associated device to execute the action information.
[0123] Optionally, when executing to obtain the first data type of the first message data, the processor 901 specifically performs:
[0124] A key-value pair in the first message data is obtained, and a key in the key-value pair is determined as a first data type of the first message data.
[0125] Optionally, before executing if it is determined based on the rule engine that the first message data meets the scene trigger condition corresponding to the target scene, obtaining the scene-associated device corresponding to the target scene and the action information corresponding to the scene-associated device, the processor 901 further executes:
[0126] Converting the first message data into the second message data based on a data format corresponding to the rule engine;
[0127] Extracting a first parameter value corresponding to the first data type from the second message data;
[0128] Obtaining a comparison operator in a target scenario trigger condition corresponding to the target scenario based on the rule engine, and comparing the first parameter value with the target parameter value in the target scenario trigger condition based on the comparison operator;
[0129] If the comparison result output by the rule engine is true, it is determined that the first message data meets the target scenario trigger condition corresponding to the target scenario.
[0130] Optionally, the processor 901 further executes:
[0131] Receive a new scene set by a terminal device and new scene condition data corresponding to the new scene;
[0132] Encapsulating the newly created scene condition data into a first rule expression, determining the first rule expression as a newly created scene trigger condition corresponding to the newly created scene, and saving the newly created scene trigger condition into a database of the rule engine;
[0133] The second data type of the newly created scene condition data is obtained, and a subscription relationship between the second data type and the newly created scene is established.
[0134] Optionally, after executing the process of acquiring the second data type of the newly created scene condition data and establishing a subscription relationship between the second data type and the newly created scene, the processor 901 further executes:
[0135] querying at least one data source corresponding to the second data type, and determining each data source in the at least one data source as a target data source;
[0136] Establish a communication connection with the target data source to receive the message data sent by the target data source.
[0137] Optionally, the processor 901 further executes:
[0138] If the updated scene condition data added by the terminal device for the updated scene is received, the added updated scene condition data is encapsulated as a second regular expression;
[0139] Assembling the second regular expression with the update scenario trigger condition corresponding to the update scenario to obtain a third regular expression;
[0140] Update the update scene trigger condition to the third regular expression;
[0141] The third data type of the update scenario condition data is obtained, and a subscription relationship between the third data type and the update scenario is added.
[0142] Optionally, the target data source includes at least one of a clock data source, a home appliance data source, a terminal device data source and a cloud data source.
[0143] Optionally, when the processor 901 sends the action information to the scene-associated device to control the scene-associated device to execute the action information, the processor 901 specifically executes:
[0144] The action information is sent to the scene-associated device through multi-threading and / or asynchronous programming to control the scene-associated device to execute the action information.
[0145] In an embodiment of the present application, by receiving the first message data sent by at least one target data source among multiple target data sources, the key in the key-value pair of the first message data is determined as the first data type of the first message data, and then the target scene corresponding to the first data type can be obtained in the subscription relationship between the preset data type and the scene. The first message data is converted into the second message data based on the data format corresponding to the rule engine, and the first parameter value corresponding to the first data type is extracted from the second message data. The comparison operator in the target scene trigger condition corresponding to the target scene is obtained based on the rule engine, and the first parameter value is compared with the target parameter value in the target scene trigger condition based on the comparison operator. If the comparison result output by the rule engine is true, it is determined that the first message data meets the target scene trigger condition corresponding to the target scene, and the scene-related device corresponding to the target scene and the action information corresponding to the scene-related device are obtained. The action information is sent to the scene-related device through multi-threading and / or asynchronous programming to control the scene-related device to execute the action information. Through the message data from multiple target data sources, accurate and comprehensive information is provided for the scene trigger, which meets the various complex needs of users and improves the user experience. When the message data is received, it can respond in time, and the message data is judged based on the rule engine whether it meets the scene trigger condition, which improves the efficiency of device control. The embodiment of the present application provides multiple target data sources, providing accurate and comprehensive information for scene triggering, and ensuring the timeliness of device control. Converting the JSON format to the MAP format prevents the rule engine from making mistakes when parsing message data, thereby improving the stability of data parsing. Multi-threaded and / or asynchronous programming ensures that multiple scene-related devices can be executed in conjunction with each other at the same time, thereby improving the efficiency of device control. When receiving the new scene and new scene condition data sent by the terminal device, the new scene condition data is encapsulated into a first rule expression, and the first rule expression is determined as the new scene trigger condition of the new scene. There is no need to write complex code, thereby reducing the amount of code and development costs. When adding a scene trigger condition for a certain update scene, the added update scene condition data can be directly encapsulated into a second rule expression, assembled with the original update scene trigger condition, and the assembled third rule expression is determined as the update scene trigger condition. There is no need to modify the code a lot, thereby reducing the workload of developers and the coupling degree of the underlying code.
[0146] It should be understood that the apparatus provided in the embodiment of the present application is used to execute the above-mentioned device control method, and thus can achieve the same effect as the above-mentioned implementation method.
[0147] In the case of an integrated unit, the device may include a processing module and a storage module. When the device is applied to a computer device, the processing module may be used to control and manage the actions of the computer device. The storage module may be used to support the computer device in executing related program codes, etc.
[0148] The processing module may be a processor or a controller, which may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc. The storage module may be a memory.
[0149] In addition, the device provided in the embodiment of the present application can specifically be a chip, component or module, and the chip may include a connected processor and memory; wherein the memory is used to store instructions, and when the processor calls and executes the instructions, the chip can execute a device control method provided in the above embodiment.
[0150] An embodiment of the present application also provides a computer-readable storage medium, in which a computer program code is stored. When the computer program code is executed on a computer, the computer executes the above-mentioned related method steps to implement a device control method provided in the above-mentioned embodiment.
[0151] This embodiment further provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the above-mentioned related steps to implement a device control method provided by the above embodiment.
[0152] Among them, the device, computer-readable storage medium, computer program product or chip provided in this embodiment is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be repeated here.
[0153] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0154] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0155] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A device control method, characterized in that: The method comprises: Receiving first message data sent by at least one target data source among multiple target data sources, and acquiring a first data type of the first message data; In the preset subscription relationship between the data type and the scene, obtaining the target scene corresponding to the first data type; If it is determined based on the rule engine that the first message data meets the target scenario trigger condition corresponding to the target scenario, then obtaining the scenario-associated device corresponding to the target scenario and the action information corresponding to the scenario-associated device; The action information is sent to the scene-associated device to control the scene-associated device to execute the action information.
2. The method according to claim 1, characterized in that The acquiring the first data type of the first message data includes: A key-value pair in the first message data is obtained, and a key in the key-value pair is determined as a first data type of the first message data.
3. The method according to claim 1 or 2, characterized in that: If it is determined based on the rule engine that the first message data satisfies the scene trigger condition corresponding to the target scene, before obtaining the scene-associated device corresponding to the target scene and the action information corresponding to the scene-associated device, the method further includes: Converting the first message data into the second message data based on a data format corresponding to the rule engine; Extracting a first parameter value corresponding to the first data type from the second message data; Acquire a comparison operator in a target scenario trigger condition corresponding to the target scenario based on the rule engine, and compare the first parameter value with a target parameter value in the target scenario trigger condition based on the comparison operator; If the comparison result output by the rule engine is true, it is determined that the first message data meets the target scenario trigger condition corresponding to the target scenario.
4. The method according to claim 1 or 2, characterized in that: The method further comprises: Receiving a new scene set by a terminal device and new scene condition data corresponding to the new scene; Encapsulating the newly created scene condition data into a first regular expression, determining the first regular expression as a newly created scene trigger condition corresponding to the newly created scene, and saving the newly created scene trigger condition into a database of a rule engine; A second data type of the newly created scene condition data is obtained, and a subscription relationship between the second data type and the newly created scene is established.
5. The method according to claim 4, characterized in that After acquiring the second data type of the newly created scene condition data and establishing a subscription relationship between the second data type and the newly created scene, the method further includes: querying at least one data source corresponding to the second data type, and determining each data source in the at least one data source as a target data source; A communication connection is established with the target data source to receive message data sent by the target data source.
6. The method according to claim 1 or 2, characterized in that: The method further comprises: If the updated scene condition data added by the terminal device for the updated scene is received, the added updated scene condition data is encapsulated as a second regular expression; Assembling the second regular expression with the update scenario trigger condition corresponding to the update scenario to obtain a third regular expression; Updating the update scenario trigger condition to the third regular expression; A third data type of the update scenario condition data is obtained, and a subscription relationship between the third data type and the update scenario is added.
7. The method according to claim 1, characterized in that The target data source includes at least one of a clock data source, a home appliance data source, a terminal device data source and a cloud data source.
8. The method according to claim 1, characterized in that The sending the action information to the scene-associated device to control the scene-associated device to execute the action information includes: The action information is sent to the scene-associated device through multi-threading and / or asynchronous programming to control the scene-associated device to execute the action information.
9. A device control device, characterized in that: The device comprises: A message data receiving unit, configured to receive first message data sent by at least one target data source among a plurality of target data sources, and obtain a first data type of the first message data; A target scene acquisition unit, configured to acquire a target scene corresponding to the first data type in a preset subscription relationship between the data type and the scene; an action information acquisition unit, configured to acquire a scene-associated device corresponding to the target scene and action information corresponding to the scene-associated device if it is determined based on a rule engine that the first message data satisfies a target scene trigger condition corresponding to the target scene; An action execution unit is used to send the action information to the scene-related device to control the scene-related device to execute the action information.
10. A computer device, characterized in that: The computer device comprises: A memory for storing executable program codes; A processor, configured to call and run the executable program code from the memory, so that the computer device executes the method according to any one of claims 1 to 8.
11. A computer program product, characterized in that The computer program product comprises: Computer program code, when the computer program code is executed, implements the method according to any one of claims 1 to 8.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program code, and when the computer program code is executed, the method according to any one of claims 1 to 8 is implemented.