-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
if serial_number is None: | ||
errors["base"] = "no_yamaha_device" |
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.
Are there devices without serial number?
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.
I am unsure, I did assume there was going to be. I was doubting to add CONF_HOST
as fallback as the unique_id but that would not accepted I read?
How should I move forward with this?
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.
I'm gonna leave this for now, the implementation is the same as the Yamaha Musiccast integration now. I found some SSDP replies through github (https://github.com/foxthefox/yamaha-yxc-nodejs/blob/da9039e3edb1cc338b6f5c19710bbbfb6770b428/lib/data/ssdp_answer_WX30.xml#L17 and https://github.com/foxthefox/yamaha-yxc-nodejs/blob/da9039e3edb1cc338b6f5c19710bbbfb6770b428/lib/data/ssdp_answer_YSP1600.xml#L17).
As well as my RX-A2010
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.
@joostlek @slyoldfox yes from my experience there seem to be ssdp responses without serial in the wild, and the rxv lib doesn't support /cant get the serial post ssdp.
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.
config_entry: ConfigEntry, | ||
) -> OptionsFlow: | ||
"""Return the options flow.""" | ||
return YamahaOptionsFlowHandler(config_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.
Config flow.py is required to be 100% unit tested
if config.get(CONF_HOST): | ||
if hass.config_entries.async_entries(DOMAIN) and config[CONF_HOST] not in [ | ||
entry.data[CONF_HOST] for entry in hass.config_entries.async_entries(DOMAIN) | ||
]: | ||
_LOGGER.error( | ||
"Configuration in configuration.yaml is not supported anymore. " | ||
"Please add this device using the config flow: %s", | ||
config[CONF_HOST], |
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.
We should raise issues instead. Check the smarty
integration for an example. (but keep the YAML entrypoint the same)
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.
Also IMO better to let it go to the config flow and abort there instead of checking here.
OPTION_INPUT_SOURCES_IGNORE: user_input.get( | ||
OPTION_INPUT_SOURCES_IGNORE | ||
), |
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.
For the ignore one, I believe there is a way on the device to limit the sources, can explore that option?
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.
I checked my receiver (RX-A2010) but didn't find a way to ignore inputs.
I can rename inputs on the device but even those modified names do not get propagated outside the unit, the output of rxv.inputs()
stays the same.
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.
Same here not on my device (RX2020) there is no functionality to support it in the rxv lib.
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.
It also isn't supported by the integration in HACS via the device and that uses a different protocol / method than rxv.
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.
if config.get(CONF_HOST): | ||
if hass.config_entries.async_entries(DOMAIN) and config[CONF_HOST] not in [ | ||
entry.data[CONF_HOST] for entry in hass.config_entries.async_entries(DOMAIN) | ||
]: | ||
_LOGGER.error( | ||
"Configuration in configuration.yaml is not supported anymore. " | ||
"Please add this device using the config flow: %s", | ||
config[CONF_HOST], |
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.
Also IMO better to let it go to the config flow and abort there instead of checking here.
) | ||
) | ||
else: | ||
_LOGGER.error( |
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.
Start a discovery instead and for each discovered receiver launch an import flow.
* 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. |
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: