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

Refactor group setup #116317

Merged
merged 4 commits into from
Apr 28, 2024
Merged

Refactor group setup #116317

merged 4 commits into from
Apr 28, 2024

Conversation

jbouwh
Copy link
Contributor

@jbouwh jbouwh commented Apr 27, 2024

Breaking change

Changes the way entity platform domains register the group on/off states or exclusions.
This will break any custom integrations that implement the group platform and use alternative ON/OFF states, or want to exclude a custom entity platform.

Proposed change

Refactor group setup up to:

  • not use current_domain context var but let the domain to be passed as an argument
  • also pass a default on state.

This is a first step in the refactoring the group integration to allow multiple ON states to be processed correctly in mixed groups. See #116318

Add PR for blogpost: home-assistant/developers.home-assistant#2157

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

  • 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.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@jbouwh
Copy link
Contributor Author

jbouwh commented Apr 27, 2024

Note from a previous PR by @emontnemery related to mixed group support:

There's a single custom integration published in HACS - bodymiscale - which also implements mixed group support so a breaking change + blog post + notifying the author of bodymiscale should be fine.
@dckiller51 You seem to be codeowner of the custom bodymiscale HACS integration

@bdraco
Copy link
Member

bdraco commented Apr 28, 2024

I don't think we have any custom components that register group states as I would expect that its only for base components.

Someone might do it though, but I'm not sure we should support that

@jbouwh
Copy link
Contributor Author

jbouwh commented Apr 28, 2024

I don't think we have any custom components that register group states as I would expect that its only for base components.

Someone might do it though, but I'm not sure we should support that

Erik knew of one custom integration, see #116317 (comment) I mentioned the code owner, so hopefully that ping will reach him,

Added a developer blog post PR

@jbouwh jbouwh merged commit 986df70 into dev Apr 28, 2024
38 checks passed
@jbouwh jbouwh deleted the group-setup branch April 28, 2024 14:32
@dckiller51
Copy link

Note from a previous PR by @emontnemery related to mixed group support:

There's a single custom integration published in HACS - bodymiscale - which also implements mixed group support so a breaking change + blog post + notifying the author of bodymiscale should be fine.
@dckiller51 You seem to be codeowner of the custom bodymiscale HACS integration

Hello, I don't think this affects "Bodymiscale". Basically I started with the basics of the “Plant” component. In the event of a problem, we will make the necessary modifications for proper operation.

mawoka-myblock pushed a commit to SonnenladenGmbH/core that referenced this pull request Apr 28, 2024
* Refactor group setup

* Add @callback decorator and remove commented out code

* Keep set, add default on state
self.on_off_mapping: dict[str, str] = {STATE_ON: STATE_OFF}
self.off_on_mapping: dict[str, str] = {STATE_OFF: STATE_ON}
self.on_states_by_domain: dict[str, set[str]] = {}
self.exclude_domains: set[str] = set()
self.state_group_mapping: dict[str, tuple[str, str]] = {}
self.group_entities: set[Group] = set()
Copy link
Member

Choose a reason for hiding this comment

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

I missed the shared container for entities when doing the review. Its not actually used in this PR

@github-actions github-actions bot locked and limited conversation to collaborators Apr 30, 2024
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.

None yet

3 participants