richibrics / IoTuring

Your Windows, Linux, macOS computer as MQTT and HomeAssistant integration
https://pypi.org/project/IoTuring/
GNU General Public License v3.0
70 stars 6 forks source link

Rethink how entity dependencies work #30

Closed infeeeee closed 1 year ago

infeeeee commented 1 year ago

I think the current flow is not really efficient, and not easily maintainable.

The problems:

Possible solutions:

A: Remove the whole dependency system. Move all the base methods to submodules, just like MyApp. Convert os and de entities similar to AppInfo. If in the future some part of an Entity needed in another one, move that methods to a submodule, or create the new entity as a subclass.

Maybe this new module could be merged with MyApp, to create a single source for all static info. I recommend this solution.

This solution could also help with the config flow, as elements not available could be hidden from the list.

B: Build correct dependency chain in EntityManager. Evaluate which entity depends on which and initialize them in the correct order.

What do you think @richibrics ? What is your plan with the dependency system?

richibrics commented 1 year ago

Hi @infeeee, been busy these days. Thank you for all your work, I'll watch it in the following days.

I think the choice will be to keep Entity dependencies so I'll create a flow to initialize everything in the correct order. It will be like:

infeeeee commented 1 year ago

Ok, thanks, no rush. I just had too much free time nowadays.

The main problem, I don't understand what is the point of dependencies. They are only checked during Initialize and during normal runtime they don't even matter. What else do you plan to add as dependency source beside existing os and de?

It seems they add a huge avoidable complexity to the code. Remember the KISS principle. I will create proof of concept to show what I'm trying to say.