ESPHome 2026.5.0-dev
Loading...
Searching...
No Matches
esphome::ControllerRegistry Class Reference

Global registry for Controllers to receive entity state updates. More...

#include <controller_registry.h>

Static Public Member Functions

static void register_controller (Controller *controller)
 Register a controller to receive entity state updates.
 

Static Protected Attributes

static StaticVector< Controller *, CONTROLLER_REGISTRY_MAX > controllers
 

Detailed Description

Global registry for Controllers to receive entity state updates.

This singleton registry allows Controllers (APIServer, WebServer) to receive entity state change notifications without storing per-entity callbacks.

Instead of each entity maintaining controller callbacks (32 bytes overhead per entity), entities call ControllerRegistry::notify_*_update() which iterates the small list of registered controllers (typically 2: API and WebServer).

Each notify method directly iterates controllers and calls the virtual method, avoiding function pointer indirection for minimal dispatch overhead.

Memory savings: 32 bytes per entity (2 controllers × 16 bytes std::function overhead) Typical config (25 entities): ~780 bytes saved Large config (80 entities): ~2,540 bytes saved

Definition at line 30 of file controller_registry.h.

Member Function Documentation

◆ register_controller()

static void esphome::ControllerRegistry::register_controller ( Controller * controller)
inlinestatic

Register a controller to receive entity state updates.

Controllers should call this in their setup() method. Typically only APIServer and WebServer register.

Definition at line 37 of file controller_registry.h.

Field Documentation

◆ controllers

StaticVector< Controller *, CONTROLLER_REGISTRY_MAX > esphome::ControllerRegistry::controllers
staticprotected

Definition at line 50 of file controller_registry.h.


The documentation for this class was generated from the following files: