kbialek / deye-inverter-mqtt

Reads Deye solar inverter metrics and posts them over MQTT
Apache License 2.0
230 stars 50 forks source link

Public access to MQTT client functions #176

Closed CarstenGrohmann closed 5 months ago

CarstenGrohmann commented 5 months ago

Hello!

I am writing a simple plugin to publish all values to Home Assistant.

Currently I am using the MQTT client from DeyePluginContext.mqtt_client. Unfortunately, the client does not have a public function to publish a message to MQTT.

Therefore, I am currently “abusing” the protected function __do_publish():

self._mqtt_client = plugin_context.mqtt_client
self._mqtt_client._DeyeMqttClient__do_publish(topic, payload)

I prefer to use the existing connection. What do you think about adding public functions for publishing and subscribing to the DeyeMqttClient class? Or do you prefer to instantiate a separate MQTT client for the plugin?

Would you exclude a PR to integrate the plugin into your repo or do you prefer adding it to your own repo?

Kind regards, Carsten

kbialek commented 5 months ago

What do you think about adding public functions for publishing and subscribing to the DeyeMqttClient class?

Fair point. The method should be public. I will change that.

Or do you prefer to instantiate a separate MQTT client for the plugin?

It's up to the plugin implementer which connection to use, but the service connection should definitely be usable by the plugin. That is the reason why I made it available.

Would you exclude a PR to integrate the plugin into your repo or do you prefer adding it to your own repo?

The plugin has its own lifecycle, that's independent of this tool. Thus, please keep the plugin in your own repo. I can link it in the readme file if you want.