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
Allow 'Discovered' flows to have title placeholders #3106
Conversation
The code starting a config flow should not be aware of what it is discovering, nor be aware what keys to set in the context. I think that indeed it should be dealt with by setting something during |
And it's actually a great idea for a lot of other discoveries too. |
@@ -190,6 +190,23 @@ class HaConfigManagerDashboard extends LocalizeMixin( | |||
return localize(`component.${integration}.config.title`); | |||
} | |||
|
|||
_computeActiveFlowTitle(localize, integration) { | |||
const placeholders = integration.context.placeholders || {}; |
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.
Can we call it title_placeholders
Requested change made. On the HA server side i'm currently doing something like this inside
And in my strings:
This works but it's throwing pylint off:
I could suppress it but I don't really know why it thinks this is a problem. |
I think it's because of the type of context. You can disable pylint check |
This PR is a bit of a proof of concept and more about starting a conversation than anything else.
When I switch homekit_controller over to Config Entries (hopefully in 0.94) even though i know the name and model of the device there doesn't seem to be a mechanism to surface that in the 'Discovered' part of the Integrations panel. Instead I just see the localisation for
component.homekit_controller.config.title
.This PR allows me to push a
placeholders
dict via a flows context which I can then fill into a newflow_title
localisation. If there are no placeholders it continues to use the existingtitle
localisation so existing integrations are not impacted.This works, and doesn't require any changes on the server side for existing integrations. For integrations that want to do it, they can just poke a
placeholders
dict into self.context from theirasync_step_discovery
and add aflow_title
to their strings.json.However it does feel like i'm breaking an abstraction or violating some layering by doing it this way so I thought it best to start a conversation about the "right way". Should I added a new key at the
context
level? Should there (is there?) a nicer way to set context duringasync_step_discovery
? Should a flow have an optional title that can be concatenated together with the integration name (I think thats what happens with a config entry's title, for example).@balloob what do you think? should i be doing this a different way?