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