lumapu / ahoy

Various tools, examples, and documentation for communicating with Hoymiles microinverters
https://ahoydtu.de
Other
953 stars 224 forks source link

Feature Request: Interface for thirdparty apps #410

Open womoak75 opened 1 year ago

womoak75 commented 1 year ago

An interface which allows easy integration of additional user applications into a custom Ahoi build would be a nice feature.

Unfortunately my knowledge of C++ is very 'minimalistic' (java ist my favourite), but i tried my very best to provide a simple example. https://github.com/lumapu/ahoy/compare/main...womoak75:ahoy:main

pros cons
minimal impact on existing code base no 'nice' sw design
esp8862/esp32 is in idle mode most of the time anyway
minimize merge effort on future custom builds

please feel free to agree/disagree or add additional topics.

stefan123t commented 1 year ago

@womoak75 this looks like a example template for building and adding custom plugins into the AhoyDTU. Thanks, let us see who will make use of this blueprint for whatever app-plugin they want to provide for AhoyDTU. Did you already have a specific purpose in mind ?

womoak75 commented 1 year ago

Yes, i do. Want to connect my power meter and implement some "Nulleinspeisung".

I also added a mqtt callback to my example, to enable input/control data for a thirdparty app. e.g. publishing to topic 'inverter/thirdparty/{data}' which will be ignored by the ahoi app. Should be sufficient for a simple start and enables user to add their own code, without "hacking" into the ahoi code base.

A more sophisticated approach would be adding hooks for all major functions (configuration, web, api, etc.), but 'a journey of a thousand miles begins with a single step'

If desired, I could add a pull request for simplicity reasons. :)

stefan123t commented 1 year ago

@womoak75 could you add a #define to disable your plugin by default and some example in example_overwrite_config.h before you PR. @lumapu did you take a quick look at this sample plugin or should @womoak75 wait with his PR till you have refactored a couple of things which you are busy with ?

womoak75 commented 1 year ago

Will add a PR at your request.

lumapu commented 1 year ago

@stefan123t will do

womoak75 commented 1 year ago

also tried to add web / webApi / gui support

stefan123t commented 1 year ago

A possible example scenario for this plugin adapter could be the Thingspeak integration in #185 or the Prometheus support in #190 and PR #356 Maybe the Azure IOT Cloud OAuth also could qualify for such a flexible plugin approach ?

womoak75 commented 1 year ago

@stefan123t Maybe, but i am not familiar with the requirements.

Would suggest to merge my proposal and let the guys find out if its suitable or not. 'try and error', a frequently used developer approach. :)

Whats still missing, but probably necessary for "plugins", is configuration load/store functionality. I took a look at the relevant code but couldn't figure out how to implement it in a simple way. So i decided my application will use its own storage.

I would also recommend to refactor the GUI. Wouldn't it be much easier concerning maintenance and extension, if there's only one html main page and content loading is done by js? Menu bar entries are loaded via js already.

womoak75 commented 1 year ago

https://github.com/lumapu/ahoy/compare/main...womoak75:ahoy:plugins https://github.com/lumapu/ahoy/compare/main...womoak75:ahoy:devel plugin hacker version v0.0.1 :)

stefan123t commented 1 week ago

@lumapu können wir das als Beispiel für ein Plugin aktzeptieren und mergen ? @womoak75 hat einiges an Doku geschrieben und man müsste mal prüfen ob es noch aktuell / mergebar ist ?