zewelor / bt-mqtt-gateway

A simple Python script which provides a Bluetooth to MQTT gateway, easily extensible via custom workers. See https://github.com/zewelor/bt-mqtt-gateway/wiki for more information.
MIT License
548 stars 116 forks source link

Support middleware #202

Closed lwestenberg closed 1 year ago

lwestenberg commented 3 years ago

Is your feature request related to a problem? Please describe. I made the first Home Assistant specific worker a while ago and when making a PR for the lywsd03mmc I read the code again and I think we can do better.

Describe the solution you'd like Split up the worker and the home assistant part by having middleware between worker and mqtt. E.g. we can create a folder middleware where you add lywsd03mmc_homeassistant.py or lywsd03mmc_whatever.py and create the formatted mqtt messages (also for e.g. auto discovery) there.

Describe alternatives you've considered None

Additional context Not applicable

zewelor commented 3 years ago

I like concept of middlewares, it would be great for sure to split workers code with HA presentation etc. Also to dry up workers a bit.