Search 1.9 billion lines of Odoo code on GitHub

iot_input_oca

Author: Creu Blanca, Odoo Community Association (OCA)
License: AGPL-3
Branch: 15.0
Repository: Change2improve/iot
Dependencies: iot_oca
Languages: HTML (395, 29.0%), JSON (19, 1.4%), Python (694, 50.9%), XML (117, 8.6%), and reStructuredText (139, 10.2%)
Other branches: 13.0, and 14.0
Other repositories: Gabinete-Digital/iot, OCA/iot, tegin/iot, and wahello/iot

<h1 class="title">IoT Input</h1> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/iot/tree/15.0/iot_input_oca"><img alt="OCA/iot" src="https://img.shields.io/badge/github-OCA%2Fiot-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/iot-15-0/iot-15-0-iot_input_oca"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/269/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p>This addon allows to use a device in order to input data to odoo automatically.</p> <p>It opens a URL that a device can use to connect (with a password) that can only execute an specific action.</p> <p>Inputs are useful when a device wants to communicate to odoo for a single and simple action. This way, the device does not need to be configured with a odoo user and password, it is handled by odoo devices.</p> <p>Examples:</p> <ul class="simple"> <li>Sending the temperature every three minutes.</li> <li>Sending the RFID that the device has received in order to perform some action</li> </ul> <p><strong>Table of contents</strong></p> <div class="contents local topic" id="contents"> <ul class="simple"> <li><a class="reference internal" href="#usage" id="id1">Usage</a></li> <li><a class="reference internal" href="#bug-tracker" id="id2">Bug Tracker</a></li> <li><a class="reference internal" href="#credits" id="id3">Credits</a><ul> <li><a class="reference internal" href="#authors" id="id4">Authors</a></li> <li><a class="reference internal" href="#contributors" id="id5">Contributors</a></li> <li><a class="reference internal" href="#maintainers" id="id6">Maintainers</a></li> </ul> </li> </ul> </div> <a name="usage"></a> <h2><a class="toc-backref" href="#id1">Usage</a></h2> <p>There are two endpoints you can use: Endpoint 1: /iot/&lt;serial&gt;/action</p> <p>Takes <cite>application/x-www-form-urlencoded</cite> parameters: passphase, value (where value is a JSON object)</p> <ol class="arabic simple"> <li>Create a Device on <cite>IoT &gt; Config Devices</cite></li> <li>Access the Inputs section of the device</li> <li>Create an input. You must define a serial, passphrase, function and model</li> </ol> <p>The function that the system will call must be of the following kind:</p> <pre> <code>&#64;api.model def call_function(self, key): return {}</code> </pre> <p>Where <cite>key</cite> is the input string send by the device and the result must be a dictionary that will be responded to the device as a JSON.</p> <p>Endpoint 2: /iot/&lt;device_identification&gt;/multi_input It can be used to send values with multiple data in one POST request such as: - Values for inputs of the same device with different address (multi input) - Values for inputs of the same device with same address, different values (multi event) - Mix of the above (multi input, multi event)</p> <p>Takes <cite>application/x-www-form-urlencoded</cite> parameters: passphase, values (a JSON array of JSON objects)</p> <p>It is called using device_identification and passing two POST parameters: device passphrase and a JSON string containing an array of values for input - The value for the <cite>address</cite> key can be a string or a numeric (to conserve bytes in memory restricted devices when creating the JSON object) and is converted to string when parsing. - The value for the <cite>value</cite> key can either be string, number or boolean according to JSON specs. You can see an example of a valid JSON input object in the examples folder, using a few combinations.</p> <p>It requires the function that the system will call must be of the following kind:</p> <pre> <code>&#64;api.model def call_function(self, key): 'do something if err: return {'status': 'error', 'message': 'The error message you want to send to the device'} return {'status': 'ok', 'message': 'Optional success message'}</code> </pre> <p>Where <cite>key</cite> is a dict send by the device having at least value for keys: 'address', 'value'</p> <p>The function must always return a JSON with status and message. If value contains a value with 'uuid' as key, it is returned along with the object for the IoT device to identify success/failure per record.</p> <p>It has full error reporting and the return value is a JSON array of dicts containing at least status and message. Error message respose is at some points generic, though extended logging is done in Odoo server logs.</p> <a name="bug-tracker"></a> <h2><a class="toc-backref" href="#id2">Bug Tracker</a></h2> <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/iot/issues">GitHub Issues</a>. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed <a class="reference external" href="https://github.com/OCA/iot/issues/new?body=module:%20iot_input_oca%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <p>Do not contact contributors directly about support or help with technical issues.</p> <a name="credits"></a> <h2><a class="toc-backref" href="#id3">Credits</a></h2> <a name="authors"></a> <h3><a class="toc-backref" href="#id4">Authors</a></h3> <ul class="simple"> <li>Creu Blanca</li> </ul> <a name="contributors"></a> <h3><a class="toc-backref" href="#id5">Contributors</a></h3> <ul class="simple"> <li>Enric Tobella &lt;<a class="reference external" href="mailto:etobella&#64;creublanca.es">etobella&#64;creublanca.es</a>&gt;</li> <li>Dimitrios Tanis &lt;<a class="reference external" href="mailto:dtanis&#64;tanisfood.gr">dtanis&#64;tanisfood.gr</a>&gt;</li> </ul> <a name="maintainers"></a> <h3><a class="toc-backref" href="#id6">Maintainers</a></h3> <p>This module is maintained by the OCA.</p> <a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a> <p>OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.</p> <p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p> <p><a class="reference external" href="https://github.com/etobella"><img alt="etobella" src="https://github.com/etobella.png?size=40px" /></a></p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/iot/tree/15.0/iot_input_oca">OCA/iot</a> project on GitHub.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>