Chapter 18 - Odoo 15 Development Book

Load Drivers

A driver, in the case of a computer is a set of files that tells a hardware device how to function by communicating with a computer’s operating system. IoT drivers help Odoo modules to communicate in real time with the devices connected to the IoT box. Communication is two-way, meaning that Odoo clients can send and receive information.

For connecting a new device, we need an interface and driver. An interface is to detect connected devices of a specific type. Once the interface has fetched the list of all connected devices, it will select a driver with the same connection type attribute and create an instance of that driver for the connected device.

  • 1. For loading a device driver into IoT Box, first, we have to open the IoT Box homepage using the IP address. Then click on the ‘handlers list’/’drivers list’ button.
  • odoo-development-book

    2. There will be a ‘Load drivers/Load Handlers’ button at the bottom. Click on the button to load the drivers.

    odoo-development-book

    3. After that, you can go back to the homepage to see the connected devices.

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):
        //add button here
whatsapp
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