The Wayback Machine - https://web.archive.org/web/20220322020835/https://github.com/home-assistant/core/pull/68473
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

Track number of persons in a Zone #68473

Merged
merged 7 commits into from Mar 21, 2022
Merged

Track number of persons in a Zone #68473

merged 7 commits into from Mar 21, 2022

Conversation

frenck
Copy link
Member

@frenck frenck commented Mar 21, 2022

Proposed change

This reverts the revert #65344

Implements state of a Zone, based on the state of persons. Instead of the previous approach (that used object IDs and coordinates), this approach only relies on the actual state of person (and thus the device tracker) entity.

  • If the current zone object ID matches the home zone, we accept home for the zone. This makes device_trackers like ping work when tied to a person (without providing a coordinate)
  • If the current state is not_home, we ignore the state of the person. We don't know where they are.
  • If the name of a zone is found in a person's state, the person is in the zone.

⚠️ The triggers of zones are based on coordinates, this behavior has not been changed and is still working as before.

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)
  • 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:

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
  • The code has been formatted using Black (black --fast 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.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@probot-home-assistant
Copy link

@probot-home-assistant probot-home-assistant bot commented Mar 21, 2022

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

@project-bot project-bot bot added this to Needs review in Dev Mar 21, 2022
for person in persons:
state = self.hass.states.get(person)
if (
state
Copy link
Member

@balloob balloob Mar 21, 2022

Choose a reason for hiding this comment

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

This is guaranteed because it is returned by hass.states.async_entity_ids()

Copy link
Member Author

@frenck frenck Mar 21, 2022

Choose a reason for hiding this comment

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

sure, but typing requires us to check it, as get() can return None.

Dev automation moved this from Needs review to Reviewer approved Mar 21, 2022
Copy link
Member

@balloob balloob left a comment

🎉

@balloob balloob merged commit 28d3117 into dev Mar 21, 2022
32 checks passed
Dev automation moved this from Reviewer approved to Done Mar 21, 2022
@balloob balloob deleted the frenck-2022-0693 branch Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Dev
  
Done
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants