Help with external "light" component - "expected a dictionary" error

Hi,

Since the removal of the custom component feature in the 2025.1 release I try to create an external component to replace my usage.
I’m faced with an error that I can’t resolve. Any help will be greatly appreciated !

Basically, I use esphome to send RGB data from a light via I2C to an arduino.

Here is the yaml config:

# [...]

external_components:
  - source: livingcolors

light:
  - platform: livingcolors
    name: "LivingColors"

light.py:

livingcolors_ns = cg.esphome_ns.namespace("livingcolors")
LivingcolorsLightOutput = livingcolors_ns.class_(
    "LivingcolorsLightOutput"
)

CONFIG_SCHEMA = (
    cv.Schema(
        {
            cv.GenerateID(): cv.declare_id(LivingcolorsLightOutput),
        }
    )
)

livingcolor.h:

namespace esphome {
namespace livingcolors {

class LivingcolorsLightOutput : public light::LightOutput {
 public:
  void setup() override {
    Wire.begin();
  }

  light::LightTraits get_traits() override {
    auto traits = LightTraits();
    traits.set_supported_color_modes({ColorMode::RGB, ColorMode::BRIGHTNESS});

    return traits;
  }

  void write_state(light::LightState *state) override {
    float red, green, blue;
    state->current_values_as_rgb(&red, &green, &blue);

    // [...]

    Wire.beginTransmission(0x21);
    Wire.write(buf);
    Wire.endTransmission();
  }
};

}  // namespace livingcolors
}  // namespace esphome

(I’ve also an empty __init.py__ file)

When I try to compile/install it I am faced with this error:

INFO ESPHome 2025.2.1
INFO Reading configuration /config/esphome/livingcolors.yaml...
Failed config

light: [source /config/esphome/livingcolors.yaml:39]
  
  expected a dictionary.
  - platform: livingcolors
    name: LivingColors

I’ve tried several things after reading different documentation and posts on this forum without managing to solve this problem.
So, I’m asking the help of the community, could someone help me to solve this?

Thanks

You need IS_PLATFORM_COMPONENT = True in your __init__.py to make your component a platform one, or it will be a “root” one, i.e.

livingcolors:

AFAICT, there is no specific documentation on platforms, though, so IDK if more than that is needed

You can bring back custom component support with this external component: GitHub - robertklep/esphome-custom-component: Brings back support for custom ESPHome components

Hi koying,

I’ve tried this but I always get the same error.
So I think the main problem is somewhere else.

Anyway, thanks four you help !

Hi robertklep,

Thank you, I didn’t know that.
I have to admit that I’d like to learn how to create an external component and follow the “good practice” of esphome.

But it could be a good workaround if I don’t find any solution to my problem.

Yes, I totally understand :slight_smile:

I created this component only because I have a custom component for a device that will be removed in a few weeks time and I couldn’t be bothered to create an external component for it.

1 Like