This is easy enough to setup as YAML configuration but I’m not understanding if, or how, this can be handled in the UI as a config_flow…
My integration needs to create a single MQTT instance for each “account” and then subscribe to various topics for each “device” within that “account”. I need the user to be able to add (or remove) accounts and/or devices under each account…
Unless I’m missing something the docs don’t seem to address this specifically. I found a couple examples online but they are not quite the same as what I’m trying to do and the examples are older so I’m hoping the newest versions of HA can in fact do this and I have just not discovered exactly how…
Sorry, not in a postion to give code examples but the basic premise with your config flow will be to base it on a single account but support multiple instances. Then your users will add a new instance of your integration for each account. Setting the unique id in your config flow to something account id based and validating that account has not already been added is important. Also ensuring your main code supports having multiple instances when storing any data against the hass object is key.
In order to be able to add devices to your instance, would need to understand more about whether these can be detected from the account or need to be manually added and what info needs to be provided for each device.
I believe I understand and have code examples for adding multiple “entries” (accounts in this case) via async_setup_entry using input from the UI gathered using async_step_user it is the sub-entries (devices) where I’m getting lost in terms of how to code that and/or if the UI can even accommodate it.
Yes, there is a way to obtain a list of devices linked to the account, however, the types of devices can be diverse, my integration will only support certain types, and there is not currently a definitive way to differentiate the device type by ID (serial number). Even if there were a unique device type identifier I would not want to arbitrarily link every supported device for a variety of reasons (not the least of which is that each device can easily have 100 or more sensor entities).
For now it will suffice to ask the user for the serial number of a supported device as well as a friendly name they wish to use to identify it (and it’s related entities). I just need to know if it is possible to “add an account” then “add devices to account” in such a way that devices can be added, removed, or disabled and accounts can be add/removed/disabled as a whole (with support for multiple account). I can envision how to do this operationally, for the most part, and the nested hierarchy I might create in a YAML config but I’m trying to do this in the UI with config_flow and I’m not finding much beyond basic overview and simple examples and I’m not certain where to start if I were to try to deep dive into the code base to learn the details of how it works.
This is the basic structure I’m looking at in terms of schema: