Open maecki-maecki opened 3 years ago
Thanks for the proposal. I'm always interested in considering ways to improve the system. Could you help me understand a bit more with an example of how and where this would be used in Mycodo?
This would allow for an asynchronous yet very low-latency communication between modules (e.g. Reactive Pattern).
Controller Broker/Bus Input Output 1
|-—-subsc. Input 1-—>| | |
| |<——subsc. for switch on messages-——|
| |<— pub. measure —| |
|<—-notify measure—-—| | |
o Calculate
|—-publish Out 1 on—>| | |
| |————-notify do switch on ———-———-—>|
No one needs polling, everyone has a messagehandler that is called when a certain condition is met (there are also patterns if mutliple input data or criteria are needed). This makes each participant rather simple in interface and also testable …
Think of every object having ‘onMessage’ Handlers like in mqtt that are called whenever something relevant for the object is happening.
This could be either tightly integrated with something like mqtt or can be achieved solely within python e.g. with RxPY or some other framework(s) …
P.S.: This would also allow a pattern that in Zigbee is called ‘binding’ that makes an input directly trigger an output without any controller e.g. for a simple switch on/off operation
example for a mqtt based event-driven architecture: https://brewblox.netlify.app/
I know it is a heavyweight task, but I guess the platform would in the long term benefit from an event-based architecture replacing the timer/pull based architecture it uses now.
Advantages I see:
Disadvantages I see:
What d‘you think?