19static constexpr uint32_t KEEPALIVE_TIMEOUT_MS = 60000;
32 struct DeferredMessage {
41 bool operator==(
const DeferredMessage &test)
const {
74#ifdef USE_BINARY_SENSOR
141#ifdef USE_TEXT_SENSOR
152#ifdef USE_ESP32_CAMERA
185#ifdef USE_DATETIME_DATE
196#ifdef USE_DATETIME_TIME
207#ifdef USE_DATETIME_DATETIME
274#ifdef USE_MEDIA_PLAYER
291#ifdef USE_BLUETOOTH_PROXY
308#ifdef USE_HOMEASSISTANT_TIME
315#ifdef USE_VOICE_ASSISTANT
327#ifdef USE_ALARM_CONTROL_PANEL
370#ifdef USE_HOMEASSISTANT_TIME
403 return this->connection_state_ == ConnectionState ::CONNECTED || this->
is_authenticated();
412 uint8_t header_padding = this->
helper_->frame_header_padding();
467 template<
typename EntityT,
typename StateT,
typename... Args>
503 template<
typename ResponseT>
519 return (this->*send_response_func)(response);
522 bool send_(
const void *buf,
size_t len,
bool force);
542#ifdef USE_ESP32_CAMERA
bool operator==(const DeferredMessage &test) const
DeferredMessage(void *source, send_message_t send_message)
send_message_t send_message_
void schedule_dump_config()
void begin(bool include_internal=false)
bool has_own_name() const
uint32_t get_object_id_hash()
const StringRef & get_name() const
std::string get_icon() const
bool is_disabled_by_default() const
std::string get_object_id() const
EntityCategory get_entity_category() const
void subscribe_voice_assistant(const SubscribeVoiceAssistantRequest &msg) override
void select_command(const SelectCommandRequest &msg) override
BluetoothConnectionsFreeResponse subscribe_bluetooth_connections_free(const SubscribeBluetoothConnectionsFreeRequest &msg) override
bool try_send_alarm_control_panel_state_(alarm_control_panel::AlarmControlPanel *a_alarm_control_panel)
void send_valve_info(valve::Valve *valve)
void send_media_player_info(media_player::MediaPlayer *media_player)
bool try_send_time_state_(datetime::TimeEntity *time)
void bluetooth_gatt_write(const BluetoothGATTWriteRequest &msg) override
void send_light_info(light::LightState *light)
bool send_media_player_state(media_player::MediaPlayer *media_player)
uint32_t client_api_version_minor_
bool try_send_valve_state_(valve::Valve *valve)
bool try_send_text_state_(text::Text *text)
bool send_time_state(datetime::TimeEntity *time)
void time_command(const TimeCommandRequest &msg) override
bool send_state_with_value_(EntityT *entity, bool(APIConnection::*try_send_entity_func)(EntityT *), bool(APIConnection::*try_send_state_func)(EntityT *, StateT, Args...), StateT state, Args... args)
Send entity state method that handles explicit state values.
bool send_buffer(ProtoWriteBuffer buffer, uint32_t message_type) override
void update_command(const UpdateCommandRequest &msg) override
void on_ping_response(const PingResponse &value) override
void send_climate_info(climate::Climate *climate)
void on_voice_assistant_announce_request(const VoiceAssistantAnnounceRequest &msg) override
bool try_send_sensor_state_(sensor::Sensor *sensor)
void set_camera_state(std::shared_ptr< esp32_camera::CameraImage > image)
bool send_state_(esphome::EntityBase *entity, send_message_t try_send_func)
Generic send entity state method to reduce code duplication.
ProtoWriteBuffer create_buffer(uint32_t reserve_size) override
esp32_camera::CameraImageReader image_reader_
bool send_select_state(select::Select *select, std::string state)
bool send_number_state(number::Number *number, float state)
void send_datetime_info(datetime::DateTimeEntity *datetime)
bool send_fan_state(fan::Fan *fan)
void bluetooth_scanner_set_mode(const BluetoothScannerSetModeRequest &msg) override
DeferredMessageQueue deferred_message_queue_
void on_voice_assistant_response(const VoiceAssistantResponse &msg) override
bool try_send_lock_info_(lock::Lock *a_lock)
bool try_send_text_info_(text::Text *text)
enum esphome::api::APIConnection::ConnectionState WAITING_FOR_HELLO
InitialStateIterator initial_state_iterator_
void subscribe_logs(const SubscribeLogsRequest &msg) override
std::unique_ptr< APIFrameHelper > helper_
void date_command(const DateCommandRequest &msg) override
void send_number_info(number::Number *number)
void send_info_(esphome::EntityBase *entity, send_message_t try_send_func)
Generic send entity info method to reduce code duplication.
void send_event(event::Event *event, std::string event_type)
void send_sensor_info(sensor::Sensor *sensor)
std::string client_combined_info_
bool send_switch_state(switch_::Switch *a_switch, bool state)
std::string get_client_combined_info() const
bool try_send_cover_info_(cover::Cover *cover)
bool try_send_button_info_(button::Button *button)
void datetime_command(const DateTimeCommandRequest &msg) override
bool try_send_switch_state_(switch_::Switch *a_switch)
void send_switch_info(switch_::Switch *a_switch)
void voice_assistant_set_configuration(const VoiceAssistantSetConfiguration &msg) override
void send_binary_sensor_info(binary_sensor::BinarySensor *binary_sensor)
bool send_valve_state(valve::Valve *valve)
void send_select_info(select::Select *select)
void bluetooth_gatt_write_descriptor(const BluetoothGATTWriteDescriptorRequest &msg) override
bool try_send_select_info_(select::Select *select)
uint32_t next_ping_retry_
bool send_lock_state(lock::Lock *a_lock, lock::LockState state)
void bluetooth_gatt_read(const BluetoothGATTReadRequest &msg) override
bool try_send_select_state_(select::Select *select)
bool try_send_cover_state_(cover::Cover *cover)
bool try_send_datetime_state_(datetime::DateTimeEntity *datetime)
VoiceAssistantConfigurationResponse voice_assistant_get_configuration(const VoiceAssistantConfigurationRequest &msg) override
bool try_send_binary_sensor_state_(binary_sensor::BinarySensor *binary_sensor)
DisconnectResponse disconnect(const DisconnectRequest &msg) override
void text_command(const TextCommandRequest &msg) override
bool send_sensor_state(sensor::Sensor *sensor, float state)
bool try_send_fan_info_(fan::Fan *fan)
bool send_(const void *buf, size_t len, bool force)
bool try_send_lock_state_(lock::Lock *a_lock)
HelloResponse hello(const HelloRequest &msg) override
bool try_send_log_message(int level, const char *tag, const char *line)
std::string client_peername_
bool send_update_state(update::UpdateEntity *update)
void on_voice_assistant_audio(const VoiceAssistantAudio &msg) override
bool try_send_datetime_info_(datetime::DateTimeEntity *datetime)
bool try_send_entity_info_(esphome::EntityBase *entity, ResponseT &response, bool(APIServerConnectionBase::*send_response_func)(const ResponseT &))
Generic function for generating entity info response messages.
void send_alarm_control_panel_info(alarm_control_panel::AlarmControlPanel *a_alarm_control_panel)
void on_fatal_error() override
void send_update_info(update::UpdateEntity *update)
bool try_send_climate_info_(climate::Climate *climate)
bool try_send_date_state_(datetime::DateEntity *date)
void alarm_control_panel_command(const AlarmControlPanelCommandRequest &msg) override
bool try_send_time_info_(datetime::TimeEntity *time)
bool try_send_alarm_control_panel_info_(alarm_control_panel::AlarmControlPanel *a_alarm_control_panel)
bool try_send_event_(event::Event *event)
bool send_binary_sensor_state(binary_sensor::BinarySensor *binary_sensor, bool state)
void unsubscribe_bluetooth_le_advertisements(const UnsubscribeBluetoothLEAdvertisementsRequest &msg) override
void number_command(const NumberCommandRequest &msg) override
bool try_send_text_sensor_info_(text_sensor::TextSensor *text_sensor)
bool try_send_binary_sensor_info_(binary_sensor::BinarySensor *binary_sensor)
void send_camera_info(esp32_camera::ESP32Camera *camera)
void list_entities(const ListEntitiesRequest &msg) override
bool try_send_switch_info_(switch_::Switch *a_switch)
bool service_call_subscription_
bool try_send_valve_info_(valve::Valve *valve)
void media_player_command(const MediaPlayerCommandRequest &msg) override
void bluetooth_gatt_notify(const BluetoothGATTNotifyRequest &msg) override
void subscribe_homeassistant_services(const SubscribeHomeassistantServicesRequest &msg) override
APIConnection(std::unique_ptr< socket::Socket > socket, APIServer *parent)
void subscribe_states(const SubscribeStatesRequest &msg) override
void send_event_info(event::Event *event)
bool is_authenticated() override
bool try_send_light_state_(light::LightState *light)
void subscribe_bluetooth_le_advertisements(const SubscribeBluetoothLEAdvertisementsRequest &msg) override
bool send_date_state(datetime::DateEntity *date)
void bluetooth_gatt_read_descriptor(const BluetoothGATTReadDescriptorRequest &msg) override
void climate_command(const ClimateCommandRequest &msg) override
void send_date_info(datetime::DateEntity *date)
void bluetooth_gatt_get_services(const BluetoothGATTGetServicesRequest &msg) override
bool is_connection_setup() override
std::vector< uint8_t > proto_write_buffer_
void on_voice_assistant_timer_event_response(const VoiceAssistantTimerEventResponse &msg) override
bool try_send_climate_state_(climate::Climate *climate)
void fan_command(const FanCommandRequest &msg) override
void on_no_setup_connection() override
void on_voice_assistant_event_response(const VoiceAssistantEventResponse &msg) override
PingResponse ping(const PingRequest &msg) override
NoiseEncryptionSetKeyResponse noise_encryption_set_key(const NoiseEncryptionSetKeyRequest &msg) override
void send_text_sensor_info(text_sensor::TextSensor *text_sensor)
bool try_send_number_info_(number::Number *number)
bool send_light_state(light::LightState *light)
DeviceInfoResponse device_info(const DeviceInfoRequest &msg) override
bool try_send_light_info_(light::LightState *light)
void valve_command(const ValveCommandRequest &msg) override
void on_home_assistant_state_response(const HomeAssistantStateResponse &msg) override
void send_button_info(button::Button *button)
void cover_command(const CoverCommandRequest &msg) override
bool try_send_camera_info_(esp32_camera::ESP32Camera *camera)
bool try_send_text_sensor_state_(text_sensor::TextSensor *text_sensor)
void send_fan_info(fan::Fan *fan)
void on_get_time_response(const GetTimeResponse &value) override
bool try_send_date_info_(datetime::DateEntity *date)
void send_time_info(datetime::TimeEntity *time)
bool try_send_fan_state_(fan::Fan *fan)
void subscribe_home_assistant_states(const SubscribeHomeAssistantStatesRequest &msg) override
bool send_text_sensor_state(text_sensor::TextSensor *text_sensor, std::string state)
bool send_bluetooth_le_advertisement(const BluetoothLEAdvertisementResponse &msg)
bool send_text_state(text::Text *text, std::string state)
void send_homeassistant_service_call(const HomeassistantServiceResponse &call)
bool try_send_event_info_(event::Event *event)
bool try_send_update_state_(update::UpdateEntity *update)
void on_disconnect_response(const DisconnectResponse &value) override
bool send_datetime_state(datetime::DateTimeEntity *datetime)
ListEntitiesIterator list_entities_iterator_
bool try_send_media_player_info_(media_player::MediaPlayer *media_player)
bool try_send_media_player_state_(media_player::MediaPlayer *media_player)
bool send_alarm_control_panel_state(alarm_control_panel::AlarmControlPanel *a_alarm_control_panel)
void camera_image(const CameraImageRequest &msg) override
void light_command(const LightCommandRequest &msg) override
GetTimeResponse get_time(const GetTimeRequest &msg) override
void send_cover_info(cover::Cover *cover)
void switch_command(const SwitchCommandRequest &msg) override
bool try_send_sensor_info_(sensor::Sensor *sensor)
bool try_send_update_info_(update::UpdateEntity *update)
bool try_send_number_state_(number::Number *number)
void send_lock_info(lock::Lock *a_lock)
void send_text_info(text::Text *text)
bool send_list_info_done()
uint32_t client_api_version_major_
ConnectResponse connect(const ConnectRequest &msg) override
void lock_command(const LockCommandRequest &msg) override
void bluetooth_device_request(const BluetoothDeviceRequest &msg) override
void execute_service(const ExecuteServiceRequest &msg) override
bool send_climate_state(climate::Climate *climate)
bool try_to_clear_buffer(bool log_out_of_space)
bool send_cover_state(cover::Cover *cover)
void button_command(const ButtonCommandRequest &msg) override
void on_unauthenticated_access() override
bool send_list_entities_done_response(const ListEntitiesDoneResponse &msg)
bool send_homeassistant_service_response(const HomeassistantServiceResponse &msg)
bool send_get_time_request(const GetTimeRequest &msg)
std::vector< DeferredMessage > deferred_queue_
APIConnection * api_connection_
void dmq_push_back_with_dedup_(void *source, send_message_t send_message)
DeferredMessageQueue(APIConnection *api_connection)
void defer(void *source, send_message_t send_message)
Base class for all binary_sensor-type classes.
ClimateDevice - This is the base class for all climate integrations.
Base class for all cover devices.
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
Base class for all locks.
Base-class for all numbers.
Base-class for all selects.
Base-class for all sensors.
Base class for all switches.
Base-class for all text inputs.
Base class for all valve devices.
struct @67::@68 __attribute__
bool(APIConnection::*)(void *) send_message_t
LockState
Enum for all states a lock can be in.
Providing packet encoding functions for exchanging data with a remote host.
Application App
Global storage of Application pointer - only one Application can exist.