Skip to content

Conversation

@kellerza
Copy link
Owner

Alternative to #585

  • Add shared Modbus connections
  • Each unique (port, driver) has a connector (sunsynk driver) & lock
  • Locking on all AInverter I/O methods
  • The new InverterOptions.driver field is optional, with the aim to be backward compatible (uses Options.driver as default)

cc: @maslyankov

Copilot

This pull request introduces significant improvements to the inverter driver architecture, enabling per-inverter driver selection and connection management. The main changes include adding support for specifying a driver per inverter, refactoring the connector and locking logic to ensure safe concurrent access, and updating the initialization process to use these new mechanisms. Several tests and scripts were also updated to reflect these changes.

Driver and connection management improvements:

  • Added a driver field to the InverterOptions class, allowing each inverter to specify its own driver type, and updated the configuration schema to support this new option (src/ha_addon_sunsynk_multi/options.py, hass-addon-sunsynk-edge/config.yaml). [1] [2]
  • Refactored the AInverter class to manage inverter connections and locks via a class-level connectors dictionary, enabling safe concurrent access and dynamic connector initialization (src/ha_addon_sunsynk_multi/a_inverter.py).
  • Updated the driver initialization logic to use per-inverter driver settings, removed direct assignment of inverter instances, and utilized the new connector management approach (src/ha_addon_sunsynk_multi/driver.py).

API and test updates:

  • Modified sensor read/write methods in AInverter to use the new locking mechanism and connector access, and updated sensor callback logic to call the new write method (src/ha_addon_sunsynk_multi/a_inverter.py, src/ha_addon_sunsynk_multi/sensor_callback.py). [1] [2]
  • Updated tests to use the new connector management and per-inverter options, ensuring compatibility with the refactored architecture (src/tests/ha_addon_sunsynk_multi/test_a_inverter.py, src/tests/ha_addon_sunsynk_multi/test_driver.py). [1] [2]

Script enhancements:

  • Improved the copy2local.cmd script to support copying and configuring addons for local testing, reflecting changes in driver and config management (scripts/copy2local.cmd).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant