Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configflow for the SPC integration #135894

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

imduffy15
Copy link
Contributor

@imduffy15 imduffy15 commented Jan 18, 2025

Proposed change

This change introduces https://developers.home-assistant.io/docs/config_entries_config_flow_handler/ support for the SPC integration.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@imduffy15 imduffy15 force-pushed the spc-configflow-2025 branch 8 times, most recently from edb856a to c4a99c9 Compare January 18, 2025 17:34
@imduffy15 imduffy15 marked this pull request as draft January 18, 2025 20:00
@imduffy15 imduffy15 force-pushed the spc-configflow-2025 branch 2 times, most recently from 4293174 to bd2c036 Compare January 18, 2025 20:05
@imduffy15 imduffy15 marked this pull request as ready for review January 18, 2025 20:10
homeassistant/components/spc/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/spc/alarm_control_panel.py Outdated Show resolved Hide resolved
homeassistant/components/spc/binary_sensor.py Outdated Show resolved Hide resolved
homeassistant/components/spc/binary_sensor.py Outdated Show resolved Hide resolved
homeassistant/components/spc/binary_sensor.py Show resolved Hide resolved
homeassistant/components/spc/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/spc/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/spc/config_flow.py Outdated Show resolved Hide resolved
Comment on lines 67 to 77
data_schema=vol.Schema(
{
vol.Required(CONF_API_URL): str,
vol.Required(CONF_WS_URL): str,
}
),
errors=errors,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So looking at the docs, the websocket url is just the api url with /ws/spc how does that work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its the protocol that differs, the API is http(s) the websocket is ws(s).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but I mean, can they be hosted at different places? Is the websocket URL always just the normal URL with a different protocol and path?

The question is boiling down to "why do we need 2 URLs?"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea what the original design constraint was. I do agree that we could just take "hostname" or "ip" as input and go from there, we'd have to modify the import code a little to allow for this.

Maybe best to do that as a separate change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do our due diligence to make sure there are not models or reasons why someone want to deviate? Because at this point i would also be fine with just trying to see if the URLs are different and raise a special error message for the users. (Or maybe just try using the normal URL and if that fails raise an error)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to make it smart? Just attempt the same credentials and if they fail ask for the correct ones?

I'm just trying to push a bit back to see if we can make this user friendly without having the need for users to dive into the manual

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it makes sense as part of this change, it would turn this into a breaking change, in its current state with just configflow and the import process existing users of the interaction would just seamlessly move over.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh but I think that if we're going to add a config flow, that means we get an influx of new users using the integration, so ideally I use this PR to find out what the best way is for the config flow to work.

The question if the host of the websocket URL can be different is also still unanswered.

Like, fine that we don't ask that now, but we can get that info from the existing configuration and ask from now on

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it makes for a better user experience.

We would be looking for hostname, port, optional get/put password(not supporting individual passwords for that given the pyspcwebgw project doesn't support them), and optional ws password.

We'd need to update the import code to attempt to parse the existing URLs for this information.

The paths and hostnames should always be the same as far as I can tell, unless somebody has done reverse proxy stuff in front of it for some reason, I'd imagine this is an unusual use.

We'd need to do a documentation update at https://www.home-assistant.io/integrations/spc/ as the parameters would no longer be the same.

We'd need the manufacturer to update their documentation too - they do state that authentication and encryption isn't supported but it does work 😅.

Screenshot 2025-01-25 at 18 55 30

It feels like something that should be scoped to a different PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional get/put password(not supporting individual passwords for that given the pyspcwebgw project doesn't support them), and optional ws password.

How do you mean this one?

I think it would make sense for our project to disallow reverse proxy stuff. We implement with the device, not with the reverse proxy. We also don't want to be responsible for the extra maintenance running it behind a reverse proxy comes, so I think the config flow addition (a moment which already is a breaking change) is a good moment to re review this instead of doing it one after the other and having multiple versions in a row.

Let me write down what I understand is the situation and then we can agree on a path forward

tests/components/spc/conftest.py Outdated Show resolved Hide resolved
@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant bot marked this pull request as draft January 24, 2025 11:02
@imduffy15 imduffy15 force-pushed the spc-configflow-2025 branch 7 times, most recently from 81160d6 to 26d1f6a Compare January 25, 2025 02:12
@imduffy15 imduffy15 marked this pull request as ready for review January 25, 2025 09:44
@home-assistant home-assistant bot requested a review from joostlek January 25, 2025 09:44
@imduffy15 imduffy15 force-pushed the spc-configflow-2025 branch 2 times, most recently from b062fd3 to 76ff27e Compare January 25, 2025 15:30
@imduffy15
Copy link
Contributor Author

Ugh, github auto assigned a bunch of reviewers due to a bad rebase with origin/dev, I've cleaned up the commits but don't have the permissions to drop the additional reviewers it added. Sorry for the noise 🙈

@home-assistant home-assistant bot marked this pull request as draft January 25, 2025 18:14
@imduffy15 imduffy15 force-pushed the spc-configflow-2025 branch 2 times, most recently from c441a32 to e258e0b Compare January 25, 2025 21:10
@imduffy15 imduffy15 force-pushed the spc-configflow-2025 branch from e258e0b to 0d431fb Compare January 25, 2025 21:11
@imduffy15 imduffy15 requested a review from joostlek January 25, 2025 22:25
@imduffy15 imduffy15 marked this pull request as ready for review January 25, 2025 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants