Start a config flow from component

Hello everybody,

i’m working on a component that connects via serial port to multiple devices. A new device can be detected and some basic setup data is transfered.

How can i start a config flow from my component (with the setup data) so that the user can fill out the rest of the form to add the device to the registry?

You add a config_flow.py to your integration, there you add configflow class, and in there you add a method async_step_user. Check other components in core to see how they do it, but basically it’s just defining a schema and passing the data.

I have the config_flow.py and it’s working when the user adds the component or manually adds a device from within the UI. But i want to popup the config flow when the running component detects a new device.

Not entirely sure I get what you want.

  • If you have a configured config_entry (representing a hub) it’s only possible to add additional devices to it without further user interaction.
  • if you have USB devices and you want to detect when a user plugs in a new device you can implement usb discovery by adding a async_step_usb to your config flow and the correct identifiers to your manifest under the “usb” key

I try to explain further:

I have a usb dongle/gateway/hub/server/host (hower you will call it). My component communicates through serial comport emulation with the dongle. To the dongle can be multiple devices connected. If the user connects a new device to the dongle and pushes a button on the device, the dongle gets a notification and sends the information to my component. The dongle is already setup in HA using my component. Now i have the information of the new device in my component (user pushed button on the device), but how can i inform the HA user about that new device?

That’s called integration discovery. It’s possible but not documented. Check the elmk1 integration, especially discovery.py and async_step_integration_discovery

Thank you @zweckj , that was the hint i needed.