Add ability to ignore heos discovery#34653
Conversation
|
Hey there @andrewsayre, mind taking a look at this pull request as its been labeled with a integration ( |
andrewsayre
left a comment
There was a problem hiding this comment.
I'm not seeing how the title of the PR matches the changes as no tests were added that confirms this behavior. Here are some things to consider:
- HEOS devices do not consistently provide a serial number through discovery or the API, so this isn't a suitable candidate for
unique_id. - You aren't supporting multiple device scenarios. A single config entry brings in all HEOS devices on the local network (whether configured manually or detected through discovery). The user selects the specific device in the
userstep. Again, using serial number (even if reliably available) is problematic as the other discovered devices will still show up will have a different serial number. - A
unique_idneeds to be set from all entry points -- not just from discovery. - Tests need to be added to show that this "ignores" discovered items.
I suggest you explore using player_id, which is available in the API to form a unique_id. You will also need to keep track of all the player IDs to check against in multi-device scenarios.
184244a to
ffc8406
Compare
|
CI is currently broken due to unrelated issue |
ffc8406 to
6a4253c
Compare
There was a problem hiding this comment.
The referenced arch issue helped me understand what is trying to be accomplished. Good/bad news: I think this can be greatly simplified. Since HEOS only supports a single config entry, we can simply set a static unique ID on the entry. Let's just set it to the DOMAIN constant and update the existing test to validate it's being set and make sure we handle setting the unique ID in all cases:
- Call
await self.async_set_unique_id(DOMAIN)fromasync_step_ssdp,async_step_import, andasync_step_user - Update existing entries as the first code in
async_setup_entry:
# For backwards compat
if entry.unique_id is None:
hass.config_entries.async_update_entry(
entry, unique_id=DOMAIN
) Sorry for sending you on a wild goose chase!
|
Will come back to this as soon as I can. I've been focused on the CI failures which are now fixed (I hope) |
dcc9ebf to
84a30c3
Compare
0c18bc5 to
c6cfcb5
Compare
* Add ability to ignore heos discovery * Fetch player_id, update tests * Handle failure state * Update tests as there are two players in the mock now * Adjust and add more tests * Strip out player id lookup * reverts per review * one more revert
Proposed change
Add ability to ignore heos discovery
Type of change
Example entry for
configuration.yaml:# Example configuration.yamlAdditional information
Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.The integration reached or maintains the following Integration Quality Scale: