Skip to content

Rework CloudhookURL setup for mobile app#156940

Merged
MartinHjelmare merged 11 commits into
home-assistant:devfrom
TimoPtr:cloudhook_deletion_support
Nov 21, 2025
Merged

Rework CloudhookURL setup for mobile app#156940
MartinHjelmare merged 11 commits into
home-assistant:devfrom
TimoPtr:cloudhook_deletion_support

Conversation

@TimoPtr
Copy link
Copy Markdown
Member

@TimoPtr TimoPtr commented Nov 20, 2025

Proposed change

This PR attempts to make sure that whenever the CloudhookURL is sent to the mobile_app, the mobile_app can use it. Today the issue we have is that even when the CloudhookURL is deleted it stays in the Entry. Because of that the mobile_app continue to try to use it, causing a failure and the app to fallback to external/internal URLs.
The app cannot assume that the CloudhookURL has been removed since it might be a temporary failure, it needs to come from core that has the knowledge.

The chosen approach is to register a listener on the cloud that is triggered when the CloudhookURL is deleted so that we can remove it from the Entry too.

The CloudhookURL was also sent when the subscription was not active which makes no sense for the mobile_app because the CloudhookURL is not usable in this state.

In order to react to the disable/enable of a CloudHook I've decided to change how we set the CloudHookURL by using a listener instead of using the value created, otherwise we cannot determine when the Cloudhook is enabled back without reloading the mobile_app 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

Combining with home-assistant/android#6072 this should remove most of the error going to HA Cloud and reduce drastically the load. Since today all the users that have canceled their subscription are still making requests to HA Cloud even if they all fail. This changes is important for HA Cloud but also for our users by reducing useless queries.

Checklist

  • I understand the code I am submitting and can explain how it works.
  • 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.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

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:

@home-assistant
Copy link
Copy Markdown
Contributor

Hey there @home-assistant/cloud, mind taking a look at this pull request as it has been labeled with an integration (cloud) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of cloud can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign cloud Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@home-assistant
Copy link
Copy Markdown
Contributor

Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration (mobile_app) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of mobile_app can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign mobile_app Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@TimoPtr TimoPtr marked this pull request as ready for review November 20, 2025 20:28
@TimoPtr TimoPtr requested a review from a team as a code owner November 20, 2025 20:28
Comment thread homeassistant/components/cloud/__init__.py Outdated
Comment thread homeassistant/components/mobile_app/__init__.py Outdated
Comment thread homeassistant/components/mobile_app/__init__.py Outdated
Comment thread tests/components/cloud/test_init.py Outdated
@home-assistant home-assistant Bot marked this pull request as draft November 20, 2025 21:11
@home-assistant
Copy link
Copy Markdown
Contributor

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.

@TimoPtr TimoPtr requested a review from edenhaus November 21, 2025 09:43
Comment thread homeassistant/components/cloud/__init__.py Outdated
Comment thread homeassistant/components/cloud/__init__.py
Comment thread homeassistant/components/cloud/__init__.py Outdated
Comment thread homeassistant/components/mobile_app/__init__.py Outdated
@TimoPtr TimoPtr marked this pull request as ready for review November 21, 2025 11:50
@home-assistant home-assistant Bot requested a review from edenhaus November 21, 2025 11:50
Comment thread tests/components/mobile_app/test_init.py Outdated
Comment thread tests/components/mobile_app/test_init.py Outdated
Comment thread tests/components/mobile_app/test_init.py Outdated
Comment thread tests/components/mobile_app/test_init.py
@edenhaus edenhaus added this to the 2025.11.3 milestone Nov 21, 2025
@TimoPtr TimoPtr requested a review from edenhaus November 21, 2025 12:32
Copy link
Copy Markdown
Member

@edenhaus edenhaus left a comment

Choose a reason for hiding this comment

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

Thanks @TimoPtr 👍

Copy link
Copy Markdown
Member

@edenhaus edenhaus left a comment

Choose a reason for hiding this comment

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

The tests are failing please have a look at it

@home-assistant home-assistant Bot marked this pull request as draft November 21, 2025 12:54
Comment thread homeassistant/components/cloud/__init__.py Outdated
Comment thread homeassistant/components/cloud/__init__.py
Comment thread tests/components/mobile_app/test_init.py Outdated
@TimoPtr TimoPtr marked this pull request as ready for review November 21, 2025 14:01
@MartinHjelmare MartinHjelmare merged commit 514a329 into home-assistant:dev Nov 21, 2025
62 checks passed
@frenck frenck mentioned this pull request Nov 21, 2025
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants