Skip to content

Add details to Husqvarna Automower restricted reason sensor #147678

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

Open
wants to merge 11 commits into
base: dev
Choose a base branch
from

Conversation

Thomas55555
Copy link
Contributor

Proposed change

If the mower is restricted in mowing it can have different reasons, one of them is called external. For example IFTT can prevent the mower from mowing, if the user build an condition for that. With this PR we give the user more information, if available.

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:
  • Link to developer documentation pull request:
  • Link to frontend 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:

@Thomas55555 Thomas55555 changed the title External reason Add external reason to Husqvarna Automower restricted reason sensor Jun 27, 2025
@Thomas55555 Thomas55555 changed the title Add external reason to Husqvarna Automower restricted reason sensor Add details to Husqvarna Automower restricted reason sensor Jun 27, 2025
@frenck frenck requested a review from Copilot June 27, 2025 15:22
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the restricted‐reason sensor to surface detailed external reasons when the mower is externally blocked.

  • Imported and integrated ExternalReasons into the restricted‐reason sensor.
  • Added a _get_restricted_reason callback to return external_reason when present.
  • Updated tests, snapshots, and translation strings to cover all new external reasons.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/components/husqvarna_automower/test_sensor.py Added test_restricted_reason_sensor for external reason logic.
tests/components/husqvarna_automower/snapshots/test_sensor.ambr Expanded snapshots to include new ExternalReasons members.
homeassistant/components/husqvarna_automower/strings.json Added translation strings for all external reasons.
homeassistant/components/husqvarna_automower/sensor.py Imported ExternalReasons, updated RESTRICTED_REASONS, and added _get_restricted_reason.
Comments suppressed due to low confidence (2)

tests/components/husqvarna_automower/test_sensor.py:139

  • [nitpick] The docstring mentions the work area sensor but this test covers the restricted‐reason sensor. Please update it to accurately describe the restricted‐reason test.
    """Test the work area sensor."""

homeassistant/components/husqvarna_automower/sensor.py:190

  • [nitpick] This list now includes external reasons as well as restricted ones. Renaming RESTRICTED_REASONS to something like RESTRICTION_OPTIONS or REASON_OPTIONS would more clearly convey its merged purpose.
    RestrictedReasons.NONE,

@@ -191,11 +192,34 @@
RestrictedReasons.PARK_OVERRIDE,
RestrictedReasons.SENSOR,
RestrictedReasons.WEEK_SCHEDULE,
ExternalReasons.AMAZON_ALEXA,
Copy link
Preview

Copilot AI Jun 27, 2025

Choose a reason for hiding this comment

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

[nitpick] Manually listing each ExternalReasons value risks falling out of sync if new reasons are added. Consider generating the list dynamically from the enum (e.g., list(ExternalReasons)).

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But if they are not manually listed and the library gets more new reasons, we might just bump the library and forget to update strings.json. So we have no translations for them.

Comment on lines 250 to 256
"iftt": "IFTT",
"iftt_wildlife": "IFTT Wildlife",
"iftt_frost_and_rain": "IFTT Frost and Rain",
"iftt_calendar_connection": "IFTT Calendar Connection",
"gardena_smart_system": "Gardena Smart System",
"iftt_applets": "IFTT Applets",
"developer_portal": "Developer Portal"
Copy link
Contributor

@NoRi2909 NoRi2909 Jun 27, 2025

Choose a reason for hiding this comment

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

Are those about https://ifttt.com/automower ?

Then it looks like we need one more "T" in "IFTTT"

Also words that can be translated should be lowercase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

@Thomas55555 Thomas55555 marked this pull request as draft June 27, 2025 17:18
@Thomas55555 Thomas55555 marked this pull request as ready for review June 27, 2025 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants