Create 2 entities of different domains from custom component [SOLVED]

Hi all,

First thanks for sharing your HA (great) work.

I’m developing a custom component, intended to create a custom ‘climate’ entity.
So I’ve created a ‘’ file, that defines a ‘my_climate’ class (derived from ‘ClimateEntity’).
This file also checks the platform data, and then creates a ‘my_climate’ entity and add it to hass with add_entities().
This works fine.

But I’d like also to create, in the same process, a ‘my_sensor’ entity (derived from ‘SensorEntity’).
I’ve created a ‘my_sensor’ class, derived from ‘SensorEntity’, but when I create and add a ‘my_sensor’ entity HA creates a ‘climate’ entity.

I’ve tried to separate the code (manage ‘my_climate’ in file ‘’ and manage ‘my_sensor’ in file ‘’) but same result.

I’ve also tried to get the ‘sensor’ platform and then call
sensor_platform.add_entities([my_sensor(…)]) but this failed also (error message was : add_entities() unknown for ‘sensor_platform’).

I’ve searched in many custom component examples and associated posts, but this didn’t helped me.

Thanks for any suggestion.


Looking more in detail in the code, I’ve found the solution.
My attempt to get the ‘sensor’ platform was not using the right function.

A call to async_get_platforms(hass, SENSOR_DOMAIN) gives me the right platform, and then use add_entities() on this platform adds my entity on the right domain (sensor).

Sorry for this mistake.
Hope this can help someone anyway.