kbialek / deye-inverter-mqtt

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

Add verification of the DeyePlugin class before instantiating the plugin #172

Closed CarstenGrohmann closed 5 months ago

CarstenGrohmann commented 6 months ago

I'm developing a new plugin for deye-inverter-mqtt. Today I started deye-inverter-mqtt to test my plugin.

After that, I got this error message:

File "deye-inverter-mqtt/src/deye_daemon.py", line 76, in __init__
    self.__processor_factory = DeyeProcessorFactory(self.__config, self.__mqtt_client)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "deye-inverter-mqtt/src/deye_processor_factory.py", line 41, in __init__
     self.plugin_loader.load_plugins(plugin_context)
File "deye-inverter-mqtt/src/deye_plugin_loader.py", line 55, in load_plugins
    self.__plugins.append(plugin_module.DeyePlugin(plugin_context))
                          ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'deye_plugin_ha_discovery' has no attribute 'DeyePlugin'. Did you mean: 'DeyePluginDisabled'?

The error is triggered as the class DeyePlugin was temporarily renamed to prevent an automatic start of the new plugin.

What do you think about adding a check for the class DeyePlugin and only activate the plugin if DeyePlugin exists. Otherwise the plugin should be ignored with a warning message.

Thank you, Carsten