tobof / openhab-addons

The next-generation open Home Automation Bus (openHAB)
Eclipse Public License 2.0
39 stars 30 forks source link

MySensors Binding Refactoring #58

Closed andreacioni closed 7 years ago

andreacioni commented 7 years ago

Hi @tobof ,

as announced, here my work of last months. I hope you'll appreciate it šŸ˜„ The idea that guided me: clearly decoupling MySensors from Openhab. Firstly, I did this by splitting binding package in two part:

  1. Internal (org.openhab.mysensors.internal) <--MySensors

  2. Non-Internal (org.openhab.mysensors) <-- OpenHab

The first should be seen as a sort of "library" that does all the background and application-specific work. It must not have any dependency on smarthome API (you can see for example, MySensorsBridgeConfiguration. Now has to be mapped to MySensorsGatewayConfig. This could be sound redundant, but it is the only way to do this separation).

Second point is completely related to OpenHab. It shouldn't know anything about how MySensors works. It doesn't have the responsibility to handle application specific task like interpreting messages. All this work is now handled by MySensorsGateway, which is the high-level access point to all the function that OH may needs.

MySensorsGateway is the new actor in this binding. It replaces (encapsulating) the connection and extends features of the DeviceManager that was already present before, but never used. With gateway we could send messages, manage node/child and theirs variables (add/remove/modify) and register listeners for network events (like variable update/connection state/etc).

That is the main idea. But there are a lot of things to explain. Let me do a summary šŸ˜‰ :

EDIT (31/1):

I hope not forgiveness. Please report me all your impressions and ideas, we could work together to accomplish the best result from this refactoring!

My TODO list: