From d6fbc558171f5f21a6fafaa086d0ea6f37d331dd Mon Sep 17 00:00:00 2001 From: FernandoRomera Date: Mon, 5 Aug 2024 10:01:51 +0200 Subject: [PATCH] [IMP] iot_input_oca: pre-commit auto fixes --- iot_input_oca/README.rst | 128 +++++++++++--------- iot_input_oca/pyproject.toml | 3 + iot_input_oca/readme/CONTRIBUTORS.md | 2 + iot_input_oca/readme/CONTRIBUTORS.rst | 2 - iot_input_oca/readme/DESCRIPTION.md | 15 +++ iot_input_oca/readme/DESCRIPTION.rst | 14 --- iot_input_oca/readme/USAGE.md | 58 +++++++++ iot_input_oca/readme/USAGE.rst | 55 --------- iot_input_oca/static/description/index.html | 100 ++++++++------- iot_input_oca/tests/test_iot_multi_input.py | 1 - 10 files changed, 199 insertions(+), 179 deletions(-) create mode 100644 iot_input_oca/pyproject.toml create mode 100644 iot_input_oca/readme/CONTRIBUTORS.md delete mode 100644 iot_input_oca/readme/CONTRIBUTORS.rst create mode 100644 iot_input_oca/readme/DESCRIPTION.md delete mode 100644 iot_input_oca/readme/DESCRIPTION.rst create mode 100644 iot_input_oca/readme/USAGE.md delete mode 100644 iot_input_oca/readme/USAGE.rst diff --git a/iot_input_oca/README.rst b/iot_input_oca/README.rst index 5115f37f..6beffb9f 100644 --- a/iot_input_oca/README.rst +++ b/iot_input_oca/README.rst @@ -17,31 +17,32 @@ IoT Input :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html :alt: License: AGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fiot-lightgray.png?logo=github - :target: https://github.com/OCA/iot/tree/16.0/iot_input_oca + :target: https://github.com/OCA/iot/tree/17.0/iot_input_oca :alt: OCA/iot .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/iot-16-0/iot-16-0-iot_input_oca + :target: https://translation.odoo-community.org/projects/iot-17-0/iot-17-0-iot_input_oca :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/iot&target_branch=16.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/iot&target_branch=17.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| -This addon allows to use a device in order to input data to odoo automatically. +This addon allows to use a device in order to input data to odoo +automatically. -It opens a URL that a device can use to connect (with a password) that can only -execute an specific action. +It opens a URL that a device can use to connect (with a password) that +can only execute an specific action. -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. +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. Examples: -* Sending the temperature every three minutes. -* Sending the RFID that the device has received in order to perform some action +- Sending the temperature every three minutes. +- Sending the RFID that the device has received in order to perform + some action **Table of contents** @@ -51,61 +52,68 @@ Examples: Usage ===== -There are two endpoints you can use: -Endpoint 1: /iot//action +There are two endpoints you can use: Endpoint 1: /iot//action -Takes `application/x-www-form-urlencoded` parameters: -passphase, value (where value is a JSON object) +Takes application/x-www-form-urlencoded parameters: passphase, value +(where value is a JSON object) -1. Create a Device on `IoT > Config Devices` +1. Create a Device on IoT > Config Devices 2. Access the Inputs section of the device -3. Create an input. You must define a serial, passphrase, function and model +3. Create an input. You must define a serial, passphrase, function and + model -The function that the system will call must be of the following kind:: +The function that the system will call must be of the following kind: - @api.model - def call_function(self, key): - return {} +:: -Where `key` 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. + @api.model + def call_function(self, key): + return {} -Endpoint 2: /iot//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) +Where key 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. -Takes `application/x-www-form-urlencoded` parameters: -passphase, values (a JSON array of JSON objects) +Endpoint 2: /iot//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) -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 `address` 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 `value` 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. +Takes application/x-www-form-urlencoded parameters: passphase, values (a +JSON array of JSON objects) -It requires the function that the system will call must be of the following kind:: +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 address 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 value 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. - @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'} +It requires the function that the system will call must be of the +following kind: -Where `key` is a dict send by the device having at least value for keys: 'address', 'value' +:: -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. + @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'} -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. +Where key is a dict send by the device having at least value for keys: +'address', 'value' + +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. + +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. Bug Tracker =========== @@ -113,7 +121,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -121,18 +129,18 @@ Credits ======= Authors -~~~~~~~ +------- * Creu Blanca Contributors -~~~~~~~~~~~~ +------------ -* Enric Tobella -* Dimitrios Tanis +- Enric Tobella +- Dimitrios Tanis Maintainers -~~~~~~~~~~~ +----------- This module is maintained by the OCA. @@ -152,6 +160,6 @@ Current `maintainer `__: |maintainer-etobella| -This module is part of the `OCA/iot `_ project on GitHub. +This module is part of the `OCA/iot `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/iot_input_oca/pyproject.toml b/iot_input_oca/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/iot_input_oca/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/iot_input_oca/readme/CONTRIBUTORS.md b/iot_input_oca/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..83dc1b76 --- /dev/null +++ b/iot_input_oca/readme/CONTRIBUTORS.md @@ -0,0 +1,2 @@ +- Enric Tobella \<\> +- Dimitrios Tanis \<\> diff --git a/iot_input_oca/readme/CONTRIBUTORS.rst b/iot_input_oca/readme/CONTRIBUTORS.rst deleted file mode 100644 index 61fe3232..00000000 --- a/iot_input_oca/readme/CONTRIBUTORS.rst +++ /dev/null @@ -1,2 +0,0 @@ -* Enric Tobella -* Dimitrios Tanis diff --git a/iot_input_oca/readme/DESCRIPTION.md b/iot_input_oca/readme/DESCRIPTION.md new file mode 100644 index 00000000..c26282db --- /dev/null +++ b/iot_input_oca/readme/DESCRIPTION.md @@ -0,0 +1,15 @@ +This addon allows to use a device in order to input data to odoo +automatically. + +It opens a URL that a device can use to connect (with a password) that +can only execute an specific action. + +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. + +Examples: + +- Sending the temperature every three minutes. +- Sending the RFID that the device has received in order to perform some + action diff --git a/iot_input_oca/readme/DESCRIPTION.rst b/iot_input_oca/readme/DESCRIPTION.rst deleted file mode 100644 index 0ca60637..00000000 --- a/iot_input_oca/readme/DESCRIPTION.rst +++ /dev/null @@ -1,14 +0,0 @@ -This addon allows to use a device in order to input data to odoo automatically. - -It opens a URL that a device can use to connect (with a password) that can only -execute an specific action. - -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. - -Examples: - -* Sending the temperature every three minutes. -* Sending the RFID that the device has received in order to perform some action diff --git a/iot_input_oca/readme/USAGE.md b/iot_input_oca/readme/USAGE.md new file mode 100644 index 00000000..15a87ed1 --- /dev/null +++ b/iot_input_oca/readme/USAGE.md @@ -0,0 +1,58 @@ +There are two endpoints you can use: Endpoint 1: /iot/\/action + +Takes application/x-www-form-urlencoded parameters: passphase, value +(where value is a JSON object) + +1. Create a Device on IoT \> Config Devices +2. Access the Inputs section of the device +3. Create an input. You must define a serial, passphrase, function and + model + +The function that the system will call must be of the following kind: + + @api.model + def call_function(self, key): + return {} + +Where key 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. + +Endpoint 2: /iot/\/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) + +Takes application/x-www-form-urlencoded parameters: passphase, values (a +JSON array of JSON objects) + +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 address 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 value 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. + +It requires the function that the system will call must be of the +following kind: + + @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'} + +Where key is a dict send by the device having at least value for keys: +'address', 'value' + +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. + +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. diff --git a/iot_input_oca/readme/USAGE.rst b/iot_input_oca/readme/USAGE.rst deleted file mode 100644 index d7d24727..00000000 --- a/iot_input_oca/readme/USAGE.rst +++ /dev/null @@ -1,55 +0,0 @@ -There are two endpoints you can use: -Endpoint 1: /iot//action - -Takes `application/x-www-form-urlencoded` parameters: -passphase, value (where value is a JSON object) - -1. Create a Device on `IoT > Config Devices` -2. Access the Inputs section of the device -3. Create an input. You must define a serial, passphrase, function and model - -The function that the system will call must be of the following kind:: - - @api.model - def call_function(self, key): - return {} - -Where `key` 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. - -Endpoint 2: /iot//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) - -Takes `application/x-www-form-urlencoded` parameters: -passphase, values (a JSON array of JSON objects) - -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 `address` 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 `value` 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. - -It requires the function that the system will call must be of the following kind:: - - @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'} - -Where `key` is a dict send by the device having at least value for keys: 'address', 'value' - -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. - -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. diff --git a/iot_input_oca/static/description/index.html b/iot_input_oca/static/description/index.html index e54b3c0e..e2a60f39 100644 --- a/iot_input_oca/static/description/index.html +++ b/iot_input_oca/static/description/index.html @@ -1,4 +1,3 @@ - @@ -9,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +275,7 @@ margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +301,7 @@ span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -369,18 +369,19 @@

