Shared modbus connections #594
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Alternative to #585
(port, driver)has a connector (sunsynk driver) & lockInverterOptions.driverfield 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:
driverfield to theInverterOptionsclass, 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]AInverterclass to manage inverter connections and locks via a class-levelconnectorsdictionary, enabling safe concurrent access and dynamic connector initialization (src/ha_addon_sunsynk_multi/a_inverter.py).src/ha_addon_sunsynk_multi/driver.py).API and test updates:
AInverterto 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]src/tests/ha_addon_sunsynk_multi/test_a_inverter.py,src/tests/ha_addon_sunsynk_multi/test_driver.py). [1] [2]Script enhancements:
copy2local.cmdscript to support copying and configuring addons for local testing, reflecting changes in driver and config management (scripts/copy2local.cmd).