OCA / iot

Internet of Things (IoT)
GNU Affero General Public License v3.0
63 stars 86 forks source link

[IDEA] Module for storing generic IOT event / message #16

Closed diggy128 closed 2 years ago

diggy128 commented 4 years ago

I think we should create a module to handle generic input FROM IOT devices and allow to store them to a separated model.

Rough Analysis: Up to now installing an IOT module gives you the possibility to handle IOT devices and allow methods to update data in Odoo. The thing here is there is so much data that can come from an IOT device that does not correlate to any model in Odoo or it does not make sense to, but useful conclusions can come from consolidating and analyzing that data. A very rough example is a simple magnetic switch in a door for a controlled environment room. Creating a new module to hold data from that single sensor is an overkill but having an analysis on when / how often the door is opened / closed can give useful insights.

So my proposal is to create a module eg iot.event that will have:

The separate date and time fields are to allow grouping and pivoting by date and time respectively. For the value field we can copy the definitions from base_custom_info in server-tools to handle all data types.

There will be a check box in device input to allow logging in the event table as well as a data type selection. A separate menu will be created along with tree, pivot and graph views to allow for some analysis.

As a side-note, using that data with mis_builder can create a multitude of KPIs Disclaimer: I am about to implement a module around the same concept (in-house) so if there is interest I would be happy to work with the community and push it to OCA.

etobella commented 4 years ago

Hi, I made a small module with the intention to handle the storage of a themperature sensor. Maybe it is useful to you https://github.com/tegin/iot/tree/11.0-add-iot_input_sensor . This is just an idea, so it is not necessary to take it :wink:

From my side, the idea is welcome and we can review it if you want to propose a module

diggy128 commented 4 years ago

So, I wrote a module that implements the logic I mentioned above and tested with 3 different platforms: -Arduino -Arduino using MIT App Inventor application to post data -ESP8266 with Micropython -Serial data on COM port (using pyserial)

But I keep bumping on the limitations of the current controller implementation in iot_input.

A few examples:

I believe a rewrite of the call_unauthorized_iot is needed. @etobella Would you consider merging breaking changes?

etobella commented 4 years ago

I cannot promise a merge, but I will review for sure!

JuanDCG commented 3 years ago

Hi @diggy128 and @etobella 👍🏽 How about this work ?

I was thinking about integrate IoT on Odoo for 6 years ago. But tools and markets were immature yet, so I only theorized.

I want to contribute to this PSC/repository and this [IDEA] proposal is very good to start with it.

First, a solution for IoT should be break in little parts:

Some thoughts about IoT Odoo based solution:

What are you thinking about all ?

etobella commented 3 years ago

Hi @JuanDCG , The proposal of @diggy128 was merged on #21

About your ideas:

I don't have a video right now of our door, but I can try to make one if you are interested :wink:

diggy128 commented 3 years ago

Actually @etobella PR #21 just sets the base for the module I was thinking of. I've put together a module cleverly named iot_event 😃. I haven't pushed it yet because it lacks tests. It's been in production for more than 2 months now.

If you want I can create a PR and discuss over it's implementation

etobella commented 3 years ago

Sure!

JuanDCG commented 3 years ago

I agree,

You have done a hard work that cannot be read in any documentation so I would need more time to read the code ... Although to test it locally I need more space, resources and time ... Maybe I can document your work while I learn.

Thank you !

JuanDCG commented 3 years ago

At the moment, I have a lot to learn about what you have built, but if I can help stimulate conversations in the community and generate new ideas or approaches, great.

So, since I thought the project was less mature, I had thought about it from scratch.

JuanDCG commented 3 years ago

For example, a scalable case study, imagine that an alarm company in electronic door locks wants to automate its business flow by innovating in cutting-edge technologies in IoT but maintaining its supply and maintenance chain with Odoo CE.

They want to gradually implement electronic locks in a few clients while automating the entire business and technological flow... Then, to be able to scale to millions of automated doors

How would you scale the database? PostgreSQL? How would you ingest so much traffic? Apache Kafka? How would the security and events of the doors be analyzed? Apache Spark?

And so on and so for

JuanDCG commented 3 years ago

@OCA/iot-maintainers

For better discussion, sorry.

diggy128 commented 3 years ago

@OCA/iot-maintainers @etobella @JuanDCG Created PR #24 with new module. It is still WIP and needs some polishing before tests but pushed it to continue discussion.

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue in the past 6 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days. If you want this issue to never become stale, please ask a PSC member to apply the "no stale" label.