Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@wollew
Copy link
Contributor

@wollew wollew commented Oct 14, 2025

Breaking change

Proposed change

Squeezebox players have multiple information on their alarm status: if an alarm is upcoming within the next 24 hours, if an alarm is currently active or if an alarm is currently in snooze status. This PR adds a binary sensor to players for each of these, which can be useful in automations. There is also information about the time of the next alarm, but in order to keep PRs minimal and this will be a change to the sensor platform, I'll create a separate PR for that.

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

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

Hey there @rajlaud, @pssc, @peteS-UK, mind taking a look at this pull request as it has been labeled with an integration (squeezebox) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of squeezebox 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 squeezebox 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.

Copy link
Contributor

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 adds binary sensors to the Squeezebox integration to track player alarm statuses. It introduces three new binary sensors for each player that indicate if an alarm is upcoming within 24 hours, currently active, or in snooze mode.

Key changes:

  • Adds three new player-specific binary sensors for alarm states (upcoming, active, snoozed)
  • Extends the binary sensor platform to support both server and player entities
  • Updates test coverage for the new binary sensor functionality

Reviewed Changes

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

Show a summary per file
File Description
homeassistant/components/squeezebox/binary_sensor.py Implements new player alarm binary sensors and refactors to support both server and player entities
homeassistant/components/squeezebox/const.py Adds constants for the three new alarm sensor types
homeassistant/components/squeezebox/strings.json Adds localization strings for the new alarm sensors
tests/components/squeezebox/test_binary_sensor.py Adds comprehensive test coverage for player alarm binary sensors
tests/components/squeezebox/conftest.py Updates mock player fixture with default alarm state properties
tests/components/squeezebox/test_switch.py Fixes docstring comment that was incorrectly referring to media_player platform

@wollew
Copy link
Contributor Author

wollew commented Oct 14, 2025

Reviewers: let me know if this is something that would generally be functionality that makes sense in your opinion, if so I'll prepare the second PR for the alarm time sensor and the docs PRs.

Copy link
Contributor

@kennedyshead kennedyshead left a comment

Choose a reason for hiding this comment

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

It feels like you cloud split the discovery and the actual alarm into 2 PR:s?

"homeassistant.components.squeezebox.Server.async_query",
return_value=deepcopy(FAKE_QUERY_RESPONSE),
),
with patch(
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this not be a fixture?



@pytest.fixture
async def mock_player(
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe move to conftest?

@peteS-UK
Copy link
Contributor

As a general comment on the testing, I have a PR at #153032 to rewrite a number of the common patches as fixtures, including mock_async_query, which might be useful here once that PR has been merged (as part of the quality scale work we're doing with joostlek). We've also rewritten all of test_config_flow to use these fixtures in that PR and moved to paramaterise the testing for reference.

@peteS-UK
Copy link
Contributor

Reviewers: let me know if this is something that would generally be functionality that makes sense in your opinion, if so I'll prepare the second PR for the alarm time sensor and the docs PRs.

I don't use alarms a great deal, so not sure of the general usage, but extending the platform in this way doesn't seem a problem to me. @rajlaud might have a view on the alarm usage.

@wollew
Copy link
Contributor Author

wollew commented Oct 15, 2025

As a general comment on the testing, I have a PR at #153032 to rewrite a number of the common patches as fixtures, including mock_async_query, which might be useful here once that PR has been merged (as part of the quality scale work we're doing with joostlek). We've also rewritten all of test_config_flow to use these fixtures in that PR and moved to paramaterise the testing for reference.

So I would either rework these tests if #153032 is merged first or otherwise open a separate PR to fix them if this one goes first.

@wollew
Copy link
Contributor Author

wollew commented Oct 15, 2025

It feels like you cloud split the discovery and the actual alarm into 2 PR:s?

I don't know, just adding the first part without adding the binary sensors would have added basically unused code (imagine the second part never being merged), I did not like that idea.

@kennedyshead
Copy link
Contributor

It feels like you cloud split the discovery and the actual alarm into 2 PR:s?

I don't know, just adding the first part without adding the binary sensors would have added basically unused code (imagine the second part never being merged), I did not like that idea.

Can see your point, in a way. But there are 2 different features IMO

@wollew
Copy link
Contributor Author

wollew commented Oct 15, 2025

It feels like you cloud split the discovery and the actual alarm into 2 PR:s?

I don't know, just adding the first part without adding the binary sensors would have added basically unused code (imagine the second part never being merged), I did not like that idea.

Can see your point, in a way. But there are 2 different features IMO

I also see what you mean. The dicovery by itself is a "code feature", both things together make an actual HA feature.

@MartinHjelmare MartinHjelmare changed the title add binary sensors for player alarm status Add Squeezebox binary sensors for player alarm status Oct 27, 2025
@home-assistant home-assistant bot marked this pull request as draft October 27, 2025 14:53
@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.

@MartinHjelmare
Copy link
Member

We don't want to add dead code. Since the discovery is needed to add the new entities the discovery should be in this PR.

@wollew wollew marked this pull request as ready for review October 27, 2025 16:10
@MartinHjelmare
Copy link
Member

Please merge dev branch into your feature branch and solve the merge conflict. We recently added required sorting 🔡 of all translation strings in strings.json.

@MartinHjelmare MartinHjelmare marked this pull request as draft November 3, 2025 16:26
@wollew wollew marked this pull request as ready for review November 3, 2025 16:50
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.

4 participants