from homeassistant.helpers.entity_component import EntityComponent component = EntityComponent(logger, 'sensor', hass) all_sensors = component.entities
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity_component import EntityComponent class MyCustomSensor(Entity): def __init__(self): self._state = 0 @property def state(self): return self._state def update(self): # update logic here, e.g. fetch value from API or sensor self._state = new_value component = EntityComponent(logger, 'sensor', hass) new_sensor_entity = MyCustomSensor() component.add_entities([new_sensor_entity])This code adds a custom sensor entity to the system using the EntityComponent class. Package library: Home Assistant Core.