Add GUI configuration#369
Open
danelphick wants to merge 11 commits into
Open
Conversation
Adds a UI-driven config flow as an alternative to YAML configuration. The flow is split into two steps: API key entry (with validation against the FoxESS API) and device/inverter selection. Bogus credentials and non-JSON API responses are handled gracefully, and auth failures are detected correctly. Adds a reauthentication flow so users can rotate their API key without removing and re-adding the integration. Adds a full test suite covering the happy path, invalid credentials, network errors, and the reauth flow.
The test action will run on push and pull_request actions.
Replace the HA-core-embedded test setup with a standalone approach using pytest-homeassistant-custom-component. Add pyproject.toml and requirements_test.txt, update CI to install from the requirements file, and simplify conftest/imports to use the package directly.
…rror - Replace _abort_if_unique_id_configured() with an inline check so duplicate-device errors appear as a field error on deviceSN, matching the existing name-collision behaviour - Use add_suggested_values_to_schema in both steps so previously entered values are restored when the form is re-shown after an error - Update tests: rename test, add suggested-value assertions, use MOCK_TWO_DEVICES (selecting the second device) to verify the selector does not revert to the first option, remove redundant test_device_id_set_to_device_sn
Creates FetchResult enum to return values from fetch functions instead of returning a mixture of booleans and error numbers.
Changes config_flow to use GetAuth from sensor.py instead of its own version of the same code.
Import constants from sensor.py instead of recreating them in config_flow.py.
async_setup_platform now stores the device SN and name in hass.data so the config flow can detect conflicts with YAML-configured devices. Previously, _async_current_entries() only returned config entries, so a device declared in YAML was invisible to the duplicate-SN and duplicate-name checks, allowing a second entry to be created silently. When a collision originates from a YAML-configured entry, distinct error messages are shown (yaml_device_already_configured / yaml_name_already_in_use) so the user knows to remove the device from configuration.yaml.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This adds a 2 page configuration UI for inverters, where the first page asks for the API key and uses that to fetch the list of devices which can then be selected on the second page. It doesn't remove YAML configuration which should continue to work as before.
I've also added extensive tests for the UI as well as adding automatic testing for pushes and pull requests on github.
Full disclosure: I'm using this project as an excuse to learn Claude Code, which generated nearly all of this. I've reviewed the code myself and tested it locally, but only have one inverter so can't test every feature in production.