Select server URL based on any Wi-Fi connection - #7372
Conversation
There was a problem hiding this comment.
Hello @adamff-dev,
When attempting to inspect the commits of your pull request for CLA signature status among all authors we encountered commit(s) which were not linked to a GitHub account, thus not allowing us to determine their status(es).
The commits that are missing a linked GitHub account are the following:
f250ece72ae5529a902cd696832ac1b7d8eb6255- No email found attached to the commit.
Unfortunately, we are unable to accept this pull request until this situation is corrected.
Here are your options:
-
If you had an email address set for the commit that simply wasn't linked to your GitHub account you can link that email now and it will retroactively apply to your commits. The simplest way to do this is to click the link to one of the above commits and look for a blue question mark in a blue circle in the top left. Hovering over that bubble will show you what email address you used. Clicking on that button will take you to your email address settings on GitHub. Just add the email address on that page and you're all set. GitHub has more information about this option in their help center.
-
If you didn't use an email address at all, it was an invalid email, or it's one you can't link to your GitHub, you will need to change the authorship information of the commit and your global Git settings so this doesn't happen again going forward. GitHub provides some great instructions on how to change your authorship information in their help center.
- If you only made a single commit you should be able to run
(substituting "Author Name" and "
git commit --amend --author="Author Name <email@address.com>"email@address.com" for your actual information) to set the authorship information. - If you made more than one commit and the commit with the missing authorship information is not the most recent one you have two options:
- You can re-create all commits missing authorship information. This is going to be the easiest solution for developers that aren't extremely confident in their Git and command line skills.
- You can use this script that GitHub provides to rewrite history. Please note: this should be used only if you are very confident in your abilities and understand its impacts.
- Whichever method you choose, I will come by to re-check the pull request once you push the fixes to this branch.
- If you only made a single commit you should be able to run
We apologize for this inconvenience, especially since it usually bites new contributors to Home Assistant. We hope you understand the need for us to protect ourselves and the great community we all have built legally. The best thing to come out of this is that you only need to fix this once and it benefits the entire Home Assistant and GitHub community.
Thanks, I look forward to checking this PR again soon! ❤️
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
f250ece to
6492238
Compare
There was a problem hiding this comment.
Pull request overview
Adds per-server support for treating any Wi‑Fi connection as internal, including persistence, connection-state logic, settings UI, migration, and tests.
Changes:
- Adds the
useAnyWifiForInternalsetting. - Updates Wi‑Fi-based URL selection and security-state handling.
- Adds Room schema migration and provider tests.
Outstanding review comments:
SsidView.kt— Moderate, 4 votes: provide switch semantics and add interaction coverage.ServerConnectionStateProviderImpl.kt— Nit, 2 votes: updateisInternaldocumentation.ServerConnectionStateProviderImpl.kt— Moderate, 3 votes: avoid requiring location when any-Wi‑Fi detection is configured.ServerConnectionInfo.kt— Nit, 3 votes: add coverage for any-Wi‑Fi-only configuration.strings.xml— Nit, 3 votes: add the user-visible setting to the changelog.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
common/src/test/kotlin/io/homeassistant/companion/android/common/data/servers/ServerConnectionStateProviderImplTest.kt |
Tests any-Wi‑Fi detection behavior. |
common/src/main/res/values/strings.xml |
Adds the setting label. |
common/src/main/kotlin/io/homeassistant/companion/android/database/server/ServerConnectionInfo.kt |
Stores and evaluates the new setting. |
common/src/main/kotlin/io/homeassistant/companion/android/database/AppDatabase.kt |
Advances the Room database version. |
common/src/main/kotlin/io/homeassistant/companion/android/common/data/servers/ServerConnectionStateProviderImpl.kt |
Applies Wi‑Fi-based internal detection. |
common/schemas/io.homeassistant.companion.android.database.AppDatabase/54.json |
Records the updated Room schema. |
app/src/main/kotlin/io/homeassistant/companion/android/settings/ssid/views/SsidView.kt |
Displays the any-Wi‑Fi toggle. |
app/src/main/kotlin/io/homeassistant/companion/android/settings/ssid/SsidViewModel.kt |
Loads and persists the setting. |
app/src/main/kotlin/io/homeassistant/companion/android/settings/ssid/SsidFragment.kt |
Connects UI callbacks to the ViewModel. |
app/src/main/kotlin/io/homeassistant/companion/android/settings/server/ServerSettingsView.kt |
Extends the home-network settings contract. |
app/src/main/kotlin/io/homeassistant/companion/android/settings/server/ServerSettingsPresenterImpl.kt |
Supplies the new configuration to the settings view. |
app/src/main/kotlin/io/homeassistant/companion/android/settings/server/ServerSettingsFragment.kt |
Displays the configured option. |
Suppressed comments (2)
app/src/main/kotlin/io/homeassistant/companion/android/settings/ssid/SsidViewModel.kt:126
- Please add a ViewModel test for this new persistence path. The provider tests cover the in-memory detection branch, but no test verifies that
setInternalWithAnyWifiwritesuseAnyWifiForInternalto the server (or that initialization reads it), so the toggle could appear to change without affecting URL selection.
fun setInternalWithAnyWifi(enabled: Boolean) {
viewModelScope.launch {
serverManager.getServer(serverId)?.let {
serverManager.updateServer(
it.copy(
common/src/main/kotlin/io/homeassistant/companion/android/common/data/servers/ServerConnectionStateProviderImpl.kt:67
- This branch short-circuits SSID detection, but enabling it leaves any previously configured
internalSsidsin the database.CheckLocationDisabledUseCase.isSsidUsed()still treats that stale list as active, so users who switch from an SSID to any-Wi-Fi detection can continue receiving a location-disabled notification even though this detection path does not need location. Please either clear the list when enabling this mode or make the location check ignore SSIDs whileuseAnyWifiForInternalis true.
return if (connection.useAnyWifiForInternal) {
wifiHelper.isUsingWifi()
} else if (connection.internalSsids.isNotEmpty()) {
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| checked = anyWifi, | ||
| onClicked = onSetAnyWifi, | ||
| ) |
| return if (connection.useAnyWifiForInternal) { | ||
| wifiHelper.isUsingWifi() |
| return if (connection.useAnyWifiForInternal) { | ||
| wifiHelper.isUsingWifi() |
| val hasHomeNetworkSetup: Boolean = useAnyWifiForInternal || | ||
| internalSsids.isNotEmpty() || |
| <string name="pref_connection_title">Connection information</string> | ||
| <string name="pref_connection_url">Home Assistant URL</string> | ||
| <string name="pref_connection_homenetwork">Home network</string> | ||
| <string name="pref_connection_use_any_wifi_for_internal">Detect any Wi-Fi connection</string> |
|
I do not believe we should add this option as it promotes insecure behavior. What issue are you trying to solve? |
793a65e to
43c0366
Compare
There was a problem hiding this comment.
Hi @adamff-dev
It seems you haven't yet signed a CLA. Please do so here.
Once you do that we will be able to review and accept this pull request.
Thanks!
Summary
This change adds support for selecting the Home Assistant server URL based on the current Wi-Fi connection.
Users can configure whether any Wi-Fi connection should be treated as an internal connection. The server settings and SSID configuration screens expose this option, and the connection state provider uses it when determining which server URL to use. The database schema was updated accordingly, with tests added for the connection state behavior.
Checklist
Select exactly one option that describes AI usage in this contribution:
Screenshots
Screenshots are not included.
Link to pull request in documentation repositories
User Documentation: home-assistant/companion.home-assistant#
Developer Documentation: home-assistant/developers.home-assistant#
Any other notes
The common module tests completed successfully. A Room database schema migration is included for the new connection setting.