IoT Integration with Odoo ERP

Posted By : Siddhant Sinha | 24-Feb-2020

 

In recent years, the Internet of Things has become the hot new domain of technology that almost every major tech company wants to dip its toes in. The problem, however, lies in integrating various IoT devices to their existing infrastructure. So Odoo, the most popular ERP framework has come up with its own method to integrate IoT with its ERP system. Released with version 12 of Odoo, Odoo IoT is a module that communicates through IoT box. An IoT box is basically a Raspberry Pi with a custom Linux image with the required drivers to connect to Odoo’s IoT module. We can connect to this box via Ethernet or WiFi, whichever method suits the users. Oodles provides top-rated Odoo Implementation services and Custom Odoo ERP development services to ensure the seamless execution of ERP systems. Our developers custom integrate selected modules from a stack of 10000+ applications as per business requirement and objectives.

 

Features of IoT 

Any IoT solution has three basic features – 

1. detecting various devices on the network

2. getting sensory data from them

3. performing any actuation based on that data.

 

Device Compatibility of Odoo’s IoT Box 

Odoo has implemented support for various different devices for it’s IoT box such as cameras, printers, point of sale systems, and footswitches. We can also connect other devices compatible with the IoT box via USB, WiFi, or Bluetooth, as Raspberry Pi supports for all these technologies.
All we need to do is extend the Driver class. During each boot, the IoT Box loads all of the Drivers that can be located on the connected Odoo instance. Each module can contain a driver directory, whose content will be copied to the IoT Box. There is a Manager service in the addons/hw_drivers/controllers/drive.py file. It takes care of detecting the devices and associating them with the correct driver.

 


 

Creating a New Driver

In order to create a new driver on your device, write the following code in a new file under Custom Addons.

class IoTDevice(Driver):

    connection_type = 'ConnectionType'

 

    def __init__(self, device):

        super(NewDriver, self).__init__(device)

        self._device_type = 'DeviceType'

        self._device_connection = 'DeviceConnection'

        self._device_name = 'DeviceName'

 

    @classmethod

    def supported(cls, device):

 

Set the ‘ConnectionType’, ‘DeviceType’, ‘DeviceConnection’, and ‘DeviceName’ attributes accordingly. Define the supported class method.

 The driver created above will allow the Manager to detect your device and it will appear in the IoT module. Note that the device can only be detected over a local network.

There is bidirectional communication between the box and the browser. For browser to box, we use Actions, and for box to browser, we use LongPolling. Both channels are accessed from the same JS object, the DeviceProxy, which is instantiated using the IP of the IoT Box and the device identifier.

var DeviceProxy = require('iot.widgets').DeviceProxy;

 

var iot_device = new DeviceProxy({

    iot_ip: iot_ip,

    identifier: device_identifier

});

 

We use Actions to tell a selected device to execute a specific action like taking a picture, printing a receipt, etc. An action can be performed on the DeviceProxy Object.


 

iot_device.action(data);

 

In the driver, define an Action method that will be executed when called from an Odoo module. It takes the data given during the call as an argument.

 

def action(self, data):

 

    

In order to read the data from a device, create a callback function that will be called every time the device status changes. The callback is called with the new data as argument.


 

iot_device.add_listener(this._onValueChange.bind(this));

 

_onValueChange: function (result) {

 

}

 

In the Driver, an event is released by calling the device_changed function from the event_manager. All callbacks set on the listener will then be called with self.data as argument.

from odoo.addons.hw_drivers.controllers.driver import event_manager

 

self.data = {

    'value': 0.8

}

event_manager.device_changed(self)

 

 

Thus, by following these steps we can add our own device to the Odoo IoT and perform the basic functionalities of device detection, data gathering, and actuation.


 

Integrate Odoo IoT Module into Odoo ERP


Odoo IoT module makes integrating IoT devices into business processes ingenious. Smoothly detected and integrated with Odoo ERP, the IoT box increases the functionality of IoT devices and enhances business operations. At Oodles, we are an ERP Development Company with the goal of augmenting enterprises with cutting-edge technologies that transform the way organizations work. Our developers have an extensive experience of working with ERP software and deal with the minutiae of it to offer enterprise-wide, effective solutions to our clients.


Please remove URL from text

Comment is required

Sending message..
Connect with us