WO2024125052A1 - 设备控制方法、装置、电子设备及计算机存储介质 - Google Patents

设备控制方法、装置、电子设备及计算机存储介质 Download PDF

Info

Publication number
WO2024125052A1
WO2024125052A1 PCT/CN2023/123635 CN2023123635W WO2024125052A1 WO 2024125052 A1 WO2024125052 A1 WO 2024125052A1 CN 2023123635 W CN2023123635 W CN 2023123635W WO 2024125052 A1 WO2024125052 A1 WO 2024125052A1
Authority
WO
WIPO (PCT)
Prior art keywords
preset
shadow
attribute
target
iot
Prior art date
Application number
PCT/CN2023/123635
Other languages
English (en)
French (fr)
Inventor
王银华
Original Assignee
深圳Tcl新技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳Tcl新技术有限公司 filed Critical 深圳Tcl新技术有限公司
Publication of WO2024125052A1 publication Critical patent/WO2024125052A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/12Protocols specially adapted for proprietary or special-purpose networking environments, e.g. medical networks, sensor networks, networks in vehicles or remote metering networks
    • H04L67/125Protocols specially adapted for proprietary or special-purpose networking environments, e.g. medical networks, sensor networks, networks in vehicles or remote metering networks involving control of end-device applications over a network
    • GPHYSICS
    • G16INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR SPECIFIC APPLICATION FIELDS
    • G16YINFORMATION AND COMMUNICATION TECHNOLOGY SPECIALLY ADAPTED FOR THE INTERNET OF THINGS [IoT]
    • G16Y40/00IoT characterised by the purpose of the information processing
    • G16Y40/30Control
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/02Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]

