ESPHome 2026.10.0-dev
Loading...
Searching...
No Matches
list_entities.cpp
Go to the documentation of this file.
1#include "list_entities.h"
2#ifdef USE_API
3#include "api_connection.h"
4#include "api_pb2.h"
6#include "esphome/core/log.h"
7#include "esphome/core/util.h"
8#ifdef USE_API_USER_DEFINED_ACTIONS
9#include "user_services.h"
10#endif
11
12namespace esphome::api {
13
14// Generate entity handler implementations using macros
15#ifdef USE_BINARY_SENSOR
17#endif
18#ifdef USE_COVER
20#endif
21#ifdef USE_FAN
23#endif
24#ifdef USE_LIGHT
26#endif
27#ifdef USE_SENSOR
29#endif
30#ifdef USE_SWITCH
32#endif
33#ifdef USE_BUTTON
35#endif
36#ifdef USE_TEXT_SENSOR
38#endif
39#ifdef USE_LOCK
41#endif
42#ifdef USE_VALVE
44#endif
45#ifdef USE_CAMERA
47#endif
48#ifdef USE_CLIMATE
50#endif
51#ifdef USE_NUMBER
53#endif
54#ifdef USE_DATETIME_DATE
56#endif
57#ifdef USE_DATETIME_TIME
59#endif
60#ifdef USE_DATETIME_DATETIME
62#endif
63#ifdef USE_TEXT
65#endif
66#ifdef USE_SELECT
68#endif
69#ifdef USE_MEDIA_PLAYER
71#endif
72#ifdef USE_ALARM_CONTROL_PANEL
75#endif
76#ifdef USE_WATER_HEATER
78#endif
79#ifdef USE_INFRARED
81#endif
82#ifdef USE_RADIO_FREQUENCY
84#endif
85#ifdef USE_EVENT
87#endif
88#ifdef USE_UPDATE
90#endif
91
92// Special cases that don't follow the pattern
94
96
97#ifdef USE_API_USER_DEFINED_ACTIONS
98// Yield after every Nth service; bounds direct (non-batched) writes per loop pass
99static constexpr uint8_t SERVICE_YIELD_INTERVAL = 3;
100
103 auto resp = service->encode_list_service_response(scratch);
104 if (!this->client_->send_message(resp))
105 return false;
106 // at_ is this service's index
107 if ((this->at_ + 1) % SERVICE_YIELD_INTERVAL == 0)
108 this->yield_after_step_();
109 return true;
110}
111#endif
112
113} // namespace esphome::api
114#endif
void yield_after_step_()
End the current try_advance() pass after this step; lets callbacks that write directly to the socket ...
bool send_message(const T &msg)
Returns false as soon as the TCP buffer is full.
ListEntitiesIterator(APIConnection *client)
bool on_service(UserServiceDescriptor *service) override
virtual ListEntitiesServicesResponse encode_list_service_response(std::span< char > scratch)=0
Build the list-entities message.
Base class for all binary_sensor-type classes.
Base class for all buttons.
Definition button.h:25
Abstract camera base class.
Definition camera.h:115
ClimateDevice - This is the base class for all climate integrations.
Definition climate.h:187
Base class for all cover devices.
Definition cover.h:110
Infrared - Base class for infrared remote control implementations.
Definition infrared.h:114
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Definition light_state.h:93
Base class for all locks.
Definition lock.h:112
Base-class for all numbers.
Definition number.h:29
RadioFrequency - Base class for radio frequency implementations.
Base-class for all selects.
Definition select.h:29
Base-class for all sensors.
Definition sensor.h:47
Base class for all switches.
Definition switch.h:38
Base-class for all text inputs.
Definition text.h:21
Base class for all valve devices.
Definition valve.h:103
LIST_ENTITIES_HANDLER(binary_sensor, binary_sensor::BinarySensor, ListEntitiesBinarySensorResponse) LIST_ENTITIES_HANDLER(cover
std::array< char, API_USER_ACTION_STRINGS_SCRATCH_SIZE > UserActionScratch
watchdog_hw scratch[0]