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

Add suggested_area to MQTT discovery #47903

Merged
merged 7 commits into from
Mar 15, 2021

Conversation

RadekHvizdos
Copy link
Contributor

@RadekHvizdos RadekHvizdos commented Mar 14, 2021

Proposed change

This adds suggested_area to MQTT discovery, so that the discovered devices could be automatically added to the proper area.

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

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

This adds suggested_area to MQTT discovery, so that the discovered devices could be automatically added to the proper area.
@homeassistant
Copy link
Contributor

Hi @RadekHvizdos,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@probot-home-assistant
Copy link

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

@PeteBa
Copy link
Contributor

PeteBa commented Mar 14, 2021

I really like this PR - maybe this suggestion is for a different PR - but I notice that entities can also be assigned to areas. They default to the area of the device but they can also be specifically assigned to a differnt area. Is assigning entity areas something that could be supported via mqtt discovery as well?

@@ -582,6 +582,7 @@ async def test_entity_device_info_with_hub(hass, mqtt_mock):
identifiers={("mqtt", "hub-id")},
manufacturer="manufacturer",
model="hub",
suggested_area="default_area",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
suggested_area="default_area",

Remove this. Instead, add it to DEFAULT_CONFIG_DEVICE_INFO_ID and DEFAULT_CONFIG_DEVICE_INFO_MAC, and update test helpers help_test_entity_device_info_with_identifier + help_test_entity_device_info_with_connection to make sure it works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion, the tests were adjusted accordingly.

Changes made as per feedback from @emontnemery
@emontnemery
Copy link
Contributor

@PeteBa No, that's not possible as there's no concept of suggested_area for entities.

@emontnemery
Copy link
Contributor

Thanks, @RadekHvizdos for a solid 1st PR 👍

@emontnemery emontnemery changed the title Add MQTT discovery suggested_area Add suggested_area to MQTT discovery Mar 15, 2021
@emontnemery emontnemery merged commit 9f4c2f6 into home-assistant:dev Mar 15, 2021
@RadekHvizdos RadekHvizdos deleted the mqtt_suggested_area branch March 15, 2021 22:15
@github-actions github-actions bot locked and limited conversation to collaborators Mar 16, 2021
@RadekHvizdos RadekHvizdos restored the mqtt_suggested_area branch July 14, 2021 08:12
@RadekHvizdos RadekHvizdos deleted the mqtt_suggested_area branch July 14, 2021 08:32
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.

4 participants