Enable Dark Mode!
By: Mohd Shamsad PS

How to Add Driver Files & Run Python Code in IoT


A Driver is a group of files that enable devices to communicate with the OS. It gives access to hardware regardless of knowing the details of the hardware used. The Interface is used to detect specific types of connected devices. Creating a new interface needs the following:

1) Extending the Interface class

2) Setting the connection_type class attribute

3) get_device method, which returns a dictionary of the connected device


This is the structure of the directory. Each module contains a folder, iot_handlers, where the driver and interface files are located. When the IoT Box is booting, it will load all the interface and driver files corresponding to the Odoo instance.

We can click on the load handlers button on the Home page of the IoT box, and it will display all the interfaces and drivers that are loaded.

The pictures below show that the driver file we have created in the directory iot_handlers is loaded into the Handlers. Similarly, we can also load the interfaces to our requirements. We can code in these files according to our needs and can run the python code there.


For testing the IoT, there is a default controller in Odoo to test. We can use that controller to verify. For that, we have to add a ‘/hw_proxy/hello’ controller to the IP of the IoT. If our Driver or interface file is not loaded when we have to reboot the IoT Box.

@http.route('/hw_proxy/hello', type='http', auth='none', cors='*')
def hello(self):
   return "ping"

This will result in a view as shown below:


If we have to run customized code, we have to create a controller similar to controller ‘/hw_proxy/hello’. Then we call that controller along with the ip of the IoT box.

from odoo import http
class ProxyController(http.Controller):
   @http.route('/hw_proxy/test', type='http', auth='none', cors='*')
   def iot_test_function(self):
       return 'Test IoT Controller'

This will return as follows:


Thus we get the output as we expected. So we can connect different devices to IoT and can run the code by creating a similar driver file. So we can connect different devices with Odoo and communicate with Odoo. Based on different devices connected to the IoT Box, we can customize their driver file and perform the required action to get the desired output.

Thus we have to create a directory called iot_handlers, where we need to create other directories for driver files as drivers and interface files as interfaces. Then we add our driver file and interface file to that corresponding directory. Then we have to load the handlers or reboot the IoT Box. Then we run the python code according to our requirements.

If you need any assistance in odoo, we are online, please chat with us.


Leave a comment




Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635



Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.



Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message