IoT Input

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:e659667d71381159c522d2752013f4cb6047702bc458f1715e0e9655ca0414f7 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: AGPL-3 OCA/iot Translate me on Weblate Try me on Runboat

-

This addon allows to use a device in order to input data to odoo automatically.

-

It opens a URL that a device can use to connect (with a password) that can only -execute an specific action.

-

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.

+

Beta License: AGPL-3 OCA/iot Translate me on Weblate Try me on Runboat

+

This addon allows to use a device in order to input data to odoo +automatically.

+

It opens a URL that a device can use to connect (with a password) that +can only execute an specific action.

+

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.

Examples:

  • Sending the temperature every three minutes.
  • -
  • Sending the RFID that the device has received in order to perform some action
  • +
  • Sending the RFID that the device has received in order to perform +some action

Table of contents

@@ -397,14 +398,14 @@

IoT Input

Usage

-

There are two endpoints you can use: -Endpoint 1: /iot/<serial>/action

-

Takes application/x-www-form-urlencoded parameters: -passphase, value (where value is a JSON object)

+

There are two endpoints you can use: Endpoint 1: /iot/<serial>/action

+

Takes application/x-www-form-urlencoded parameters: passphase, value +(where value is a JSON object)

    -
  1. Create a Device on IoT > Config Devices
  2. +
  3. Create a Device on IoT > Config Devices
  4. Access the Inputs section of the device
  5. -
  6. Create an input. You must define a serial, passphrase, function and model
  7. +
  8. Create an input. You must define a serial, passphrase, function and +model

