Skip to content

Conversation

@jbouwh
Copy link
Contributor

@jbouwh jbouwh commented Mar 10, 2022

Proposed change

  • Move the discovery updater code for tag and device trigger to Mixins and make it an inheritable class.
  • Use async_removed_from_device to filter the correct event to remove a device.
  • Add a test for publishing an empty payload after device removal to align with the tag platform.
  • deduplicate code for discovery in mixins.py

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

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

@frenck frenck added the smash Indicator this PR is close to finish for merging or closing label Mar 11, 2022
@jbouwh jbouwh changed the title Mqtt notify correct setup Mqtt notify correct setup and rework discovery Mar 12, 2022
@jbouwh jbouwh mentioned this pull request Mar 12, 2022
22 tasks
@jbouwh jbouwh changed the title Mqtt notify correct setup and rework discovery Mqtt correct setup notify and rework discovery Mar 12, 2022
@jbouwh jbouwh force-pushed the mqtt-notify-correct-setup branch 4 times, most recently from 763e2fd to 0b97afc Compare March 13, 2022 15:22
@jbouwh jbouwh force-pushed the mqtt-notify-correct-setup branch from 61eca2b to 8dc9fc8 Compare March 15, 2022 00:19
@jbouwh jbouwh requested a review from a team as a code owner March 19, 2022 14:48
@jbouwh jbouwh mentioned this pull request Mar 21, 2022
22 tasks
@jbouwh jbouwh marked this pull request as draft March 22, 2022 09:38
@jbouwh jbouwh changed the title Mqtt correct setup notify and rework discovery Mqtt rework discovery for non-entity platforms Mar 22, 2022
@jbouwh jbouwh force-pushed the mqtt-notify-correct-setup branch 2 times, most recently from b9d1ee8 to cfb93b0 Compare April 1, 2022 18:11
@jbouwh jbouwh changed the title Mqtt rework discovery for non-entity platforms Refactor MQTT discovery Apr 6, 2022
@jbouwh jbouwh force-pushed the mqtt-notify-correct-setup branch from 337fb99 to aaee2f7 Compare April 7, 2022 12:34
@jbouwh jbouwh marked this pull request as ready for review April 7, 2022 12:35
@jbouwh jbouwh requested a review from MartinHjelmare April 8, 2022 06:30
Comment on lines 643 to 644
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is not done, when does the loop of device registry updates happen?

Copy link
Contributor Author

@jbouwh jbouwh Apr 14, 2022

Choose a reason for hiding this comment

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

Updated the comment to # Prevent a second cleanup round after the device is removed. Normally the device is cleaned up after an empty discovery payload. If the device is removed, all linked services are removed, that might cause multiple events. Only the first should trigger a cleanup.

@jbouwh jbouwh force-pushed the mqtt-notify-correct-setup branch from 31b86bd to 0975aad Compare April 15, 2022 06:51
@jbouwh jbouwh closed this Apr 15, 2022
@jbouwh jbouwh reopened this Apr 15, 2022
Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

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

Thanks a lot @jbouwh 👍

@emontnemery emontnemery merged commit 3b2aae5 into home-assistant:dev Apr 15, 2022
@jbouwh jbouwh deleted the mqtt-notify-correct-setup branch April 15, 2022 10:35
@github-actions github-actions bot locked and limited conversation to collaborators Apr 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed code-quality core integration: mqtt smash Indicator this PR is close to finish for merging or closing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants