Config_flow won't execute

I’m not quite sure what I’m missing. I followed the docs (I think) and am adding a config flow to an integration that previously was yaml only.
I’ve created my config_flow.py with a single step
updated the manifest to include the flag
created a strings.json
and updated my init to implement async_setup_entry

From the UI however, it still gives me the, must configure using yaml, message. I feel like I’ve missed a step somewhere but not sure where.
What actually is checked to determine if it should use the config_flow?

Post a link to your code

This is my repo for the Lutron component where I’ve added the config_flow. The init still needs some work but it’s a really straight forward flow as there are only 3 yaml settings for this integration that need to be collected. I’m just trying to get it flowing so I can start debugging it. Thanks in advance for your help!

You need to add the decorator to your configflow class to register it with HA. So,

@config_entries.HANDLERS.register(DOMAIN)
class LutronConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):

You will also need to add translations to make your form display properly. Ie add to strings.json but copy this to .translations/en.json

Give it a go and shout if you need more help.

EDIT: sorry think what i said maybe incorrect. Let me have a look when not on my mobile later and see what real issue is.

I did try the decorator after seeing it on some other integrations but alas, no dice.
It feels like there is some registration somewhere that is keeping the UI from attempting the config flow.
I just can’t find any documentation that says I need to do anything else.

Im wondering if it is something to do with your async_setup_entry function. That def looks like it will cause errors. Not had chance to look at it yet but will try to do so tomorrow or Sat am.

I expect it will cause errors as I just roughed it in super quick from the old code. My hope was to be able to debug it. I can’t imagine that the core is smart enough to know it would throw errors so it reverts to yaml. It feels like there’s an integration registration somewhere that needs to be updated. For instance in the UI, when you go to add “lutron” it then spawns to a sub menu that lists the three lutron integrations. Where is that relationship between the integrations stored?

This is held in homeassistant/generated/integrations.json where it states config_flow: false. There is also a config_flows.py in this directory where it lists integrations with flows.

Agreed, after looking there are a number of issues with your code but none of these stop the config flow starting (maybe lack of strings.json). It is these genrated files that need updating by running:

python -m script.hassfest --action=generate

When you do this however, it will error that your manifest.json is not ordered correctly and you have an invalid strings.json file.

Manifest.json should be ordered domain, name, all other keys alphabetical

{
  "domain": "lutron",
  "name": "Lutron",
  "codeowners": ["@cdheiser"],
  "config_flow": true,
  "documentation": "https://www.home-assistant.io/integrations/lutron",
  "iot_class": "local_polling",
  "loggers": ["pylutron"],
  "requirements": ["pylutron==0.2.8"]
}

Strings.json needs to have entries for your flow.

{
  "config": {
    "flow_title": "Lutron Setup",
    "step": {
      "user": {
        "title": "Lutron Setup",
        "description": "Please enter the details",
        "data": {
          "ip_address": "IP Address",
          "username": "Username",
          "password": "Secret Key"
        }
      }
    },
    "abort": {
      "already_configured": "Device is already configured"
    }
  }
}

I am sure this used to be in the docs and not sure if running in dev container if there is a task to run or you are supposed to update manually. I have not developed a core integration only custom ones where you do not need to update generated files.

EDIT: You also have an error in your config_flow.py with duplicate imports of DOMAIN constant. You should not import it from homeassistant.const

EDIT2: Was having issues getting dev env to run in vscode. How I have, you just run it in the terminal inside the dev container.

THANK YOU for all this info. This is definitely the gap I had. The docs mention the script.hassfest but not the parameters and I can’t actually figure out how to run that. My HA instance doesn’t have that file anywhere. Any clues on how to actually invoke that process?

I’ll get my manifest and strings json files updated as well.

It does but it is a directory not a file. In your ha-core is the script directory. I am assuming you are running this in a dev container in vscode?

If so, in your terminal (you have to terminate the run homeassistant task)

I’m a terrible dev, I’m not running it in a dev container in vscode, I have a dev instance on hardware lol
What is the full path to the scripts directory?

in your ha-core folder

But run it from your ha-core folder.

so it is in the source files but not the running config anywhere?
if so, after I run that, what files need to be updated in the dev instance?

Hass should not be running when you run this. You do not need to update any files, this is what it does.

here’s my confusion:
I’m testing this on an instance that is running on a Pi. So I’ve been copying over the updated files into the docker instance. It looks like this isn’t part of the code that is installed on a Pi, it only exists in the source repo. So I’ll have to run it from the source repo in my vscode and then copy over whatever it changes. I’m sure I can use the git tools to see but I wasn’t sure if it was something obvious and simple.

And yes, I realize this is a crappy way to dev but my feeble little mind can only handle so much new stuff at one time :slight_smile:

I think this is a very hard way to dev and might be worth your time sorting a simpler solution to make the overall project quicker and simpler.

Anyway hope i helped point you in the rignt direction and good luck

ok, I took your suggestion and changed my ways :slight_smile:
I now have a dev container and yes, it is soooo much faster to dev that way. Should have done that from the beginning lol
For anyone finding this thread, the files that the script changes are:
/ha-core/homeassistant/generated/config_flows.py
/ha-core/homeassistant/generated/integrations.json
Getting the script to run properly was the key to changing how the UI behaves. I can now launch it and work through the rest of the code.
Thank you again for getting me in the right direction!