The function that the system will call must be of the following kind:

@@ -412,24 +413,25 @@ 

Usage

def call_function(self, key): return {}
-

Where key 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.

-

Endpoint 2: /iot/<device_identification>/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)

-

Takes application/x-www-form-urlencoded parameters: -passphase, values (a JSON array of JSON objects)

-

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 address 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 value 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.

-

It requires the function that the system will call must be of the following kind:

+

Where key 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.

+

Endpoint 2: /iot/<device_identification>/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)

+

Takes application/x-www-form-urlencoded parameters: passphase, values (a +JSON array of JSON objects)

+

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 address 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 value 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.

+

It requires the function that the system will call must be of the +following kind:

 @api.model
     def call_function(self, key):
@@ -438,20 +440,22 @@ 

Usage

return {'status': 'error', 'message': 'The error message you want to send to the device'} return {'status': 'ok', 'message': 'Optional success message'}
-

Where key is a dict send by the device having at least value for keys: ‘address’, ‘value’

-

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.

-

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.

+

Where key is a dict send by the device having at least value for keys: +‘address’, ‘value’

+

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.

+

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.

Bug Tracker

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

+feedback.

Do not contact contributors directly about support or help with technical issues.

@@ -472,13 +476,15 @@

Contributors

Maintainers

This module is maintained by the OCA.

-Odoo Community Association + +Odoo Community Association +

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.

Current maintainer:

etobella

-

This module is part of the OCA/iot project on GitHub.

+

This module is part of the OCA/iot project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

diff --git a/iot_input_oca/tests/test_iot_multi_input.py b/iot_input_oca/tests/test_iot_multi_input.py index f4afe2d9..c3c605fb 100644 --- a/iot_input_oca/tests/test_iot_multi_input.py +++ b/iot_input_oca/tests/test_iot_multi_input.py @@ -88,7 +88,6 @@ def test_error_missing_parameter(self): @mute_logger("odoo.addons.iot_input_oca.models.iot_device_input") def test_error_with_extra_args(self): - iot = self.iot.get_device( serial=self.device_identification, passphrase=self.passphrase )