Odoo 16 Development Book

Load Drivers

For a hardware device to communicate with a computer’s OS, we need a set of files called drivers. When a new device is connected to the system, the interface will fetch all the connected devices, and it will loop through all the drivers that have the same connection type attribute and test their respective supported methods on all connected devices. And if one of the driver methods returns True, an instance of the corresponding driver will be created for the device.

1. Open the IoT box homepage using the IP address, and click on the ‘handlers list’/’drivers list’ button.

odoo Development

2. On the resulting page, there will be a ‘Load drivers/Load Handlers’ button at the bottom. Click on the button to load the drivers.

odoo Development

3. To see the list of connected devices, go back to the homepage.

For creating a driver for a new device, we have to first extend the Driver class, then set the ‘connection_type’ class attribute. Then set the device_type, device_connection, and device_name attributes. And finally, define the ‘supported’ method.

from odoo.addons.hw_drivers.driver import Driver
class DriverName(Driver):
    connection_type = 'ConnectionType'
    def __init__(self, identifier, device):
        super(NewDriver, self).__init__(identifier, device)
        self.device_type = 'DeviceType'
        self.device_connection = 'DeviceConnection'
        self.device_name = 'DeviceName'
    @classmethod
    def supported(cls, device):
        ...
location

Calicut

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

location

Kochi

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

location

Bangalore

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

Send Us A Message