Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
For convenience of understanding, a scenario of accessing a device to a control platform is first shown, as shown in fig. 1, the scenario includes a plurality of devices, a control platform, and a user side, where the user side may be a mobile terminal (e.g., a mobile phone, a tablet computer, a smart band, etc.), or a computer; the device can be a household appliance, furniture and other devices which can access the Internet. Generally, a device is accessed to a control platform, and a user can control the accessed device through a user side control platform to provide corresponding services for the user. In the above manner, if the user wants to control the accessed device through the control platform, the user needs to submit a protocol matching with the brand, type, model, etc. of the accessed device, so that the user is difficult to operate when using the device.
Based on the above, the invention provides a method, a device and a server for accessing a device to a control platform, and the technology can be applied to platform access scenes of various devices, especially access scenes of household appliances. To facilitate understanding of the present embodiment, first, a method for accessing a device to a control platform disclosed in the embodiment of the present invention is described in detail, and as shown in fig. 2, the method is applied to a server running the device control platform, and the method includes the following steps:
step S202, the type and function of the target device to be accessed are obtained.
The target device to be accessed may be a device that needs to be accessed to the control platform, and the device may be a household, hotel or residential appliance, such as a lamp, an air conditioner, a television, a refrigerator, or an intelligent home, such as an intelligent curtain, an intelligent faucet, or the like. The type of the target device is a category to which the target device belongs, for example, both a hall lamp and a bedroom lamp belong to a category of lamps; moreover, lamps of different brands, different categories and different models all belong to the same category, so that the mode does not need to consider the brand, the category and the model of equipment to be accessed, and only needs to pay attention to the type and the function of the equipment.
The target device to be accessed is usually provided by a third party company, the functions that can be realized by the target device are also provided by the third party company, and after the target device is connected with the control platform, the third party company can send the functions and types that can be realized by the target device to the server of the control platform through the terminal device. In specific implementation, the target device may establish a connection with the control platform through bluetooth, infrared, or a wireless local area network.
And step S204, determining an initial object model matched with the type of the target equipment.
The control platform may be configured with multiple types of object models in advance according to the business requirements of the third-party company, and the object models may be preset with initial functions of corresponding types of devices, for example, functions of turning on, turning off, adjusting, and the like of the devices. The object model is generally used to describe what the device is, what it can do, and what services can be provided externally, and generally, the object model represents the function of the device, including at least one attribute, service or event; the attribute is generally used to describe the running state of the device, such as the current ambient temperature read by the environment monitoring device, and the application system can initiate a request for reading and setting the attribute; the service can be used for describing the capability or method that the equipment can be called by the outside, the settable input parameter and output parameter, and the like, and compared with the attribute, the service can realize more complex business logic through one instruction, such as executing a certain specific task; the event may be used to describe the time when the device runs, the event generally includes notification information that needs to be sensed and processed externally, may include a plurality of output parameters, such as information about completion of a certain task, or a temperature when the device fails or alarms, and the event may be subscribed and pushed.
In specific implementation, according to the type of the target device, an object model matched with the target device is determined from a plurality of types of object models preset by the control platform, and the object model is used as an initial object model, so that model description is performed through the initial object model.
And step S206, according to the function of the target equipment, performing model description on the determined initial object model to obtain a final object model corresponding to the target equipment, so as to access the target equipment to the control platform through the final object model and provide a service corresponding to the target equipment to a preset user side.
Generally, an object model refers to a data model for digitizing an entity (corresponding to a target device) in a physical space and constructing the entity at a cloud end; in an internet of things platform (equivalent to the control platform), an object model, that is, a device function is defined, and after the function definition is completed, an object model corresponding to the device is automatically generated, which can also be understood as describing the function of the target device based on an initial object model corresponding to the target device according to the function of the target device, generally describing the function of the target device from three dimensions of attributes, services, and events, and obtaining a final object model corresponding to the target device after the function description is completed.
The final object model can access the corresponding target device to the control platform, that is, the attributes, methods and time corresponding to the target device are accessed to the control platform, so that the control platform can control the target device to provide services for the user by controlling the final object model. During specific implementation, a user can send a control instruction to the control platform through the user side, the control instruction carries services which the user needs to provide, and after receiving the control instruction, the control platform can control the target device corresponding to the final object model to provide the services which the user needs, such as turning on a light, turning on an air conditioner, adjusting the temperature of the air conditioner and the like.
The method for accessing the equipment to the control platform comprises the steps of firstly obtaining the type and the function of target equipment to be accessed; further determining an initial object model matched with the type of the target equipment; and then according to the function of the target equipment, carrying out model description on the determined initial object model to obtain a final object model corresponding to the target equipment, so that the target equipment is accessed to the control platform through the final object model, and services corresponding to the target equipment are provided for a preset user side. According to the method, the initial object model is determined based on the type of the target equipment, the final object model of the target equipment is obtained according to the function description initial object model of the target equipment, and the target equipment is accessed to the control platform through the final object model.
The embodiment of the invention also provides another method for accessing the equipment to the control platform, which is realized on the basis of the method of the embodiment; the method focuses on a specific process of determining an initial object model matching the type of the target device (realized by steps S308-S310 described below); as shown in fig. 3, the method comprises the following specific steps:
step S302, a communication protocol of the target equipment to be accessed is obtained.
In specific implementation, the communication protocol of the target device may be acquired through an Application Programming Interface (API) of the device developed by the third party company. The communication protocol generally refers to the rules and conventions that must be followed by two entities to complete communication or service, and the protocol generally defines the format used by the data unit, the information and meaning that the information unit should contain, the connection mode, and the timing of sending and receiving information, so as to ensure that data in the network is smoothly transmitted to a certain place. The communication protocol may be a bluetooth communication protocol, an infrared communication protocol, a Zigbee protocol, an MQTT (Message Queuing Telemetry Transport) protocol, or the like.
The Bluetooth communication protocol is usually a short-distance communication protocol and is suitable for equipment with a short data transmission distance; the infrared communication protocol is generally a transmission technology based on infrared rays, which are not interfered by radio, but because the wavelength of the infrared rays is shorter and the diffraction capability to obstacles is poor, the infrared communication protocol is more suitable for point-to-point direct line data transmission in occasions requiring short-distance wireless communication; zigbee is generally an emerging short-distance, low-rate wireless network technology, and the Zigbee protocol has requirements of low cost, low energy, high fault tolerance, and the like; the MQTT protocol is generally an instant messaging protocol with low overhead and low bandwidth occupation, and can be widely applied to the aspects of internet of things, small-sized device application, mobile application and the like.
Step S304, establishing a communication connection with the target device through the communication protocol of the target device.
During specific implementation, the equipment for data transmission through the Bluetooth can establish communication connection with the control platform through a Bluetooth communication protocol; the device for data transmission through infrared rays can establish communication connection with the control platform through an infrared protocol; the equipment for data transmission through the wireless network can be connected with the control platform through a ZigBee protocol; in some embodiments, the connection may also be established with the control platform via other communication protocols. Usually, the target device may establish a connection with the control platform only when the communication protocol of the target device meets the access protocol of the control platform, and the access protocol may be various connectable communication protocols, such as a bluetooth communication protocol, an infrared communication protocol, a Zigbee protocol, an MQTT protocol, and the like, in order to meet the access requirements of various devices.
The step S304 can also be realized by the following steps 10-11 (not shown in the figure):
and step 10, judging whether the communication protocol of the target equipment is a preset accessible protocol of the control platform.
And 11, if the protocol is a preset accessible protocol of the control platform, establishing communication connection with the target equipment. In specific implementation, if the access protocol is not the preset access protocol of the control platform, the communication connection is not established with the target device.
Step S306, the type and function of the target device for establishing the communication connection are obtained.
Step S308, receiving a model selection instruction triggered by a user based on the type of the target equipment; the model selection instructions include an initial object model selected by the user to match the type of target device.
In specific implementation, when the type and the function of the target device are received, the function is usually a data form provided by a third party, the data form needs to be manually carded into a uniform format, and a user can select an initial object model matched with the type of the target device based on the type of the target device through a user side, and encapsulate the selected initial object model and the uniformly provided data form into a model selection instruction. For example, when the type of target device is a lamp, the user may select an initial object model corresponding to the lamp.
Step S310, obtaining an initial object model corresponding to the target device from the model selection command.
Step S312, according to the function of the target device, performing model description on the obtained initial object model to obtain a final object model corresponding to the target device, so as to access the target device to the control platform through the final object model, and provide a service corresponding to the target device to a preset user side.
During specific implementation, model description is carried out on the initial object model according to a data table with a uniform format corresponding to the functions of the target equipment, and a final object model is obtained. And obtaining a final object model, namely, accessing the target equipment to the control platform, and controlling the target equipment to provide services through the control platform by a user.
And step S314, monitoring the working state and the load parameters of the target equipment through the final object model.
After the target device is accessed to the control platform, the working state and the load parameters of the target device can be monitored through a final object model corresponding to the target device, namely the working parameters and the load running parameters of the target device during running are monitored, and when the working parameters or the load parameters exceed a preset value, alarm information can be sent to a user side to ensure safe running of the target device.
In the method for accessing the equipment to the control platform, the target equipment establishes connection with the control platform through a communication protocol, and after the communication connection is established, the type and the function of the target equipment are obtained; further receiving a model selection instruction triggered by a user based on the type of the target equipment, and then acquiring an initial object model corresponding to the target equipment from the model selection instruction; and then according to the function of the target equipment, carrying out model description on the obtained initial object model to obtain a final object model corresponding to the target equipment, so that the target equipment is accessed to the control platform through the final object model, and the working state and the load parameters of the target equipment are monitored. According to the method, the equipment is accessed to the control platform through the object model, the time for accessing the equipment is effectively shortened, the labor cost and the time cost are saved, meanwhile, the object model is used for controlling the target equipment, and a user can call the control target equipment through simple operation, so that the calling process of the user is reduced, and the learning cost of equipment calling is also reduced.
The embodiment of the invention also provides another method for accessing the equipment to the control platform, which is realized on the basis of the method of the embodiment; the method mainly describes a specific process of performing model description on a determined initial object model according to the function of target equipment to obtain a final object model corresponding to the target equipment (realized through the following steps S406-S408); as shown in fig. 4, the method includes the following specific steps:
step S402, obtaining the type and function of the target device to be accessed.
Step S404, determining an initial object model matched with the type of the target equipment; wherein, the initial function corresponding to the type of the target device is preset in the initial object model.
The initial function corresponding to the initial object model is usually that different operation instructions are set for different types of target devices, and initial parameters corresponding to each type of target device, usually the same type of device has the same initial parameters, and when the same type of device has special functions, the expansion or modification can be performed on the basis of the initial parameters. For example, the floor lamp of brand a and the bedside lamp of brand B to be switched in are of the same type of lamp, wherein for the on operation of the lamp, only one operation instruction needs to be set in the initial object model, that is, the control instructions of the floor lamp and the bedside lamp for the same operation are the same, and there is no need to distinguish the brand and the model.
Step S406, adjusting the initial function in the initial object model according to the function of the target device.
The initial parameters in the initial object model can be deactivated, activated or modified according to the function of the target device, for example, the yellow light set in the initial object model is sleep light, the yellow-white light set in the target device is sleep light, and the yellow light in the initial object model needs to be adjusted to be yellow-white light; the initial object model is provided with an alarm function of the target equipment, and alarm parameters, alarm modes and the like can be conditioned in the initial object model according to the alarm function of the target equipment. According to the function of the target device, the control command in the initial object model may be matched with the function of the target device, for example, the light-on command is corresponding to the light-on parameter in the target device.
In a specific implementation, the step 406 may be implemented only in the following first mode or second mode, or may be implemented in the following first mode and second mode:
in the first mode, the operation state of the initial object model in each preset time period is adjusted, so that the operation state of the initial object model is matched with the function of the target equipment.
The time periods may be time periods in a day or seasonal time periods in a year, the operation state is usually the state of the target device during operation, and the operation state of the target device is usually different in each time period, for example, for a hall lamp, the color of the lamp light set in the evening (e.g., 18; the light color set at late night (e.g., 22. In a specific implementation, the operation state of the initial object model is adjusted to match the function of the target device, which may also be understood as the state of the target device in operation described by the initial object model.
And in the second mode, the control instruction needing to be identified by the initial object model is adjusted, and the working parameters are adjusted based on the control instruction.
The operating parameters in the initial object model generally correspond to the operating parameters of the target device, including the initial parameters. The control command may be sent by a developer, and the corresponding operating parameters may be adjusted according to the control command, for example, for the lamp, when the developer wants to set the white light in the initial object model to be yellow, the control command may be sent to modify the color of the lamp light. In specific implementation, a developer may add new working parameters according to requirements to add functions of the device or meet requirements of a user, for example, add alarm parameters.
By the second mode, the working parameters corresponding to the initial object model can be expanded or adjusted according to the change of the business requirements, and the corresponding functions of the working parameters are packaged, so that the business expansion is facilitated.
And step S408, determining the adjusted initial object model as a final object model corresponding to the target equipment.
Step S410, if a service request for the target device is received from the user side, controlling the target device to respond to the service request through the final object model of the target device.
The service request can be a request for opening, closing or adjusting the target device, the service request can be sent by a user through a user side, and in the scheme, the user can send the service request through a uniform interface provided by the control platform without sending the service request respectively for devices of different brands and different models, so that the user operation is simplified, and the experience of the user is improved.
During specific implementation, the user side is in communication connection with the control platform through a specified communication protocol; the specified communication protocol may be a protocol for uniformly providing services to the outside by the control platform, that is, the user side and the control platform may communicate through a uniform interface. The above step S410 can be realized by the following steps 20 to 21 (not shown in the figure):
and step 20, receiving a service request aiming at the target equipment from the user terminal through the specified communication protocol.
And step 21, controlling the target device to respond to the service request by using the communication protocol of the target device through the final object model. The control platform may convert a service request of the target device received through the specified communication protocol into a service request that the target device may be another service request through the final object model, and respond to the service request through a communication protocol corresponding to the target device, that is, adjust or control the target device according to the service request, for example, the service request is to adjust the temperature of the air conditioner to 25 degrees, and the final object model is to set the air conditioner to 25 degrees through the communication protocol corresponding to the target device.
In specific implementation, the control of the target device through the final object model in the control platform is implemented based on a micro service architecture, which is generally a new technology for deploying applications and services in the cloud, in service disclosure, many services can be limited by internal independent processes, and in the micro service architecture, only required functions need to be added in a specific certain service, and the architecture of the whole process is not influenced. The micro service architecture comprises a domain model (equivalent to the initial object model) layer, a technical middle platform, a service layer and a gateway layer.
The micro-service architecture in the control platform can be preset with a plurality of domain models according to service forms, the domain models can be divided into gardens, projects, sub-projects, buildings and the like, and can also be divided into rooms, buildings, units, floors and the like, and the domain models and the functions of the domain models can be generally expanded according to service requirements; in specific implementation, in the domain model layer, the level form of the domain is predefined according to the business form, and the device described by the access object model can be directly connected with the service of the use scene. The linkage of a plurality of scenes is realized by matching with the scenes and other auxiliary capabilities. In the above technology, the station can convert the communication protocol, that is, convert the communication protocol corresponding to the target device into the specified communication protocol, so that when the user controls the target device, the user does not need to pay attention to the communication protocol for establishing communication connection with the target device, but only needs to control the target device through the specified communication protocol, and the specified communication protocol can provide an http request (equivalent to the service request) provided by the user outside in a unified manner for the user to use in the web page and the interface. Meanwhile, the technical middle platform can also provide uniform working state, load bearing capacity and the like of the monitoring equipment to the outside.
The service layer can provide uniform service capability to provide external delivery capability, namely, provide uniform field model service (equivalent to providing service through the final object model), the field model can directly run the service of the target device by operating the final object model, and meanwhile, the field model also comprises the services of checking the final object model corresponding to the target device, pushing the state of the device and the like. The gateway layer is used for providing a unified login service for the user, when the user logs in the control platform to control the target equipment through a login page in the user side, the OAuth2 authentication page is skipped, and after the authentication is successful, the page is skipped back to the previous page. The OAuth (Open Authorization) is generally an Open standard that allows a developer to authorize a user application to access a function of a device provided by a third party company stored in a server corresponding to a control platform by the platform without providing a user name and a password to the third party company, and OAuth2.0 is a continuation version of the OAuth protocol.
The micro-service architecture generally has the functions of uniform gateway, uniform authentication, authentication service management and the like, wherein the uniform gateway can uniformly provide services to the outside through a service layer and a gateway layer, and uniformly receives requests and forwards the requests to corresponding micro-services; the unified authentication can realize the unified routing authentication function through a micro service gateway (Zuul), and the authentication function of the service can be accessed only after the user authentication is realized; the authentication service management can realize unified authentication service management of the third-party application needing single sign-on, and distribute configurations such as application identity (Client), secret key (secret) and the like.
In a specific implementation, the third-party company may access the operation capability of its own device to the control platform according to the control platform access protocol. In this process, the control platform needs to interface different devices of different brands, such as a floor lamp of brand a and a bedside lamp of brand B, and for the operation of the lamps, it needs to provide the same password for the external and service operations to operate the devices.
The method for accessing the equipment to the control platform aims at the problems that each brand, type and model are required to be independently accessed when the existing equipment is accessed, and manufacturers, types, models and the like of the equipment also need to be concerned in the use process.
Corresponding to the above embodiment of the method for accessing a device to a control platform, the embodiment of the present invention further provides a device for accessing a device to a control platform, as shown in fig. 5, the device is disposed in a server running with the device control platform; the device includes:
and a data module 50, configured to acquire the type and function of the target device to be accessed.
And a model determining module 51, configured to determine an initial object model matching the type of the target device.
And the access module 52 is configured to perform model description on the determined initial object model according to the function of the target device to obtain a final object model corresponding to the target device, so as to access the target device to the control platform through the final object model, and provide a service corresponding to the target device to a preset user side.
The device for accessing the equipment to the control platform firstly acquires the type and the function of target equipment to be accessed; further determining an initial object model matched with the type of the target equipment; and then according to the function of the target equipment, carrying out model description on the determined initial object model to obtain a final object model corresponding to the target equipment, so as to access the target equipment to the control platform through the final object model and provide services corresponding to the target equipment to a preset user side. According to the method, the initial object model is determined based on the type of the target equipment, the final object model of the target equipment is obtained according to the function description initial object model of the target equipment, and the target equipment is accessed to the control platform through the final object model.
Further, the apparatus further comprises a connection module configured to: acquiring a communication protocol of target equipment to be accessed; and establishing communication connection with the target device through the communication protocol of the target device.
Specifically, the connection module is further configured to: judging whether a communication protocol of the target equipment is a preset accessible protocol of the control platform; and if the protocol is the preset accessible protocol of the control platform, establishing communication connection with the target equipment.
Further, the model determining module 51 is configured to: receiving a model selection instruction triggered by a user based on the type of the target equipment; the model selection instruction comprises an initial object model which is selected by a user and matched with the type of the target equipment; and acquiring an initial object model corresponding to the target equipment from the model selection instruction.
The initial function corresponding to the type of the target equipment is preset in the initial object model; the access module 52 is configured to: adjusting an initial function in the initial object model according to the function of the target equipment; and determining the adjusted initial object model as a final object model corresponding to the target equipment.
Further, the access module 52 is further configured to: adjusting the running state of the initial object model in each preset time period so as to enable the running state of the initial object model to be matched with the function of the target equipment; and/or adjusting control commands that the initial object model needs to identify, and adjusting the working parameters based on the control commands.
Further, the apparatus further includes a device control module configured to: and if a service request aiming at the target equipment from the user side is received, controlling the target equipment to respond to the service request through the final object model of the target equipment.
Specifically, the user terminal is in communication connection with the control platform through a specified communication protocol; the device control module is configured to: receiving a service request aiming at a target device from a user side through a specified communication protocol; and controlling the target equipment to respond to the service request by using the communication protocol of the target equipment through the final object model.
Specifically, the apparatus further includes a monitoring module, configured to: and monitoring the working state and the load parameters of the target equipment through the final object model.
The device for accessing a device to a control platform provided by the embodiment of the present invention has the same implementation principle and technical effect as those of the foregoing method embodiments, and for brief description, reference may be made to corresponding contents in the foregoing method embodiments for parts of embodiments of the device that are not mentioned.
An embodiment of the present invention further provides a server, which is shown in fig. 6, and the server includes a processor 101 and a memory 100, where the memory stores machine executable instructions that can be executed by the processor 101, and the processor 101 executes the machine executable instructions to implement the method for accessing the device to the control platform.
Further, the server shown in fig. 6 further includes a bus 102 and a communication interface 103, and the processor 101, the communication interface 103 and the memory 100 are connected through the bus 102.
The memory 100 may include a high-speed Random Access Memory (RAM) and may further include a non-volatile memory (non-volatile memory), such as at least one disk memory. The communication connection between the network element of the system and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the internet, a wide area network, a local network, a metropolitan area network, and the like can be used. The bus 102 may be an ISA bus, a PCI bus, an EISA bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 6, but this does not indicate only one bus or one type of bus.
The processor 101 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware or instructions in the form of software in the processor 101. The processor 101 may be a general-purpose processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the Integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, or discrete hardware components. The various methods, steps and logic blocks disclosed in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present invention may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in the memory 100, and the processor 101 reads the information in the memory 100, and completes the steps of the method of the foregoing embodiment in combination with the hardware thereof.
An embodiment of the present invention further provides a machine-readable storage medium, where the machine-readable storage medium stores machine-executable instructions, and when the machine-executable instructions are called and executed by a processor, the machine-executable instructions cause the processor to implement the method for accessing the device to the control platform, where specific implementation may refer to method embodiments, and details are not described herein.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the apparatus and/or the electronic device described above may refer to corresponding processes in the foregoing method embodiments, and are not described herein again.
Finally, it should be noted that: the above-mentioned embodiments are only specific embodiments of the present invention, which are used for illustrating the technical solutions of the present invention and not for limiting the same, and the protection scope of the present invention is not limited thereto, although the present invention is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: those skilled in the art can still make modifications or changes to the embodiments described in the foregoing embodiments, or make equivalent substitutions for some features, within the scope of the disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present invention, and they should be construed as being included therein. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.