ESPHome 2025.12.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 void notify_binary_sensor_update (binary_sensor::BinarySensor *obj)
 
static void notify_fan_update (fan::Fan *obj)
 
static void notify_light_update (light::LightState *obj)
 
static void notify_sensor_update (sensor::Sensor *obj)
 
static void notify_switch_update (switch_::Switch *obj)
 
static void notify_cover_update (cover::Cover *obj)
 
static void notify_text_sensor_update (text_sensor::TextSensor *obj)
 
static void notify_climate_update (climate::Climate *obj)
 
static void notify_number_update (number::Number *obj)
 
static void notify_date_update (datetime::DateEntity *obj)
 
static void notify_time_update (datetime::TimeEntity *obj)
 
static void notify_datetime_update (datetime::DateTimeEntity *obj)
 
static void notify_text_update (text::Text *obj)
 
static void notify_select_update (select::Select *obj)
 
static void notify_lock_update (lock::Lock *obj)
 
static void notify_valve_update (valve::Valve *obj)
 
static void notify_media_player_update (media_player::MediaPlayer *obj)
 
static void notify_alarm_control_panel_update (alarm_control_panel::AlarmControlPanel *obj)
 
static void notify_event (event::Event *obj)
 
static void notify_update (update::UpdateEntity *obj)
 

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).

Controllers read state directly from entities using existing accessors (obj->state, etc.) rather than receiving it as callback parameters that were being ignored anyway.

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 150 of file controller_registry.h.

Member Function Documentation

◆ notify_alarm_control_panel_update()

static void esphome::ControllerRegistry::notify_alarm_control_panel_update ( alarm_control_panel::AlarmControlPanel * obj)
static

◆ notify_binary_sensor_update()

static void esphome::ControllerRegistry::notify_binary_sensor_update ( binary_sensor::BinarySensor * obj)
static

◆ notify_climate_update()

static void esphome::ControllerRegistry::notify_climate_update ( climate::Climate * obj)
static

◆ notify_cover_update()

static void esphome::ControllerRegistry::notify_cover_update ( cover::Cover * obj)
static

◆ notify_date_update()

static void esphome::ControllerRegistry::notify_date_update ( datetime::DateEntity * obj)
static

◆ notify_datetime_update()

static void esphome::ControllerRegistry::notify_datetime_update ( datetime::DateTimeEntity * obj)
static

◆ notify_event()

static void esphome::ControllerRegistry::notify_event ( event::Event * obj)
static

◆ notify_fan_update()

static void esphome::ControllerRegistry::notify_fan_update ( fan::Fan * obj)
static

◆ notify_light_update()

static void esphome::ControllerRegistry::notify_light_update ( light::LightState * obj)
static

◆ notify_lock_update()

static void esphome::ControllerRegistry::notify_lock_update ( lock::Lock * obj)
static

◆ notify_media_player_update()

static void esphome::ControllerRegistry::notify_media_player_update ( media_player::MediaPlayer * obj)
static

◆ notify_number_update()

static void esphome::ControllerRegistry::notify_number_update ( number::Number * obj)
static

◆ notify_select_update()

static void esphome::ControllerRegistry::notify_select_update ( select::Select * obj)
static

◆ notify_sensor_update()

static void esphome::ControllerRegistry::notify_sensor_update ( sensor::Sensor * obj)
static

◆ notify_switch_update()

static void esphome::ControllerRegistry::notify_switch_update ( switch_::Switch * obj)
static

◆ notify_text_sensor_update()

static void esphome::ControllerRegistry::notify_text_sensor_update ( text_sensor::TextSensor * obj)
static

◆ notify_text_update()

static void esphome::ControllerRegistry::notify_text_update ( text::Text * obj)
static

◆ notify_time_update()

static void esphome::ControllerRegistry::notify_time_update ( datetime::TimeEntity * obj)
static

◆ notify_update()

static void esphome::ControllerRegistry::notify_update ( update::UpdateEntity * obj)
static

◆ notify_valve_update()

static void esphome::ControllerRegistry::notify_valve_update ( valve::Valve * obj)
static

◆ register_controller()

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

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 11 of file controller_registry.cpp.

Field Documentation

◆ controllers

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

Definition at line 240 of file controller_registry.h.


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