Definitions

  • the present application relates to the field of data processing technology, and in particular to a device control method, apparatus, electronic device and computer storage medium.
  • IoT devices are becoming more and more popular among users, and more and more IoT devices are controlled by the same user.
  • each IoT device will be associated with a scene, and then the server will determine whether to trigger the scene based on the status data of the IoT device, thereby determining whether to trigger the IoT device associated with the scene.
  • the server will determine whether to trigger the scene based on the status data of the IoT device, thereby determining whether to trigger the IoT device associated with the scene.
  • a large amount of status data is obtained, which results in a longer time to determine whether a scene is triggered and lower concurrent performance of the server.
  • the present application provides a device control method, including:
  • the attribute status data is sent to the preset message queue
  • an action execution instruction for the second IoT device is generated according to the target preset scenario through the consumer thread;
  • the action execution instruction is sent to the second IoT device through the consumer thread to control the second IoT device to perform the operation corresponding to the action execution instruction.
  • an embodiment of the present application provides a device control apparatus, including:
  • a data acquisition module used to acquire attribute status data reported by multiple first IoT devices
  • a data sending module used for sending the attribute status data to a preset message queue if the attribute status data meets a preset trigger condition
  • a thread acquisition module used to acquire multiple consumer threads of the preset message queue, and acquire the target preset scene associated with the first IoT device and the current device shadow of the second IoT device corresponding to the target preset scene through the consumer threads according to the attribute state data;
  • An instruction generation module configured to generate an action execution instruction for the second IoT device according to the target preset scenario through the consumer thread if the current device shadow matches the preset device shadow corresponding to the second IoT device in the target preset scenario;
  • An instruction sending module is used to send the above-mentioned action execution instruction to the above-mentioned second Internet of Things through the above-mentioned consumer thread Device, to control the above-mentioned second Internet of Things device to perform the operation corresponding to the above-mentioned action execution instruction.
  • an embodiment of the present application also provides an electronic device, including a processor and a memory, wherein the memory stores a computer program, and the processor is used to run the computer program in the memory to implement the device control method provided in the embodiment of the present application.
  • an embodiment of the present application further provides a computer-readable storage medium, which stores a computer program.
  • the computer program is suitable for loading by a processor to execute any device control method provided in the embodiment of the present application.
  • an embodiment of the present application also provides a computer program product, including a computer program, and when the computer program is executed by a processor, any device control method provided in the embodiment of the present application is implemented.
  • attribute status data reported by multiple first IoT devices are obtained; if the attribute status data meets the preset trigger condition, the attribute status data is sent to a preset message queue; multiple consumer threads of the preset message queue are obtained, and the target preset scene associated with the first IoT device and the current device shadow of the second IoT device corresponding to the target preset scene are obtained through the consumer thread according to the attribute status data; if the current device shadow matches the preset device shadow corresponding to the second IoT device in the target preset scene, an action execution instruction for the second IoT device is generated according to the target preset scene through the consumer thread; the action execution instruction is sent to the second IoT device through the consumer thread to control the second IoT device to execute the operation corresponding to the action execution instruction, so as to realize the judgment of whether to trigger the target preset scene through multiple consumer threads of the preset message queue, speed up the triggering of the target preset scene, and improve the concurrency performance of the server.
  • FIG1 is a schematic diagram of a flow chart of a device control method provided in an embodiment of the present application.
  • FIG2 is a schematic diagram of a shadow set provided in an embodiment of the present application.
  • FIG3 is a schematic diagram of another device control method provided in an embodiment of the present application.
  • FIG4 is a schematic diagram of another device control method provided in an embodiment of the present application.
  • FIG5 is a schematic diagram of another device control method provided in an embodiment of the present application.
  • FIG6 is a schematic diagram of the structure of a device control device provided in an embodiment of the present application.
  • FIG. 7 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
  • the embodiments of the present application provide a device control method, device, electronic device and computer storage medium.
  • the device control device can be integrated in an electronic device, which can be a server or a gateway.
  • the gateway and the server may be connected directly or indirectly via wired or wireless communication, which is not limited in this application.
  • the term “plurality” in the embodiments of the present application refers to two or more than two.
  • the terms “first” and “second” in the embodiments of the present application are used to distinguish descriptions and should not be understood as implying relative importance.
  • the description will be made from the perspective of the device control apparatus.
  • the device control apparatus will be integrated in a server for detailed description, that is, the server will be used as the execution subject for detailed description.
  • FIG1 is a flow chart of a device control method provided by an embodiment of the present application.
  • the device control method may include:
  • the first Internet of Things device can be a trigger device for each preset scene, that is, it can be a trigger for each preset scene, used to determine whether to trigger the preset scene.
  • the first Internet of Things device can be various sensors, or the first Internet of Things device can include a sensor terminal.
  • the first IoT devices of different preset scenarios may be the same or different.
  • the preset trigger conditions satisfied by the first IoT devices of different preset scenarios are also the same, it can be understood that when the attribute state data of the first IoT device satisfies the preset trigger conditions, different preset scenarios are triggered at the same time.
  • the attribute state data refers to data indicating the properties of the first IoT device, wherein the properties of the first IoT device may refer to the static properties of the first IoT device, or may refer to the dynamic properties of the first IoT device.
  • the attribute state data may refer to the device identification of the first IoT device, where the device identification is the static properties of the first IoT device, or for another example, the attribute state data may refer to the status data of the first IoT device, where the status data is the dynamic properties of the first IoT device.
  • the status data may refer to data collected in real time by the first IoT device.
  • the status data may be data collected by the infrared sensor.
  • the data collected by the infrared sensor may indicate two states, one state is when there is someone, and the other state is when there is no one.
  • the first IoT device may periodically collect attribute status data, and then periodically send the attribute status data to the server, so that the server obtains the attribute status data reported by multiple first IoT devices.
  • the first IoT device may also collect attribute status data according to the collection instruction when receiving the collection instruction, and then send the attribute status data to the server, so that the server obtains the attribute status data reported by the first IoT device.
  • the manner in which the server obtains the attribute status data reported by the first IoT device may be selected according to actual conditions, and this embodiment does not limit this.
  • the server can determine whether the attribute status data meets the preset trigger condition, or the first Internet of Things device can determine whether the preset trigger condition is met. If the preset trigger condition is met, the first Internet of Things device will send the attribute status data that meets the preset trigger condition and the attribute status data to the server, and the server will send the attribute status data to the preset message queue.
  • the preset message queue refers to a container for storing messages.
  • the type of the preset message queue can be selected according to actual conditions.
  • the preset message queue can be an MQ message queue, an ActiveMQ message queue, a RabbitMQ message queue, or a ZeroMQ message queue, etc. This embodiment does not limit this.
  • the server may input the attribute identifier and the status data in the attribute status data into the trigger tree, so as to determine whether the attribute identifier and the status data meet a preset trigger condition through the trigger tree.
  • the trigger tree refers to a tree structure that can match strings. That is, the strings that meet the preset trigger conditions can be stored in the trigger tree first, and then the attribute identifier and status data in the attribute status data are input into the trigger tree for matching. If the trigger tree contains a string that matches the attribute identifier and status data in the attribute status data, then the trigger tree is determined to be The attribute identification and status data meet the preset trigger conditions.
  • S103 Acquire multiple consumer threads of a preset message queue, and acquire, through the consumer threads according to the attribute status data, a target preset scene associated with the first IoT device and a current device shadow of a second IoT device corresponding to the target preset scene.
  • the consumer thread refers to a collection of programs that process attribute status data.
  • the device shadow may refer to a document used to store the status of a device, so that the status of the device can be known from the device shadow regardless of whether the device is online or not, thereby achieving decoupling of the device status from the device.
  • the current device shadow may refer to a document including the current state of the second IoT device.
  • the second IoT device may refer to an IoT device controlled in a target preset scene.
  • the target preset scene is a home scene
  • the first IoT device may be a time sensor
  • the second IoT device may be an air conditioner, a lamp, a water heater, etc.
  • the target preset scenes associated with the first IoT device may include multiple ones, and each target preset scene may be associated with multiple second IoT devices.
  • the server can determine the first IoT device corresponding to the device identifier in the attribute state data through the consumer thread, and then obtain the target preset scene associated with the first IoT device and the current device shadow of the second IoT device corresponding to the target preset scene.
  • the first IoT device is an infrared sensor
  • the device identifier of the first IoT device is d1
  • the device identifier in the attribute status data is d1
  • the target preset scene associated with the first IoT device is s1
  • the second IoT device corresponding to the target preset scene is an air conditioner and the device identifier of the air conditioner is d2.
  • the server can first determine the infrared sensor corresponding to d1, and then determine s1 corresponding to d1, and then determine d2 corresponding to s1, and finally, the server obtains the current device shadow of d2.
  • the preset device shadow refers to a document including the target state of the second IoT device.
  • the current device shadow matches the preset device shadow corresponding to the second IoT device in the target preset scenario. It can be understood that the state in the current device shadow matches the state in the preset device shadow.
  • the target preset scene is going home
  • the second IoT devices are lights, water heaters and air conditioners.
  • the lights, water heaters and air conditioners are all in the off state in the preset device shadows
  • the action execution instruction for the lights is to turn on
  • the action execution instruction for the water heater is to turn on and adjust the temperature to 42°
  • the action execution instruction for the air conditioner is to turn on and adjust the temperature to 23°.
  • the "turn on” action execution instruction for the lights is generated according to the target preset scene
  • the "turn on and adjust the temperature to 42°” action execution instruction for the water heater is generated according to the target preset scene
  • the "turn on and adjust the temperature to 23°” action execution instruction for the air conditioner is generated according to the target preset scene.
  • multiple consumer threads are used to determine whether to trigger the target preset scenario, thereby improving the concurrency performance of the server, and the attribute status data is first stored in the preset message queue, and then the attribute status data is consumed from the preset message queue by multiple consumer threads, so that when the amount of attribute status data is large, consumer threads will not be created indefinitely, thereby avoiding server crashes, and realizing peak shaving and valley filling of status attribute data through the preset message queue, thereby improving the concurrency performance of the server.
  • the server After receiving the action execution instruction, the server sends the action execution instruction to the second IoT device through the consumer thread, and the second IoT device then executes the operation corresponding to the action execution instruction.
  • the attribute status data reported by multiple first IoT devices is obtained; if If the property status data meets the preset trigger condition, the property status data is sent to the preset message queue; multiple consumer threads of the preset message queue are obtained, and the target preset scene associated with the first IoT device and the current device shadow of the second IoT device corresponding to the target preset scene are obtained through the consumer thread according to the property status data; if the current device shadow matches the preset device shadow corresponding to the second IoT device in the target preset scene, an action execution instruction for the second IoT device is generated according to the target preset scene through the consumer thread; the action execution instruction is sent to the second IoT device through the consumer thread to control the second IoT device to execute the operation corresponding to the action execution instruction, so as to realize the judgment of whether to trigger the target preset scene through multiple consumer threads of the preset message queue, speed up the triggering of the target preset scene, and improve the concurrency performance
  • the attribute status data includes a device identifier and an attribute identifier of the first IoT device, and obtaining the attribute status data reported by the plurality of first IoT devices includes:
  • the initial attribute state data of the first Internet of Things device is used as the attribute state data reported by the first Internet of Things device.
  • the attribute identifier refers to a field corresponding to the status data in the attribute status data.
  • the status data is a numerical value
  • the attribute identifier may be the radiation amount.
  • the scene state is the target scene state
  • the first Internet of Things device has a corresponding target preset scene, that is, it means that the first Internet of Things device is a trigger of a preset scene.
  • the first Internet of Things device that does not have a corresponding target preset scene is first filtered out, thereby reducing the amount of calculation in determining whether the attribute state data meets the preset trigger condition, further speeding up the speed of triggering the target preset scene, so as to further improve the concurrency performance of the server.
  • the initial attribute state data of the first IoT device is used as the attribute state data reported by the first IoT device, including:
  • the scene state corresponding to the first IoT device is the target scene state, then selecting the target preset scene corresponding to the first IoT device from the preset scenes;
  • the initial attribute state data of the first Internet of Things device is used as the attribute state data reported by the first Internet of Things device.
  • the acquisition time of the initial attribute status data is not within the effective time of the target preset scenario, even if the attribute status data meets the preset trigger condition, there is no need to execute the target preset scenario. Therefore, in this embodiment, when it is determined that the first Internet of Things device has a corresponding target preset scenario, it is first determined whether the acquisition time of the initial attribute status data is within the effective time of the target preset scenario.
  • the initial attribute status data of the first Internet of Things device is used as the attribute status data reported by the first Internet of Things device, thereby reducing the amount of calculation in determining whether the attribute status data meets the preset trigger condition, further speeding up the speed of triggering the target preset scenario, so as to further improve the concurrency performance of the server.
  • determining the scene state corresponding to the first IoT device according to the device identifier and the attribute identifier in the initial attribute state data includes:
  • the scene state of the first IoT device is determined as the target scene state.
  • the server may concatenate the device identifier and the attribute identifier to obtain a concatenated identifier, and then perform hash mapping on the concatenated identifier to obtain a current mapping value.
  • the server may also perform mapping processing on the device identifier and the attribute identifier in the initial attribute state data to obtain a first current mapping value and an initial attribute value corresponding to the device identifier in the initial attribute state data.
  • the second current mapping value corresponding to the attribute identifier in the property status data is then determined according to the first current mapping value and the second current mapping value.
  • the server After obtaining the current mapping value, the server matches the current mapping value with the mapping value in the array. If there is a mapping value in the array that matches the current mapping value, the scene state of the first IoT device is determined as the target scene state.
  • the current mapping value when the current mapping value is obtained by concatenating the identifier, the current mapping value can be directly matched with the mapping value in the numerical value.
  • the attribute identifier and the device identifier are mapped separately, the first mapping value can be matched with the mapping value in the array, and the second mapping value can be matched with the mapping value in the array.
  • the scene state of the first Internet of Things device is determined as the target scene state.
  • the process of determining the scene state of the first IoT device as the target scene state may be:
  • the difference between the current mapping value and each mapping value in the array is determined, and if the difference satisfies a preset difference condition, the mapping value satisfying the preset difference condition is used as the mapping value matching the current mapping value.
  • the mapping value corresponds to the target value in the array. If there is a mapping value matching the current mapping value in the array, the process of determining the scene state of the first IoT device as the target scene state may also be:
  • the scene state of the first Internet of Things device is determined as the target scene state.
  • the mapping value indicates the position in the array. For example, after mapping the device identifier and the attribute identifier, the mapping value obtained is 13, and the target value is stored at the 13th position in the array. After the server obtains the current mapping value, if the value of the current mapping value at the current position corresponding to the array is the target value, it indicates that the first IoT device has a corresponding target preset scene.
  • the target value can be set according to actual conditions.
  • the target value can be set to 1 or 2, which is not limited in this embodiment.
  • the server can also simultaneously map the device identifier and the attribute identifier through multiple different hash functions to obtain multiple current mapping values corresponding to the device identifier and the attribute identifier, and then when the numerical values at the current position corresponding to each current mapping value are all target values, the scene state of the first Internet of Things device is determined as the target scene state. At this time, the scene state corresponding to the first Internet of Things device can be determined through the Bloom filter.
  • the current mapping value and the mapping value represent the position in the array, and then check whether the value at the position is the target value to determine whether the first Internet of Things device has a corresponding target preset scene, so that the scene status of the first Internet of Things device can be obtained more quickly.
  • the server may obtain the attribute status data of many first IoT devices at the same time, if the server determines whether the attribute status data meets the preset trigger condition one by one, the speed is slow. Therefore, in order to more quickly determine whether the attribute status data meets the preset trigger condition, in other embodiments, if the attribute status data meets the preset trigger condition, the process of sending the attribute status data to the preset message queue can be:
  • the thread pool includes multiple judgment threads
  • multiple judgment threads are used to judge whether the attribute status data meets the preset trigger conditions, thereby speeding up the sending of the attribute status data to the preset message queue so that the target preset scene can be triggered more quickly later, thereby further improving the concurrency performance of the server.
  • the attribute state data also includes a user identifier that triggers the first IoT device, and a judgment thread is used to judge whether the attribute state data meets a preset trigger condition, including:
  • the judgment thread is used to determine whether the attribute status data meets the preset trigger condition.
  • the triggering authority of the user who triggers the first IoT device is verified.
  • a judgment thread is used to judge whether the attribute status data meets the preset triggering condition, thereby ensuring security.
  • an action execution instruction for the second IoT device is generated according to the target preset scenario through the consumer thread, including:
  • an action execution instruction for the second IoT device is generated according to the target preset scenario.
  • Verifying the action permission of the second IoT device may refer to verifying the family identifier corresponding to the second IoT device and the family identifier corresponding to the target preset scene. For example, when the family identifier corresponding to the second IoT device and the family identifier corresponding to the target preset scene are the same, it means that the family to which the second IoT device belongs and the family to which the target preset scene belongs are the same, and the action permission verification of the second IoT device passes.
  • the action permission checks for different types of second IoT devices may be different.
  • the second IoT device is a Wi-Fi device
  • the second IoT device is a light group
  • the action permission check is performed on the second Internet of Things device.
  • the action execution instruction of the second Internet of Things device is generated according to the target preset scenario, thereby improving the correctness of the action execution instruction.
  • the method before the current device shadow matches the preset device shadow corresponding to the second IoT device in the target preset scenario, the method further includes:
  • the matching result is the first result, it is determined that the current device shadow matches the preset device shadow corresponding to the second IoT device in the target preset scenario.
  • a second IoT device may correspond to multiple target preset scenes
  • the corresponding preset device shadows in each target preset scene may be the same or different. Therefore, all preset device shadows corresponding to the target preset scenes containing the same preset device shadows can be placed in the same shadow set, and then a target shadow set containing a target preset device shadow that matches the current device shadow of the target second IoT device can be filtered out from the shadow set, so that the matching result of the second IoT device can be determined more quickly later based on the target shadow set.
  • the target second IoT device is IoT device A
  • the preset device shadow corresponding to IoT device A in the target preset scene c1 is 1
  • the preset device shadow corresponding to IoT device A in the target preset scene c2 is also 1
  • the preset device shadow corresponding to IoT device A in the target preset scene c3 is 2.
  • the preset device shadow of the target preset scene c1 and the preset device shadow of the target preset scene c2 can be placed in the shadow set g1
  • the preset device shadow of the target preset scene c3 can be placed in the shadow set g2.
  • the current device shadow of IoT device A is 1, and the shadow set g1 is used as the target shadow set.
  • the shadow set may include multiple preset device shadows of the second IoT device, for example, The shadow set includes not only the preset device shadow of the target second IoT device, but also the preset device shadows of the initial second IoT devices except the target second IoT device.
  • the shadow set may also include only a preset device shadow of the second IoT device.
  • the shadow set may be understood as a node in a matching tree, that is, each shadow set is first used as a node to construct a matching tree.
  • the matching result of the second IoT device is determined according to the target shadow set, including:
  • the current device shadow of the initial second Internet of Things device in the second Internet of Things device is matched with the preset device shadow in the subordinate shadow set to obtain a matching result of the second Internet of Things device.
  • the current device shadow of each initial second IoT device is matched with the subordinate shadow set corresponding to the initial second IoT device until the current device shadow of each initial second IoT device is matched.
  • the subordinate shadow set can be understood as a child node of the target shadow set.
  • the second IoT device includes IoT device A, IoT device B, and IoT device C.
  • IoT device A is the target second IoT device
  • IoT device B and IoT device C are the initial second IoT devices
  • the current device shadow of IoT device A is 1
  • the current device shadow of IoT device B is 1
  • the current device shadow of IoT device C is 0.
  • the target shadow set corresponds to node n1, and node n1 indicates that the preset device shadow is 1.
  • the subordinate shadow set corresponding to the target shadow set can be node n2 or node n4.
  • Node n2 indicates that the preset device shadow is 1
  • node n3 indicates that the preset device shadow is 0
  • node n4 indicates that the preset device shadow is 0
  • node n5 indicates that the preset device shadow is 1.
  • the shadow set that matches the current device shadow of IoT device B is node n2. Since there is also IoT device C, IoT device C is matched with the subordinate shadow set node n3 of node n2. If node n3 is the end node, the matching result of the second IoT device is determined to be the first result.
  • a matching tree is constructed with each preset device shadow as a node, and the same preset device shadow for the same second IoT device in different target preset scenarios is used as the same node in the matching tree. Then, the current device shadow is input into the matching tree for traversal, thereby reducing the traversed nodes and improving the matching speed.
  • the device control method provided in the embodiment of the present application is further described below with reference to FIG. 3 , FIG. 4 and FIG. 5 .
  • the first IoT device sends the initial attribute status data to the access gateway of the server.
  • the access gateway converts the initial attribute status data into an MQ message according to the MQTT protocol and sends the MQ message to the message queue kafka.
  • the server obtains the MQ message from the message queue kafka, and determines whether the first IoT device has a corresponding target preset scenario through a Bloom filter according to the device identifier and attribute identifier in the MQ message. If there is no corresponding target preset scenario, the interceptor is triggered to intercept the MQ message. If there is a corresponding target preset scenario, the acquisition time corresponding to the initial attribute status data is obtained. If the effective time of the target preset scenario does not match the acquisition time, the target preset scenario is removed. If the effective time of the target preset scenario matches the acquisition time, the MQ message is used as the attribute status data.
  • the server creates a thread pool based on the attribute status data.
  • the thread pool includes multiple judgment threads.
  • the judgment thread verifies the triggering authority of the user identifier in the attribute status data. If the verification of the triggering authority passes, the judgment thread determines whether the attribute status data meets the preset triggering condition. If the attribute status data meets the preset triggering condition, the attribute status data is sent to the preset message queue.
  • the server consumes the attribute status data in the preset message queue through multiple consumer threads. As shown in Figure 4, the server obtains the target preset scene associated with the first IoT device and the current device shadow of the second IoT device corresponding to the target preset scene through the consumer thread according to the attribute status data. The current device shadow is input into the matching tree for traversal. If the traversal result is the first result, the consumer thread is used to determine whether the action execution instruction corresponding to the target preset scene has been executed. If the execution is completed, the action execution interceptor is started through the consumer thread, and the action execution interceptor intercepts the action execution instruction of the target preset scene.
  • the action permission check is started through the consumer thread
  • the device performs action permission verification on the second IoT device through the action permission verifier. If the verification of the second IoT device passes, the delayed executor in the consumer thread determines whether the target preset scene is a delayed execution scene. If it is a delayed execution scene, a delayed task is created to execute the target preset scene when the delay time is reached.
  • the offline verifier in the consumer thread is used to determine whether the second IoT device is offline. If the second IoT device is online, the action executor in the consumer thread is used to generate an action execution instruction according to the target preset scenario.
  • the action execution instruction is converted into a control instruction through the action executor in the consumer thread according to the MQTT protocol, and the control instruction is sent to the control server.
  • the control server sends the control instruction to the gateway corresponding to the second IoT device, and the gateway corresponding to the second IoT device sends the control instruction to the second IoT device.
  • the initial attribute status data of the target preset scenes that do not have corresponding target preset scenes and are not within the effective time are synchronously intercepted to obtain the attribute status data, thereby reducing the amount of attribute status data and speeding up the judgment of whether the attribute status data meets the preset trigger conditions, thereby improving the concurrency performance of the server, for example, as shown in Figure 5.
  • the attribute status data is first stored in the preset message queue, and then consumed from the preset message queue by multiple consumer threads.
  • consumer threads will not be created indefinitely, thereby achieving peak shaving and valley filling, avoiding server crashes, and further improving the concurrent performance of the server, for example, as shown in Figure 5.
  • the execution time of the second IoT device may be as shown in Table 1:
  • the execution time of the second IoT devices may be as shown in Table 2:
  • the embodiment of the present application also provides a device based on the above device control method.
  • the meanings of the terms are the same as those in the above device control method, and the specific implementation details can refer to the description in the method embodiment.
  • the device control device may include:
  • the data acquisition module 601 is used to acquire attribute status data reported by multiple first IoT devices.
  • the data sending module 602 is used to send the attribute status data to a preset message queue if the attribute status data meets a preset trigger condition.
  • the thread acquisition module 603 is used to acquire multiple consumer threads of the preset message queue, and acquire the target preset scene associated with the first IoT device and the current device shadow of the second IoT device corresponding to the target preset scene through the consumer threads according to the attribute state data.
  • the instruction generation module 604 is used to generate an action execution instruction for the second IoT device according to the target preset scenario through the consumer thread if the current device shadow matches the preset device shadow corresponding to the second IoT device in the target preset scenario.
  • the instruction sending module 605 is used to send the action execution instruction to the second IoT device through the consumer thread to control the second IoT device to perform the operation corresponding to the action execution instruction.
  • the instruction generation module 604 is specifically used to execute:
  • an action execution instruction for the second IoT device is generated according to the target preset scenario.
  • the equipment control device further includes:
  • Shadow matching module used to perform:
  • the matching result is the first result, it is determined that the current device shadow matches the preset device shadow corresponding to the second IoT device in the target preset scenario.
  • the shadow matching module is specifically used to perform:
  • the current device shadow of the initial second Internet of Things device in the second Internet of Things device is matched with the preset device shadow in the subordinate shadow set to obtain a matching result of the second Internet of Things device.
  • the attribute status data includes a device identifier and an attribute identifier of the first IoT device.
  • the data acquisition module 601 is specifically configured to execute:
  • the initial attribute state data of the first Internet of Things device is used as the attribute state data reported by the first Internet of Things device.
  • the data acquisition module 601 is specifically used to execute:
  • the scene state corresponding to the first IoT device is the target scene state, then selecting the target preset scene corresponding to the first IoT device from the preset scenes;
  • the initial attribute state data of the first Internet of Things device is used as the attribute state data reported by the first Internet of Things device.
  • the data acquisition module 601 is specifically used to execute:
  • the scene state of the first IoT device is determined as the target scene state.
  • the data acquisition module 601 is specifically used to execute:
  • the scene state of the first Internet of Things device is determined as the target scene state.
  • the data acquisition module 601 is specifically used to execute:
  • a current mapping value is determined according to the first current mapping value and the second current mapping value.
  • the equipment control device also includes:
  • the thread pool includes multiple judgment threads
  • the attribute status data also includes a user identifier that triggers the first IoT device.
  • the data judgment module is specifically used to execute:
  • the judgment thread is used to determine whether the attribute status data meets the preset trigger condition.
  • the above modules can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities.
  • the specific implementation methods and corresponding beneficial effects of the above modules can be found in the previous method embodiments, which will not be repeated here.
  • the embodiment of the present application further provides an electronic device, which may be a server or a terminal, etc.
  • an electronic device which may be a server or a terminal, etc.
  • FIG. 7 it shows a schematic diagram of the structure of the electronic device involved in the embodiment of the present application. Specifically:
  • the electronic device may include components such as a processor 701 with one or more processing cores, a memory 702 with one or more computer-readable storage media, a power supply 703, and an input unit 704.
  • a processor 701 with one or more processing cores
  • a memory 702 with one or more computer-readable storage media
  • a power supply 703 with one or more computer-readable storage media
  • FIG. 7 does not limit the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. Among them:
  • the processor 701 is the control center of the electronic device, which uses various interfaces and lines to connect various parts of the entire electronic device, and executes various functions of the electronic device and processes data by running or executing computer programs and/or modules stored in the memory 702, and calling data stored in the memory 702.
  • the processor 701 may include one or more processing cores; preferably, the processor 701 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 701.
  • the memory 702 can be used to store computer programs and modules.
  • the processor 701 executes various functional applications and data processing by running the computer programs and modules stored in the memory 702.
  • the memory 702 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 (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc.
  • the memory 702 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 702 may also include a memory controller to provide the processor 701 with access to the memory 702.
  • the electronic device also includes a power supply 703 for supplying power to various components.
  • the power supply 703 can be logically connected to the processor 701 through a power management system, so that the power management system can manage charging, discharging, power consumption and other functions.
  • the power supply 703 can also include one or more DC or AC power supplies, a recharging system, a power failure detection circuit, Any component such as a power converter or inverter, power status indicator, etc.
  • the electronic device may further include an input unit 704, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
  • an input unit 704 which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
  • the electronic device may further include a display unit, etc., which will not be described in detail herein.
  • the processor 701 in the electronic device will load the executable files corresponding to the processes of one or more computer programs into the memory 702 according to the following instructions, and the processor 701 will run the computer programs stored in the memory 702, thereby realizing various functions, such as:
  • the attribute status data is sent to the preset message queue
  • an action execution instruction for the second IoT device is generated according to the target preset scenario through the consumer thread;
  • an embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored, and the computer program can be loaded by a processor to execute the steps in any device control method provided in the embodiment of the present application.
  • the computer program can execute the following steps:
  • the attribute status data is sent to the preset message queue
  • an action execution instruction for the second IoT device is generated according to the target preset scenario through the consumer thread;
  • the action execution instruction is sent to the second IoT device through the consumer thread to control the second IoT device to perform the operation corresponding to the action execution instruction.
  • the computer readable storage medium may include: read-only memory (ROM), random access memory (RAM), disk or CD, etc.
  • the computer program stored in the computer-readable storage medium can execute the steps in any device control method provided in the embodiments of the present application, the beneficial effects that can be achieved by any device control method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
  • a computer program product or a computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium.
  • a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned device control method.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computing Systems (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Informatics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Selective Calling Equipment (AREA)
  • Telephonic Communication Services (AREA)

Abstract

本申请公开了一种设备控制方法、装置、电子设备及计算机存储介质;在本申请中,先将属性状态数据存储至预设消息队列,然后再通过多个消费者线程从预设消息队列中消费属性状态数据,使得当属性状态数据的数量较大时,不会无限制地创建消费者线程,避免服务器崩溃,实现通过预设消息队列对状态属性数据进行削峰填谷,提高服务器的并发性能。

Description

设备控制方法、装置、电子设备及计算机存储介质
本申请要求申请日为2022年12月13日、申请号为202211603348.0、发明名称为“设备控制方法、装置、电子设备及计算机存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及数据处理技术领域,具体涉及一种设备控制方法、装置、电子设备及计算机存储介质。
背景技术
随着科学技术的发展,物联网设备越来越受用户的欢迎,同一个用户控制的物联网设备越来越多。
为了方便用户对物联网设备进行控制,会将各个物联网设备与场景进行关联,然后服务器根据物联网设备的状态数据判断是否触发场景,从而判断是否触发与该场景关联的物联网设备。然而,由于获取到的状态数据较多,导致判断一个场景是否被触发的时间较长,服务器的并发性能较低。
技术问题
获取到的状态数据较多,导致判断一个场景是否被触发的时间较长,服务器的并发性能较低。
技术解决方案
本申请实施例提供一种设备控制方法,包括:
获取多个第一物联网设备上报的属性状态数据;
若上述属性状态数据满足预设触发条件,则将上述属性状态数据发送至预设消息队列中;
获取上述预设消息队列的多个消费者线程,并通过上述消费者线程根据上述属性状态数据,获取与上述第一物联网设备关联的目标预设场景以及上述目标预设场景对应的第二物联网设备的当前设备影子;
若上述当前设备影子与上述第二物联网设备在上述目标预设场景中对应的预设设备影子匹配,则通过上述消费者线程,根据上述目标预设场景生成上述第二物联网设备的动作执行指令;
通过上述消费者线程,将上述动作执行指令发送至上述第二物联网设备,以控制上述第二物联网设备执行上述动作执行指令对应的操作。
相应地,本申请实施例提供一种设备控制装置,包括:
数据获取模块,用于获取多个第一物联网设备上报的属性状态数据;
数据发送模块,用于若上述属性状态数据满足预设触发条件,则将上述属性状态数据发送至预设消息队列中;
线程获取模块,用于获取上述预设消息队列的多个消费者线程,并通过上述消费者线程根据上述属性状态数据,获取与上述第一物联网设备关联的目标预设场景以及上述目标预设场景对应的第二物联网设备的当前设备影子;
指令生成模块,用于若上述当前设备影子与上述第二物联网设备在上述目标预设场景中对应的预设设备影子匹配,则通过上述消费者线程,根据上述目标预设场景生成上述第二物联网设备的动作执行指令;
指令发送模块,用于通过上述消费者线程,将上述动作执行指令发送至上述第二物联网 设备,以控制上述第二物联网设备执行上述动作执行指令对应的操作。
此外,本申请实施例还提供一种电子设备,包括处理器和存储器,上述存储器存储有计算机程序,上述处理器用于运行上述存储器内的计算机程序实现本申请实施例提供的设备控制方法。
此外,本申请实施例还提供一种计算机可读存储介质,上述计算机可读存储介质存储有计算机程序,上述计算机程序适于处理器进行加载,以执行本申请实施例所提供的任一种设备控制方法。
此外,本申请实施例还提供一种计算机程序产品,包括计算机程序,所述计算机程序被处理器执行时实现本申请实施例所提供的任一种设备控制方法。
有益效果
在本申请实施例中,获取多个第一物联网设备上报的属性状态数据;若属性状态数据满足预设触发条件,则将属性状态数据发送至预设消息队列中;获取预设消息队列的多个消费者线程,并通过消费者线程根据属性状态数据,获取与第一物联网设备关联的目标预设场景以及目标预设场景对应的第二物联网设备的当前设备影子;若当前设备影子与第二物联网设备在目标预设场景中对应的预设设备影子匹配,则通过消费者线程,根据目标预设场景生成第二物联网设备的动作执行指令;通过消费者线程,将动作执行指令发送至第二物联网设备,以控制第二物联网设备执行动作执行指令对应的操作,实现通过预设消息队列的多个消费线程判断是否触发目标预设场景,加快触发目标预设场景的速度,提高服务器的并发性能。
附图说明
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是本申请实施例提供的设备控制方法的流程示意图;
图2是本申请实施例提供的影子集合的示意图;
图3是本申请实施例提供的另一种设备控制方法的示意图;
图4是本申请实施例提供的另一种设备控制方法的示意图;
图5是本申请实施例提供的另一种设备控制方法的示意图;
图6是本申请实施例提供的设备控制装置的结构示意图;
图7是本申请实施例提供的电子设备的结构示意图。
本发明的实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
本申请实施例提供一种设备控制方法、装置、电子设备及计算机存储介质。该设备控制装置可以集成在电子设备中,该电子设备可以是服务器,也可以是网关等设备。
其中,服务器可以是独立的物理服务器,也可以是多个物理服务器构成的服务器集群或者分布式系统,还可以是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、网络加速服务(Content Delivery Network,CDN)、以及大数据和人工智能平台等基础云计算服务的云服务器。
网关以及服务器可以通过有线或无线通信方式进行直接或间接地连接,本申请在此不做限制。
另外,本申请实施例中的“多个”指两个或两个以上。本申请实施例中的“第一”和“第二”等用于区分描述,而不能理解为暗示相对重要性。
以下分别进行详细说明。需要说明的是,以下实施例的描述顺序不作为对实施例优选顺序的限定。
在本实施例中,将从设备控制装置的角度进行描述,为了方便对本申请的设备控制方法进行说明,以下将以设备控制装置集成在服务器中进行详细说明,即以服务器作为执行主体进行详细说明。
请参阅图1,图1是本申请一实施例提供的设备控制方法的流程示意图。该设备控制方法可以包括:
S101、获取多个第一物联网设备上报的属性状态数据。
第一物联网设备可以为各个预设场景的触发设备,即可以为各个预设场景的触发器,用于判断是否触发预设场景,比如,第一物联网设备可以为各种传感器,或者,第一物联网设备可以包含传感器的终端。
应理解,不同预设场景的第一物联网设备可以相同,也可以不相同。当不同预设场景的第一物联网设备相同且不同预设场景的第一物联网设备满足的预设触发条件也相同时,可以理解为当第一物联网设备的属性状态数据满足预设触发条件时,同时触发不同的预设场景。
属性状态数据指表明第一物联网设备的性质的数据,其中,第一物联网设备的性质可以指第一物联网设备的静态性质,或者也可以指第一物联网设备的动态性质。比如,属性状态数据可以指第一物联网设备的设备标识,设备标识为第一物联网设备的静态性质,又比如,属性状态数据可以指第一物联网设备的状态数据,状态数据为第一物联网设备的动态性质。
状态数据可以指第一物联网设备实时采集的数据,比如,当第一物联网设备为红外传感器时,状态数据可以为红外传感器采集的数据,红外传感器采集的数据可以指示两种状态,一种状态是有人,另外一种状态是没有人。
第一物联网设备可以周期性地采集属性状态数据,然后将属性状态数据周期性地发送至服务器,服务器从而获取到多个第一物联网设备上报的属性状态数据。或者,第一物联网设备也可以在接收到采集指令时,根据采集指令采集属性状态数据,然后将属性状态数据发送至服务器,服务器从而获取到第一物联网设备上报的属性状态数据。
对于服务器获取第一物联网设备上报的属性状态数据的方式,可以根据实际情况进行选择,本实施例在此不做限定。
S102、若属性状态数据满足预设触发条件,则将属性状态数据发送至预设消息队列中。
应理解,可以通过服务器判断属性状态数据是否满足预设触发条件,或者,也可以通过第一物联网设备判断是否满足预设触发条件,如果满足预设触发条件,第一物联网设备再将属性状态数据满足预设触发条件和属性状态数据发送给服务器,服务器再将属性状态数据发送至预设消息队列中。
预设消息队列指存储消息的容器,预设消息队列的类型可以根据实际情况进行选择,比如,预设消息队列可以为MQ消息队列、ActiveMQ消息队列、RabbitMQ消息队列、或者ZeroMQ消息队列等,本实施例在此不做限定。
可选地,服务器可以将属性状态数据中属性标识和状态数据输入至触发器树中,以便通过触发器树判断属性标识和状态数据是否满足预设触发条件。
其中,触发器树指可以匹配字符串的树形结构,也即是,可以先将满足预设触发条件对应的字符串存储在触发器树中,然后属性状态数据中属性标识和状态数据输入至触发器树中进行匹配,如果触发器树存在与属性状态数据中属性标识和状态数据匹配的字符串,则确定 属性标识和状态数据满足预设触发条件。
比如,将(P1:V1)输入至触发器树中,得到true或者false,其中,P1表示属性标识,V1表示状态数据,true表示满足预设触发条件,false表示不满足预设触发条件。
S103、获取预设消息队列的多个消费者线程,并通过消费者线程根据属性状态数据,获取与第一物联网设备关联的目标预设场景以及目标预设场景对应的第二物联网设备的当前设备影子。
消费者线程指处理属性状态数据的程序的集合。设备影子可以指用于存储设备的状态的文档,使得无论设备是否在线,均可以从设备影子中获知设备的状态,实现设备的状态与设备的解耦。
当前设备影子可以指包括第二物联网设备的当前状态的文档。第二物联网设备可以指在目标预设场景下控制的物联网设备。比如,目标预设场景为回家场景,则第一物联网设备可以为时间传感器,第二物联网设备可以为空调、灯以及热水器等。
与第一物联网设备关联的目标预设场景可以包括多个,每个目标预设场景可以关联多个第二物联网设备。
服务器可以通过消费者线程,确定与属性状态数据中设备标识对应的第一物联网设备,然后再获取与第一物联网设备关联的目标预设场景以及目标预设场景对应的第二物联网设备的当前设备影子。
比如,第一物联网设备为红外传感器,且第一物联网设备的设备标识为d1,属性状态数据中设备标识为d1,与第一物联网设备关联的目标预设场景为s1,目标预设场景对应的第二物联网设备为空调且空调的设备标识为d2,服务器可以先确定d1对应的红外传感器,然后再确定d1对应的s1,接着,再确定s1对应的d2,最后,服务器再获取d2的当前设备影子。
S104、若当前设备影子与第二物联网设备在目标预设场景中对应的预设设备影子匹配,则通过消费者线程,根据目标预设场景生成第二物联网设备的动作执行指令。
预设设备影子指包括第二物联网设备的目标状态的文档,当前设备影子与第二物联网设备在目标预设场景中对应的预设设备影子匹配,可以理解为当前设备影子中的状态与预设设备影子中的状态匹配。
比如,目标预设场景为回家,第二物联网设备为灯、热水器以及空调,在目标预设场景中,灯、热水器以及空调在预设设备影子中状态均为关闭状态,灯的动作执行指令为打开,热水器的动作执行指令为打开且温度调节到42°,空调的动作执行指令为打开且把温度调节到23°,则如果灯、热水器以及空调在当前设备影子中的状态也均为关闭状态,则通过消费者线程,根据目标预设场景生成灯的“打开”动作执行指令、根据目标预设场景生成热水器的“打开且温度调节到42°”动作执行指令以及根据目标预设场景生成空调的“打开且温度调节到23°”动作执行指令。
在本实施例中,通过多个消费者线程判断是否触发目标预设场景,从而提高服务器的并发性能,并且,先将属性状态数据存储至预设消息队列,然后再通过多个消费者线程从预设消息队列中消费属性状态数据,使得当属性状态数据的数量较大时,不会无限制地创建消费者线程,避免服务器崩溃,实现通过预设消息队列对状态属性数据进行削峰填谷,提高服务器的并发性能。
S105、通过消费者线程,将动作执行指令发送至第二物联网设备,以控制第二物联网设备执行动作执行指令对应的操作。
服务器在得到动作执行指令之后,再通过消费者线程,将动作执行指令发送至第二物联网设备,第二物联网设备再执行动作执行指令对应的操作。
由以上可知,在本申请实施例中,获取多个第一物联网设备上报的属性状态数据;若属 性状态数据满足预设触发条件,则将属性状态数据发送至预设消息队列中;获取预设消息队列的多个消费者线程,并通过消费者线程根据属性状态数据,获取与第一物联网设备关联的目标预设场景以及目标预设场景对应的第二物联网设备的当前设备影子;若当前设备影子与第二物联网设备在目标预设场景中对应的预设设备影子匹配,则通过消费者线程,根据目标预设场景生成第二物联网设备的动作执行指令;通过消费者线程,将动作执行指令发送至第二物联网设备,以控制第二物联网设备执行动作执行指令对应的操作,实现通过预设消息队列的多个消费线程判断是否触发目标预设场景,加快触发目标预设场景的速度,提高服务器的并发性能。
在一些实施例中,属性状态数据包括第一物联网设备的设备标识和属性标识,获取多个第一物联网设备上报的属性状态数据,包括:
获取多个第一物联网设备上报的初始属性状态数据;
根据初始属性状态数据中设备标识和属性标识,确定第一物联网设备对应的场景状态;
若第一物联网设备对应的场景状态为目标场景状态,则将第一物联网设备的初始属性状态数据作为第一物联网设备上报的属性状态数据。
属性标识指属性状态数据中状态数据对应的字段,比如,当第一物联网设备为红外传感器时,状态数据为数值,属性标识可以为辐射量。
当场景状态为目标场景状态时,意味着第一物联网设备存在对应的目标预设场景,也即是,意味着第一物联网设备为某一个预设场景的触发器,在本实施例中,在判断属性状态数据是否满足预设触发条件之前,先过滤掉没有存在对应的目标预设场景的第一物联网设备,从而减少在判断属性状态数据是否满足预设触发条件的计算量,进一步加快触发目标预设场景的速度,以便进一步提高服务器的并发性能。
在另一些实施例中,若第一物联网设备对应的场景状态为目标场景状态,则将第一物联网设备的初始属性状态数据作为第一物联网设备上报的属性状态数据,包括:
若第一物联网设备对应的场景状态为目标场景状态,则从预设场景中筛选出第一物联网设备对应的目标预设场景;
获取初始属性状态数据对应的获取时间;
若目标预设场景的生效时间与获取时间匹配,则将第一物联网设备的初始属性状态数据作为第一物联网设备上报的属性状态数据。
当第一物联网设备存在对应的目标预设场景时,如果初始属性状态数据的获取时间不在目标预设场景的生效时间内,即使属性状态数据满足预设触发条件,也无需执行目标预设场景,因此,在本实施例中,当判断第一物联网设备存在对应的目标预设场景时,先判断初始属性状态数据的获取时间是否在目标预设场景的生效时间内,如果在目标预设场景的生效时间内,再将第一物联网设备的初始属性状态数据作为第一物联网设备上报的属性状态数据,从而减少在判断属性状态数据是否满足预设触发条件的计算量,进一步加快触发目标预设场景的速度,以便进一步提高服务器的并发性能。
在另一些实施例中,根据初始属性状态数据中设备标识和属性标识,确定第一物联网设备对应的场景状态,包括:
获取预设场景对应的数组,数组包括预设场景对应的设备标识和属性标识的映射值;
对初始属性状态数据中设备标识和属性标识进行映射处理,得到当前映射值;
若数组中存在与当前映射值匹配的映射值,则将第一物联网设备的场景状态确定为目标场景状态。
其中,服务器可以将设备标识和属性标识进行串接,得到串接后标识,然后对串接后标识进行哈希映射,得到当前映射值,或者,服务器也对初始属性状态数据中设备标识和属性标识分别进行映射处理,得到初始属性状态数据中设备标识对应的第一当前映射值和初始属 性状态数据中属性标识对应的第二当前映射值,然后根据第一当前映射值和第二当前映射值,确定当前映射值。
服务器在得到当前映射值之后,再将当前映射值与数组中映射值进行匹配,如果数组中存在与当前映射值匹配的映射值,则将第一物联网设备的场景状态确定为目标场景状态。
其中,当通过串接后标识得到当前映射值时,可以直接将当前映射值与数值中映射值进行匹配,当对属性标识和设备标识进行分别映射时,可以将第一映射值与数组中映射值进行匹配,将第二映射值与数组中映射值进行匹配,此时,当数组中存在与第一映射值匹配的映射值且存在与第二映射值匹配的映射值,将第一物联网设备的场景状态确定为目标场景状态。
在一些实施例中,若数组中存在与当前映射值匹配的映射值,则将第一物联网设备的场景状态确定为目标场景状态的过程可以为:
确定当前映射值与数组中各个映射值之间的差值,如果差值满足预设差值条件,则将满足预设差值条件的映射值作为与当前映射值匹配的映射值。
为了更加快速地确定是否存在与当前映射值匹配的映射值,在另一些实施例中,映射值在数组中对应目标值,若数组中存在与当前映射值匹配的映射值,则将第一物联网设备的场景状态确定为目标场景状态的过程也可以为:
确定数组中与当前映射值匹配的当前位置;
若当前位置上的数值为目标值,则将第一物联网设备的场景状态确定为目标场景状态。
在本实施例中,映射值表示数组中的位置,比如,对设备标识和属性标识进行映射之后,得到的映射值为13,则在数组中第13个位置上存储目标值。服务器在得到当前映射值之后,如果当前映射值在数组中对应的当前位置上数值为目标值,则表示第一物联网设备存在对应的目标预设场景。
目标值可以根据实际情况进行设置,比如,目标值可以设置为1或2,本实施例在此不做限定。
应理解,服务器也可以通过多个不同的哈希函数同时对设备标识和属性标识进行映射,得到设备标识和属性标识对应的多个当前映射值,然后当每个当前映射值对应的当前位置上的数值均为目标值时,将第一物联网设备的场景状态确定为目标场景状态,此时,可以通过布隆过滤器确定第一物联网设备对应的场景状态。
在本实施例中,当前映射值和映射值表示数组中的位置,然后查看位置上的数值是否为目标值从而确定第一物联网设备是否存在对应的目标预设场景,从而使得可以更加快速地得到第一物联网设备的场景状态。
由于服务器在同一时间可能获取到很多个第一物联网设备的属性状态数据,如果服务器对属性状态数据一个个地进行是否满足预设触发条件的判断,速度较慢,因此,为了使得可以更加快速地确定属性状态数据是否满足预设触发条件,在另一些实施例中,若属性状态数据满足预设触发条件,则将属性状态数据发送至预设消息队列中的过程可以为:
根据属性状态数据创建线程池,线程池包括多个判断线程;
通过判断线程,判断属性状态数据是否满足预设触发条件。
在本实施例中,通过多个判断线程对属性状态数据是否满足预设触发条件进行判断,加快将属性状态数据发送至预设消息队列的速度,以便后续可以更加快速地触发目标预设场景,从而进一步提高服务器的并发性能。
在另一些实施例中,属性状态数据还包括触发第一物联网设备的用户标识,通过判断线程,对属性状态数据是否满足预设触发条件进行判断,包括:
通过判断线程,对用户标识的触发权限进行校验;
若触发权限的校验通过,则通过判断线程,对属性状态数据是否满足预设触发条件进行判断。
在本实施例中,对触发第一物联网设备的用户的触发权限进行校验,当具备第一物联网设备的触发权限的用户对第一物联网设备进行触发时,才通过判断线程,对属性状态数据是否满足预设触发条件进行判断,从而保证安全性。
在另一些实施例中,若当前设备影子与第二物联网设备在目标预设场景中对应的预设设备影子匹配,则通过消费者线程,根据目标预设场景生成第二物联网设备的动作执行指令,包括:
若当前设备影子与第二物联网设备在目标预设场景中对应的预设设备影子匹配,则对第二物联网设备进行动作权限校验;
若对第二物联网设备的动作权限校验通过,则根据目标预设场景生成第二物联网设备的动作执行指令。
对第二物联网设备进行动作权限校验可以指对第二物联网设备对应的家庭标识和目标预设场景对应的家庭标识进行校验。比如,当第二物联网设备对应的家庭标识和目标预设场景对应的家庭标识相同时,意味着第二物联网设备所属的家庭和目标预设场景所属的家庭相同,则对第二物联网设备的动作权限校验通过。
应理解,不同类型的第二物联网设备的动作权限校验可以不相同。比如,当第二物联网设备为Wi-Fi设备时,可以判断第二物联网设备所属的家庭是否和目标预设场景所属的家庭相同,如果相同,则对第二物联网设备的动作权限校验通过。又比如,当第二物联网设备为灯组时,可以确定灯组所属的用户对应的家庭标识是否和目标预设场景所属的家庭标识相同,如果相同,则对第二物联网设备的动作权限校验通过。
在本实施例中,在当前设备影子与第二物联网设备在目标预设场景中对应的预设设备影子匹配时,对第二物联网设备进行动作权限校验,当对第二物联网设备的动作权限校验通过时,再根据目标预设场景生成第二物联网设备的动作执行指令,从而提高动作执行指令的正确性。
在另一些实施例中,在若当前设备影子与第二物联网设备在目标预设场景中对应的预设设备影子匹配之前,还包括:
获取根据第二物联网设备在目标预设场景中对应的预设设备影子生成的影子集合;
从第二物联网设备中筛选出目标第二物联网设备,并从影子集合中筛选出包含目标预设设备影子的目标影子集合,目标预设设备影子为与目标第二物联网设备的当前设备影子匹配的预设设备影子;
根据目标影子集合,确定第二物联网设备的匹配结果;
若匹配结果为第一结果,则确定当前设备影子与第二物联网设备在目标预设场景中对应的预设设备影子匹配。
由于一个第二物联网设备可能对应多个目标预设场景,在每个目标预设场景中对应的预设设备影子可能相同,也可能不相同,因此,可以将包含相同预设设备影子的目标预设场景对应的所有预设设备影子放在同一个影子集合中,然后从影子集合中筛选出包含与目标第二物联网设备的当前设备影子匹配的目标预设设备影子的目标影子集合,使得后续可以根据目标影子集合,更加快速地确定第二物联网设备的匹配结果。
比如,目标第二物联网设备为物联网设备A,物联网设备A在目标预设场景c1中对应的预设设备影子为1,物联网设备A在目标预设场景c2中对应的预设设备影子也为1,物联网设备A在目标预设场景c3中对应的预设设备影子为2,则可以将目标预设场景c1的预设设备影子和目标预设场景c2的预设设备影子放在影子集合g1中,将目标预设场景c3的预设设备影子放在影子集合g2中,物联网设备A的当前设备影子为1,则将影子集合g1作为目标影子集合。
需要说明的是,影子集合中可以包括多个第二物联网设备的预设设备影子,比如,目标 影子集合中不但包括目标第二物联网设备的预设设备影子,而且包括除了目标第二物联网设备之外的初始第二物联网设备的预设设备影子。
或者,影子集合也可以只包括一个第二物联网设备的预设设备影子,此时,影子集合可以理解为匹配树中的节点,即先以各个影子集合作为节点,构建匹配树,此时,根据目标影子集合,确定第二物联网设备的匹配结果,包括:
从影子集合中查找目标影子集合对应的下级影子集合;
将第二物联网设备中初始第二物联网设备的当前设备影子与下级影子集合中预设设备影子进行匹配,得到第二物联网设备的匹配结果。
如果初始第二物联网设备存在多个,则将每个初始第二物联网设备的当前设备影子与初始第二物联网设备对应的下级影子集合进行匹配,直至每个初始第二物联网设备的当前设备影子均匹配完成。
下级影子集合可以理解为目标影子集合的子节点。比如,如图2所示,第二物联网设备包括物联网设备A、物联网设备B以及物联网设备C,物联网设备A为目标第二物联网设备,物联网设备B以及物联网设备C为初始第二物联网设备,物联网设备A的当前设备影子为1,物联网设备B的当前设备影子为1,物联网设备C的当前设备影子为0。
目标影子集合对应节点n1,节点n1表示预设设备影子为1,目标影子集合对应的下级影子集合可以为节点n2或节点n4,节点n2表示预设设备影子为1,节点n3表示预设设备影子为0,节点n4表示预设设备影子为0,节点n5表示预设设备影子为1。
由于物联网设备B的当前设备影子为1,因此,物联网设备B的当前设备影子匹配的影子集合为节点n2。因为还存在物联网设备C,则将物联网设备C与节点n2的下级影子集合节点n3进行匹配。如果节点n3为结束节点,则确定第二物联网设备的匹配结果为第一结果。
在本实施例中,以各个预设设备影子作为节点构建匹配树,并将不同目标预设场景针对同一个第二物联网设备的相同预设设备影子作为匹配树中同一个节点,然后将当前设备影子输入至匹配树中进行遍历,减少遍历的节点,从而提高匹配的速度。
下面参照图3、图4以及图5,对本申请实施例提供的设备控制方法进行进一步说明。
如图3所示,第一物联网设备将初始属性状态数据发送至服务器的接入网关,接入网关根据MQTT协议将初始属性状态数据转换为MQ消息,并将MQ消息发送至消息队列kafka。
服务器从消息队列kafka中获取MQ消息,并通过布隆过滤器,根据MQ消息中设备标识和属性标识,确定第一物联网设备是否存在对应的目标预设场景,如果不存在对应的目标预设场景,则触发拦截器拦截MQ消息,如果存在对应的目标预设场景,则获取初始属性状态数据对应的获取时间,若目标预设场景的生效时间与获取时间不匹配,则移除目标预设场景,如果目标预设场景的生效时间与获取时间匹配,则将MQ消息作为属性状态数据。
服务器根据属性状态数据创建线程池,线程池包括多个判断线程,通过判断线程,对属性状态数据中用户标识的触发权限进行校验,若触发权限的校验通过,则通过判断线程,对属性状态数据是否满足预设触发条件进行判断。若属性状态数据满足预设触发条件,则将属性状态数据发送至预设消息队列中。
服务器通过多个消费者线程消费预设消息队列中的属性状态数据。如图4所示,服务器通过消费者线程根据属性状态数据,获取与第一物联网设备关联的目标预设场景以及目标预设场景对应的第二物联网设备的当前设备影子。将当前设备影子输入至匹配树中进行遍历,如果遍历结果为第一结果,则通过消费者线程,判断该目标预设场景对应的动作执行指令是否已经执行完成,如果执行完成,则通过消费者线程,启动动作执行拦截器,通过动作执行拦截器对目标预设场景的动作执行指令进行拦截。
如果该目标预设场景对应的动作执行指令未执行,则通过消费者线程启动动作权限校验 器,通过动作权限校验器对第二物联网设备进行动作权限校验,如果对第二物联网设备的校验通过,则通过消费者线程中延时执行器,确定该目标预设场景是否为延时执行场景,如果是延时执行场景,则创建延时任务,以便在到达延时时间时,执行目标预设场景。
如果不是延时执行场景,则通过消费者线程中在离线校验器,确定第二物联网设备是否离线,如果第二物联网设备在线,则通过消费者线程中动作执行器,根据目标预设场景生成动作执行指令。
通过消费者线程中动作执行器,根据MQTT协议,将动作执行指令转换为控制指令,并将控制指令发送至控制服务器。控制服务器将控制指令发送至第二物联网设备对应的网关,第二物联网设备对应的网关将控制指令发送至第二物联网设备。
在本实施例中,通过同步对不存在对应的目标预设场景以及不在生效时间内的目标预设场景的初始属性状态数据进行拦截,得到属性状态数据,从而减少属性状态数据的数量,加快对属性状态数据是否满足预设触发条件的判断速度,从而提高服务器的并发性能,比如,如图5所示。
通过线程池中多个判断线程,异步对属性状态数据是否满足预设触发条件进行判断,从而进一步加快得到属性状态数据是否满足预设触发条件的速度,从而提高服务器的并发性能,比如,如图5所示。
通过预设消息队列中多个消费者线程,判断是否触发目标预设场景,从而提高服务器的并发性能,并且,先将属性状态数据存储至预设消息队列,然后再通过多个消费者线程从预设消息队列中消费属性状态数据,使得当属性状态数据的数量较大时,不会无限制地创建消费者线程,实现削峰填谷,避免服务器崩溃,从而进一步提高服务器的并发性能,比如,如图5所示。
下面对本申请实施例提高的并发性能进行说明。
当一个预设触发条件对应多个预设场景时,第二物联网设备的执行时间可以如表1所示:
表1
从表1可以看出,当一个预设触发条件对应多个预设场景时,执行时间从原来632ms提升到301ms,缩短了52.37%。
当一个预设场景对应多个第二物联网设备时,第二物联网设备的执行时间可以如表2所示:
表2
从表2可以看出,当一个预设场景对应多个第二物联网设备时,执行时间从原来1244ms提升到527ms,缩短了57.64%。
kafka堆积数据可以如表3所示:
表3
从表3可以看出,kafka堆积峰值/平均从原来的394976降到309,CPU Max消耗从原来200.88%降到78.7%,平均内存消耗从原来85.11%降到65.19%。
预设场景的压力测试结果可以如表4所示:
表4
从表4可以看出,在对预设场景的压力测试的结果中,CPU Max消耗从原来97.2%降到57.6%,平均内存消耗从原来92.42%降到65.56%。
为便于更好的实施本申请实施例提供的设备控制方法,本申请实施例还提供一种基于上述设备控制方法的装置。其中名词的含义与上述设备控制方法中相同,具体实现细节可以参考方法实施例中的说明。
例如,如图6所示,该设备控制装置可以包括:
数据获取模块601,用于获取多个第一物联网设备上报的属性状态数据。
数据发送模块602,用于若属性状态数据满足预设触发条件,则将属性状态数据发送至预设消息队列中。
线程获取模块603,用于获取预设消息队列的多个消费者线程,并通过消费者线程根据属性状态数据,获取与第一物联网设备关联的目标预设场景以及目标预设场景对应的第二物联网设备的当前设备影子。
指令生成模块604,用于若当前设备影子与第二物联网设备在目标预设场景中对应的预设设备影子匹配,则通过消费者线程,根据目标预设场景生成第二物联网设备的动作执行指令。
指令发送模块605,用于通过消费者线程,将动作执行指令发送至第二物联网设备,以控制第二物联网设备执行动作执行指令对应的操作。
可选地,指令生成模块604具体用于执行:
若当前设备影子与第二物联网设备在目标预设场景中对应的预设设备影子匹配,则对第二物联网设备进行动作权限校验;
若对第二物联网设备的动作权限校验通过,则根据目标预设场景生成第二物联网设备的动作执行指令。
可选地,该设备控制装置还包括:
影子匹配模块,用于执行:
获取根据第二物联网设备在目标预设场景中对应的预设设备影子生成的影子集合;
从第二物联网设备中筛选出目标第二物联网设备,并从影子集合中筛选出包含目标预设设备影子的目标影子集合,目标预设设备影子为与目标第二物联网设备的当前设备影子匹配的预设设备影子;
根据目标影子集合,确定第二物联网设备的匹配结果;
若匹配结果为第一结果,则确定当前设备影子与第二物联网设备在目标预设场景中对应的预设设备影子匹配。
可选地,影子匹配模块具体用于执行:
从影子集合中查找目标影子集合对应的下级影子集合;
将第二物联网设备中初始第二物联网设备的当前设备影子与下级影子集合中预设设备影子进行匹配,得到第二物联网设备的匹配结果。
可选地,属性状态数据包括第一物联网设备的设备标识和属性标识,相应地,数据获取模块601具体用于执行:
获取多个第一物联网设备上报的初始属性状态数据;
根据初始属性状态数据中设备标识和属性标识,确定第一物联网设备对应的场景状态;
若第一物联网设备对应的场景状态为目标场景状态,则将第一物联网设备的初始属性状态数据作为第一物联网设备上报的属性状态数据。
可选地,数据获取模块601具体用于执行:
若第一物联网设备对应的场景状态为目标场景状态,则从预设场景中筛选出第一物联网设备对应的目标预设场景;
获取初始属性状态数据对应的获取时间;
若目标预设场景的生效时间与获取时间匹配,则将第一物联网设备的初始属性状态数据作为第一物联网设备上报的属性状态数据。
可选地,数据获取模块601具体用于执行:
获取预设场景对应的数组,数组包括预设场景对应的设备标识和属性标识的映射值;
对初始属性状态数据中设备标识和属性标识进行映射处理,得到当前映射值;
若数组中存在与当前映射值匹配的映射值,则将第一物联网设备的场景状态确定为目标场景状态。
可选地,数据获取模块601具体用于执行:
确定数组中与当前映射值匹配的当前位置;
若当前位置上的数值为目标值,则将第一物联网设备的场景状态确定为目标场景状态。
可选地,数据获取模块601具体用于执行:
对初始属性状态数据中设备标识和属性标识分别进行映射处理,得到初始属性状态数据中设备标识对应的第一当前映射值和初始属性状态数据中属性标识对应的第二当前映射值;
根据第一当前映射值和第二当前映射值,确定当前映射值。
可选地该设备控制装置还包括:
数据判断模块,用于执行:
根据属性状态数据创建线程池,线程池包括多个判断线程;
通过判断线程,判断属性状态数据是否满足预设触发条件。
可选地,属性状态数据还包括触发第一物联网设备的用户标识,相应地,数据判断模块具体用于执行:
通过判断线程,对用户标识的触发权限进行校验;
若触发权限的校验通过,则通过判断线程,对属性状态数据是否满足预设触发条件进行判断。
具体实施时,以上各个模块可以作为独立的实体来实现,也可以进行任意组合,作为同一或若干个实体来实现,以上各个模块的具体实施方式以及对应的有益效果可参见前面的方法实施例,在此不再赘述。
本申请实施例还提供一种电子设备,该电子设备可以是服务器或终端等,如图7所示,其示出了本申请实施例所涉及的电子设备的结构示意图,具体来讲:
该电子设备可以包括一个或者一个以上处理核心的处理器701、一个或一个以上计算机可读存储介质的存储器702、电源703和输入单元704等部件。本领域技术人员可以理解,图7中示出的电子设备结构并不构成对电子设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。其中:
处理器701是该电子设备的控制中心,利用各种接口和线路连接整个电子设备的各个部分,通过运行或执行存储在存储器702内的计算机程序和/或模块,以及调用存储在存储器702内的数据,执行电子设备的各种功能和处理数据。可选的,处理器701可包括一个或多个处理核心;优选的,处理器701可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作系统、用户界面和应用程序等,调制解调处理器主要处理无线通信。可以理解的是,上述调制解调处理器也可以不集成到处理器701中。
存储器702可用于存储计算机程序以及模块,处理器701通过运行存储在存储器702的计算机程序以及模块,从而执行各种功能应用以及数据处理。存储器702可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的计算机程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储根据电子设备的使用所创建的数据等。此外,存储器702可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。相应地,存储器702还可以包括存储器控制器,以提供处理器701对存储器702的访问。
电子设备还包括给各个部件供电的电源703,优选的,电源703可以通过电源管理系统与处理器701逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。电源703还可以包括一个或一个以上的直流或交流电源、再充电系统、电源故障检测电路、 电源转换器或者逆变器、电源状态指示器等任意组件。
该电子设备还可包括输入单元704,该输入单元704可用于接收输入的数字或字符信息,以及产生与用户设置以及功能控制有关的键盘、鼠标、操作杆、光学或者轨迹球信号输入。
尽管未示出,电子设备还可以包括显示单元等,在此不再赘述。具体在本实施例中,电子设备中的处理器701会按照如下的指令,将一个或一个以上的计算机程序的进程对应的可执行文件加载到存储器702中,并由处理器701来运行存储在存储器702中的计算机程序,从而实现各种功能,比如:
获取多个第一物联网设备上报的属性状态数据;
若属性状态数据满足预设触发条件,则将属性状态数据发送至预设消息队列中;
获取预设消息队列的多个消费者线程,并通过消费者线程根据属性状态数据,获取与第一物联网设备关联的目标预设场景以及目标预设场景对应的第二物联网设备的当前设备影子;
若当前设备影子与第二物联网设备在目标预设场景中对应的预设设备影子匹配,则通过消费者线程,根据目标预设场景生成第二物联网设备的动作执行指令;
通过消费者线程,将动作执行指令发送至第二物联网设备,以控制第二物联网设备执行动作执行指令对应的操作。
以上各个操作的具体实施方式以及对应的有益效果可参见上文对设备控制方法的详细描述,在此不作赘述。
本领域普通技术人员可以理解,上述实施例的各种方法中的全部或部分步骤可以通过计算机程序来完成,或通过计算机程序控制相关的硬件来完成,该计算机程序可以存储于一计算机可读存储介质中,并由处理器进行加载和执行。
为此,本申请实施例提供一种计算机可读存储介质,其中存储有计算机程序,该计算机程序能够被处理器进行加载,以执行本申请实施例所提供的任一种设备控制方法中的步骤。例如,该计算机程序可以执行如下步骤:
获取多个第一物联网设备上报的属性状态数据;
若属性状态数据满足预设触发条件,则将属性状态数据发送至预设消息队列中;
获取预设消息队列的多个消费者线程,并通过消费者线程根据属性状态数据,获取与第一物联网设备关联的目标预设场景以及目标预设场景对应的第二物联网设备的当前设备影子;
若当前设备影子与第二物联网设备在目标预设场景中对应的预设设备影子匹配,则通过消费者线程,根据目标预设场景生成第二物联网设备的动作执行指令;
通过消费者线程,将动作执行指令发送至第二物联网设备,以控制第二物联网设备执行动作执行指令对应的操作。
以上各个操作的具体实施方式以及对应的有益效果可参见前面的实施例,在此不再赘述。
其中,该计算机可读存储介质可以包括:只读存储器(ROM,Read Only Memory)、随机存取记忆体(RAM,Random Access Memory)、磁盘或光盘等。
由于该计算机可读存储介质中所存储的计算机程序,可以执行本申请实施例所提供的任一种设备控制方法中的步骤,因此,可以实现本申请实施例所提供的任一种设备控制方法所能实现的有益效果,详见前面的实施例,在此不再赘述。
其中,根据本申请的一个方面,提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括计算机指令,该计算机指令存储在计算机可读存储介质中。计算机设备的处理器从计算机可读存储介质读取该计算机指令,处理器执行该计算机指令,使得该计算机设备执行上述设备控制方法。
以上对本申请实施例所提供的一种设备控制方法、装置、电子设备及计算机存储介质进 行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。

Claims (20)

  1. 一种设备控制方法,其中,包括:
    获取多个第一物联网设备上报的属性状态数据;
    若所述属性状态数据满足预设触发条件,则将所述属性状态数据发送至预设消息队列中;
    获取所述预设消息队列的多个消费者线程,并通过所述消费者线程根据所述属性状态数据,获取与所述第一物联网设备关联的目标预设场景以及所述目标预设场景对应的第二物联网设备的当前设备影子;
    若所述当前设备影子与所述第二物联网设备在所述目标预设场景中对应的预设设备影子匹配,则通过所述消费者线程,根据所述目标预设场景生成所述第二物联网设备的动作执行指令;
    通过所述消费者线程,将所述动作执行指令发送至所述第二物联网设备,以控制所述第二物联网设备执行所述动作执行指令对应的操作。
  2. 根据权利要求1所述的设备控制方法,其中,所述若所述当前设备影子与所述第二物联网设备在所述目标预设场景中对应的预设设备影子匹配,则通过所述消费者线程,根据所述目标预设场景生成所述第二物联网设备的动作执行指令,包括:
    若所述当前设备影子与所述第二物联网设备在所述目标预设场景中对应的预设设备影子匹配,则对所述第二物联网设备进行动作权限校验;
    若对所述第二物联网设备的动作权限校验通过,则根据所述目标预设场景生成所述第二物联网设备的动作执行指令。
  3. 根据权利要求1所述的设备控制方法,其中,在所述若所述当前设备影子与所述第二物联网设备在所述目标预设场景中对应的预设设备影子匹配之前,还包括:
    获取根据所述第二物联网设备在目标预设场景中对应的预设设备影子生成的影子集合;
    从所述第二物联网设备中筛选出目标第二物联网设备,并从所述影子集合中筛选出包含目标预设设备影子的目标影子集合,所述目标预设设备影子为与所述目标第二物联网设备的当前设备影子匹配的预设设备影子;
    根据所述目标影子集合,确定所述第二物联网设备的匹配结果;
    若所述匹配结果为第一结果,则确定所述当前设备影子与所述第二物联网设备在所述目标预设场景中对应的预设设备影子匹配。
  4. 根据权利要求3所述的设备控制方法,其中,所述根据所述目标影子集合,确定所述第二物联网设备的匹配结果,包括:
    从所述影子集合中查找所述目标影子集合对应的下级影子集合;
    将所述第二物联网设备中初始第二物联网设备的当前设备影子与下级影子集合中预设设备影子进行匹配,得到第二物联网设备的匹配结果。
  5. 根据权利要求1所述的设备控制方法,其中,所述属性状态数据包括所述第一物联网设备的设备标识和属性标识,所述获取多个第一物联网设备上报的属性状态数据,包括:
    获取多个第一物联网设备上报的初始属性状态数据;
    根据所述初始属性状态数据中设备标识和属性标识,确定所述第一物联网设备对应的场景状态;
    若所述第一物联网设备对应的场景状态为目标场景状态,则将所述第一物联网设备的初始属性状态数据作为所述第一物联网设备上报的属性状态数据。
  6. 根据权利要求5所述的设备控制方法,其中,所述若所述第一物联网设备对应的场景状态为目标场景状态,则将所述第一物联网设备的初始属性状态数据作为所述第一物联网设备上报的属性状态数据,包括:
    若所述第一物联网设备对应的场景状态为目标场景状态,则从预设场景中筛选出所述第一物联网设备对应的目标预设场景;
    获取所述初始属性状态数据对应的获取时间;
    若所述目标预设场景的生效时间与所述获取时间匹配,则将所述第一物联网设备的初始属性状态数据作为所述第一物联网设备上报的属性状态数据。
  7. 根据权利要求5所述的设备控制方法,其中,所述根据所述初始属性状态数据中设备标识和属性标识,确定所述第一物联网设备对应的场景状态,包括:
    获取预设场景对应的数组,所述数组包括所述预设场景对应的设备标识和属性标识的映射值;
    对所述初始属性状态数据中设备标识和属性标识进行映射处理,得到当前映射值;
    若所述数组中存在与所述当前映射值匹配的映射值,则将所述第一物联网设备的场景状态确定为目标场景状态。
  8. 根据权利要求7所述的设备控制方法,其中,所述映射值在所述数组中对应目标值,所述若所述数组中存在与所述当前映射值匹配的映射值,则将所述第一物联网设备的场景状态确定为目标场景状态,包括:
    确定所述数组中与所述当前映射值匹配的当前位置;
    若所述当前位置上的数值为所述目标值,则将所述第一物联网设备的场景状态确定为目标场景状态。
  9. 根据权利要求7所述的设备控制方法,其中,在所述若所述数组中存在与所述当前映射值匹配的映射值,则将所述第一物联网设备的场景状态确定为目标场景状态之前,还包括:
    确定所述当前映射值与所述数组中各个映射值之间的差值;
    将满足预设差值条件的差值对应的映射值,作为与所述当前映射值匹配的映射值,并确定所述数组中存在与所述当前映射值匹配的映射值。
  10. 根据权利要求7所述的设备控制方法,其中,所述对所述初始属性状态数据中设备标识和属性标识进行映射处理,得到当前映射值,包括:
    对所述初始属性状态数据中设备标识和属性标识分别进行映射处理,得到所述初始属性状态数据中设备标识对应的第一当前映射值和所述初始属性状态数据中属性标识对应的第二当前映射值;
    根据所述第一当前映射值和所述第二当前映射值,确定当前映射值。
  11. 根据权利要求7所述的设备控制方法,其中,所述对所述初始属性状态数据中设备标识和属性标识进行映射处理,得到当前映射值,包括:
    将所述初始属性状态数据中设备标识和属性标识进行串接,得到串接后标识;
    对所述串接后标识进行映射处理,得到当前映射值。
  12. 根据权利要求1-11任一项所述的设备控制方法,其中,在所述若所述属性状态数据满足预设触发条件,则将所述属性状态数据发送至预设消息队列中之前,还包括:
    根据所述属性状态数据创建线程池,所述线程池包括多个判断线程;
    通过所述判断线程,判断所述属性状态数据是否满足预设触发条件。
  13. 根据权利要求12所述的设备控制方法,其中,所述属性状态数据还包括触发所述第一物联网设备的用户标识,所述通过所述判断线程,对所述属性状态数据是否满足预设触发条件进行判断,包括:
    通过所述判断线程,对所述用户标识的触发权限进行校验;
    若所述触发权限的校验通过,则通过所述判断线程,对所述属性状态数据是否满足预设触发条件进行判断。
  14. 根据权利要求1所述的设备控制方法,其中,所述属性状态数据包括属性标识和状态数据;
    在所述若所述属性状态数据满足预设触发条件,则将所述属性状态数据发送至预设消息队列中之前,还包括:
    将所述属性标识和状态数据输入至触发器树中进行匹配;
    若所述触发器树中存在与所述属性标识和所述状态数据匹配的字符串,则确定所述属性状态数据满足预设触发条件。
  15. 一种设备控制装置,其中,包括:
    数据获取模块,用于获取多个第一物联网设备上报的属性状态数据;
    数据发送模块,用于若所述属性状态数据满足预设触发条件,则将所述属性状态数据发送至预设消息队列中;
    线程获取模块,用于获取所述预设消息队列的多个消费者线程,并通过所述消费者线程根据所述属性状态数据,获取与所述第一物联网设备关联的目标预设场景以及所述目标预设场景对应的第二物联网设备的当前设备影子;
    指令生成模块,用于若所述当前设备影子与所述第二物联网设备在所述目标预设场景中对应的预设设备影子匹配,则通过所述消费者线程,根据所述目标预设场景生成所述第二物联网设备的动作执行指令;
    指令发送模块,用于通过所述消费者线程,将所述动作执行指令发送至所述第二物联网设备,以控制所述第二物联网设备执行所述动作执行指令对应的操作。
  16. 根据权利要求15所述的设备控制装置,其中,所述指令生成模块用于执行:
    若所述当前设备影子与所述第二物联网设备在所述目标预设场景中对应的预设设备影子匹配,则对所述第二物联网设备进行动作权限校验;
    若对所述第二物联网设备的动作权限校验通过,则根据所述目标预设场景生成所述第二物联网设备的动作执行指令。
  17. 根据权利要求15所述的设备控制装置,其中,所述设备控制装置还包括:
    影子匹配模块,用于执行:
    获取根据所述第二物联网设备在目标预设场景中对应的预设设备影子生成的影子集合;
    从所述第二物联网设备中筛选出目标第二物联网设备,并从所述影子集合中筛选出包含目标预设设备影子的目标影子集合,所述目标 预设设备影子为与所述目标第二物联网设备的当前设备影子匹配的预设设备影子;
    根据所述目标影子集合,确定所述第二物联网设备的匹配结果;
    若所述匹配结果为第一结果,则确定所述当前设备影子与所述第二物联网设备在所述目标预设场景中对应的预设设备影子匹配。
  18. 根据权利要求17所述的设备控制装置,其中,所述影子匹配模块,用于执行:
    从所述影子集合中查找所述目标影子集合对应的下级影子集合;
    将所述第二物联网设备中初始第二物联网设备的当前设备影子与下级影子集合中预设设备影子进行匹配,得到第二物联网设备的匹配结果。
  19. 一种电子设备,其中,包括处理器和存储器,所述存储器存储有计算机程序,所述处理器用于运行所述存储器内的计算机程序,以执行权利要求1至14任一项所述的设备控制方法。
  20. 一种计算机可读存储介质,其中,所述计算机可读存储介质存储有计算机程序,所述计算机程序适于处理器进行加载,以执行权利要求1至14任一项所述的设备控制方法。
PCT/CN2023/123635 2022-12-13 2023-10-09 设备控制方法、装置、电子设备及计算机存储介质 WO2024125052A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211603348.0 2022-12-13
CN202211603348.0A CN117135192A (zh) 2022-12-13 2022-12-13 设备控制方法、装置、电子设备及计算机存储介质

Publications (1)

Publication Number Publication Date
WO2024125052A1 true WO2024125052A1 (zh) 2024-06-20

Family

ID=88857018

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/123635 WO2024125052A1 (zh) 2022-12-13 2023-10-09 设备控制方法、装置、电子设备及计算机存储介质

Country Status (2)

Country Link
CN (1) CN117135192A (zh)
WO (1) WO2024125052A1 (zh)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200228365A1 (en) * 2019-01-15 2020-07-16 Vmware, Inc. Device scenario management
CN111930530A (zh) * 2020-06-24 2020-11-13 山东浪潮通软信息科技有限公司 一种基于物联网的设备消息处理方法、装置及介质
CN112995348A (zh) * 2021-05-12 2021-06-18 北京金山云网络技术有限公司 物联网设备的控制方法、装置、系统
CN114567519A (zh) * 2022-02-28 2022-05-31 武汉世聪智能科技有限公司 一种多线程并行管理多个智能设备指令消息的方法及装置
CN115080259A (zh) * 2021-03-11 2022-09-20 北京金山云网络技术有限公司 设备联动控制方法、装置、电子设备及存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200228365A1 (en) * 2019-01-15 2020-07-16 Vmware, Inc. Device scenario management
CN111930530A (zh) * 2020-06-24 2020-11-13 山东浪潮通软信息科技有限公司 一种基于物联网的设备消息处理方法、装置及介质
CN115080259A (zh) * 2021-03-11 2022-09-20 北京金山云网络技术有限公司 设备联动控制方法、装置、电子设备及存储介质
CN112995348A (zh) * 2021-05-12 2021-06-18 北京金山云网络技术有限公司 物联网设备的控制方法、装置、系统
CN114567519A (zh) * 2022-02-28 2022-05-31 武汉世聪智能科技有限公司 一种多线程并行管理多个智能设备指令消息的方法及装置

Also Published As

Publication number Publication date
CN117135192A (zh) 2023-11-28

Similar Documents

Publication Publication Date Title
US11704144B2 (en) Creating virtual machine groups based on request
WO2020133967A1 (zh) 共享计算资源的调度方法、共享计算系统、服务器及介质
WO2019153505A1 (zh) 一种故障修复数据包的发布方法及服务器
CN110798517B (zh) 去中心化集群负载均衡方法、系统、移动终端及存储介质
TW201837734A (zh) 業務受理及共識的方法及裝置
US20140233588A1 (en) Large receive offload functionality for a system on chip
CN109144559B (zh) 一种更新数据包的推送方法及服务器
US10476985B1 (en) System and method for resource management and resource allocation in a self-optimizing network of heterogeneous processing nodes
TW201423425A (zh) 資料分塊儲存至分散式伺服器的系統及方法
CN109145051A (zh) 分布式数据库的数据汇总方法及装置和电子设备
WO2004063928A1 (ja) データベース負荷軽減システムおよび負荷軽減プログラム
CN105681426B (zh) 异构系统
US11563805B2 (en) Method, apparatus, client terminal, and server for data processing
WO2019153880A1 (zh) 集群中镜像文件下载的方法、节点、查询服务器
CN106164888A (zh) 用于最小化工作负荷空闲时间和工作负荷间干扰的网络和存储i/o请求的排序方案
CN115280283A (zh) 在kubernets中运行pbs作业
WO2024125052A1 (zh) 设备控制方法、装置、电子设备及计算机存储介质
CN109948332A (zh) 一种物理机登录密码重置方法及装置
CN112748996A (zh) 一种非集中式拓扑系统的负载均衡策略方法及系统
CN115454576B (zh) 一种虚拟机进程管理方法、系统及电子设备
CN111008071A (zh) 任务调度系统、方法和服务器
CN116132369A (zh) 云网关服务器中多网口的流量分发方法及相关设备
WO2021232860A1 (zh) 通信方法、装置及系统
Wang et al. Virtual network embedding with pre‐transformation and incentive convergence mechanism
WO2019191569A1 (en) System and method for resource management and resource allocation in a self-optimizing network of heterogeneous processing nodes