-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
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 config flow to Yamaha #131246
base: dev
Are you sure you want to change the base?
Add config flow to Yamaha #131246
Conversation
As discussed in #130820 this is a first attempt to add a config flow to the Yamaha integration. As this was a first attempt at this and for people that are stumbling on this in the future, it's a mix of https://github.com/home-assistant/core/pull/51561/files and the current state of the I've removed references to I still have 2 unit tests marked as ignore in which I need your help to understand if they can be removed.
Hope this is more or less adequate for a first attempt :-) |
The CI is failing |
Yes sorry about that, it seems my dev environment is not running the git pre commit hooks, i'll fix this as soon as possible! |
FYI, you don't have to add the issue to the commit message. If you want to do so, feel free to do so, but you're not required to :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial comments to steer into the right direction
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The config flow itself seems not quite finished at the moment, so I have not reviewed it.
Instead couple of pointers for some other stuff.
* Realign code with yamaha_musiccast and store UPNP Description instead of model and name * Reuse rxv.ssdp.rxv_details for querying the rxv data instead of querying from HA code
…add discovery when configuration yaml has no host, add issues (taken from onkyo integration)
I hope this is moving in the right direction, so I've requested another review. |
…age for issue creation
…age for issue creation
…out SSDP and serials
if entry.data.get(CONF_UPNP_DESC) is None: | ||
hass.config_entries.async_update_entry( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this work?
Like I am known with the technique to do this in the config flow discovery step, so for example when someone setup the integration using the host and then we find either a zeroconf or DHCP flow that we can link to it (for example if the entry uses the same host and is loaded) and then we update the entry to have that unique identifier. Examples of this are fritzbox
and reolink
, both do this in the DHCP step I believe.
From my understanding this does the same, but I am wondering how the order of discovery works, because if the integration is setup and after that the SSDP picks up the advertisement, this code is not run anymore.
So I am not really sure what is best here, but I do want to share this info with you to at stir up the discussion.
CONF_HOST: entry.data[CONF_HOST], | ||
CONF_SERIAL: entry.data[CONF_SERIAL], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CONF_HOST: entry.data[CONF_HOST], | |
CONF_SERIAL: entry.data[CONF_SERIAL], | |
**entry.data, |
}, | ||
) | ||
|
||
hass.data.setdefault(DOMAIN, {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're storing nothing here so this line can be removed
rxv_details = await YamahaConfigInfo.get_rxv_details( | ||
entry.data[CONF_UPNP_DESC], hass | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So our code relies on having that info, but why do we then only set the upnp description during initialisation and why not during the config (or import) flow?
return upnp_desc | ||
|
||
|
||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use a typed ConfigEntry here, see more at https://developers.home-assistant.io/docs/core/integration-quality-scale/rules/runtime-data
|
||
return await self.async_step_confirm() | ||
|
||
async def async_step_confirm(self, user_input=None) -> ConfigFlowResult: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing typing
OPTION_INPUT_SOURCES_IGNORE: user_input.get( | ||
OPTION_INPUT_SOURCES_IGNORE | ||
) | ||
or [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's wrap these multiline statements in parenthesis
async def async_step_import(self, import_data: dict) -> ConfigFlowResult: | ||
"""Import data from configuration.yaml into the config flow.""" | ||
return await self.async_step_user(import_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While for the user flow we want to raise errors, for the import flow we should abort when an error happens.
Also, typing is missing
…class to utils, reverted self._attr_unique_id change in media_player
Breaking change
Proposed change
Type of change
Additional information
Checklist
ruff format 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
.To help with the load of incoming pull requests: