ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
subscribe_state.h
Go to the documentation of this file.
1#pragma once
2
4#ifdef USE_API
7namespace esphome::api {
8
9class APIConnection;
10
11// Macro for generating InitialStateIterator handlers
12// Calls send_*_state
13#define INITIAL_STATE_HANDLER(entity_type, EntityClass) \
14 bool InitialStateIterator::on_##entity_type(EntityClass *entity) { /* NOLINT(bugprone-macro-parentheses) */ \
15 return this->client_->send_##entity_type##_state(entity); \
16 }
17
19 public:
21
22// Entity overrides (generated from entity_types.h).
23// ENTITY_TYPE_ entities have no state to send and default to a no-op.
24// ENTITY_CONTROLLER_TYPE_ entities are implemented in subscribe_state.cpp via INITIAL_STATE_HANDLER,
25// except on_event which has no state (defined out-of-line in subscribe_state.cpp).
26// NOLINTBEGIN(bugprone-macro-parentheses)
27#define ENTITY_TYPE_(type, singular, plural, count, upper) \
28 bool on_##singular(type *entity) override { return true; }
29#define ENTITY_CONTROLLER_TYPE_(type, singular, plural, count, upper, callback) \
30 bool on_##singular(type *entity) override;
32#undef ENTITY_TYPE_
33#undef ENTITY_CONTROLLER_TYPE_
34 // NOLINTEND(bugprone-macro-parentheses)
35
36 protected:
38};
39
40} // namespace esphome::api
41#endif
InitialStateIterator(APIConnection *client)