Custom component is not found

Hi,

I am looking to extend (play around with) an existing core light component. From this best practices on creating a custom component thread I see that one of the solutions is:

  • copy existing component to custom_components directory.
  • rename components directory to a new name (e.g. fancy_light)
  • in init.py change: DOMAIN = “fancy_light”
  • in manifest.json change: “domain”: “fancy_light” and “name”: “Fancy Light”
  • validate configuration and restart HA
  • define new component in configuration.yaml (related thread):
    • fancy_light:
  • revalidate configuration and restart HA

Initially I want to do as minimal changes as possible and to have a new component behaving exactly like the core light component.

My configuration for this custom component:
image

Problem I get:

  1. Configuration validations gives a warning: Integration error: fancy_light - Integration ‘fancy_light’ not found.
  2. service fancy_light.toggle is not available in developer tools too.
    image

What am I missing? I am using correct custom_components directory as other components are loaded and working from there.

Also, what would be the best way to redefine my existing light device to be not a base light device but a fancy light ?

P.s. I see that renaming might not be necessary, as custom component should override core component. But I am still not able to see my extended light component changed (I tried to have exact copy of light component in custom_components/light with changed strings.json to see the changes in UI).
Do I need somehow provide a configuration for extended light component in configuration.yaml?

Update:

  • Adding version to manifest.json is a must. With that i finally see my fancy_lights component/service in developer tools.
  • Looks like custom component must not be of the same name as core component, as this takes no effect (I still do not see my custom strings from strings.json in UI), even though I see a python ache folder created inside of that component in file system.
  • Still I’m not sure how to change my lights device to use fancy_light and it’s features instead of core light component.

Patrick,

Absolutely right, you cannot have 2 integrations with the same name and core will take precedence over custom components.

In terms of strings.json, for a custom component you have to supply the translation files yourself, so create a translations directory and copy strings.json into this as en.json.

To use your integration for lights, you would have to have an integration that controls them. If you have copied the light integration from HA core and tried to modifiy this, this is not the way to do it.

Light, along with some other core integrations like sensor, climate etc are special in that they are built in domains to be standard ways to handle certain entity types.

Your integration will need to have functionality to add and control your lights and have its own light.py which has a class that extends LightEntity.

You then use this integration to provide your lights. Note, however, that the cards also have fixed functionality, so for custom functions, you will also need to create custom services that control these.

Hope that helps explain but if you need more guidance, come back and post link to what code you have.

1 Like