ESPHome 2025.5.0
Loading...
Searching...
No Matches
esphome::api::APIConnection Class Reference

#include <api_connection.h>

Inheritance diagram for esphome::api::APIConnection:
esphome::api::APIServerConnection esphome::api::APIServerConnectionBase esphome::api::ProtoService

Public Member Functions

 APIConnection (std::unique_ptr< socket::Socket > socket, APIServer *parent)
 
virtual ~APIConnection ()
 
void start ()
 
void loop ()
 
bool send_list_info_done ()
 
bool send_binary_sensor_state (binary_sensor::BinarySensor *binary_sensor, bool state)
 
void send_binary_sensor_info (binary_sensor::BinarySensor *binary_sensor)
 
bool send_cover_state (cover::Cover *cover)
 
void send_cover_info (cover::Cover *cover)
 
void cover_command (const CoverCommandRequest &msg) override
 
bool send_fan_state (fan::Fan *fan)
 
void send_fan_info (fan::Fan *fan)
 
void fan_command (const FanCommandRequest &msg) override
 
bool send_light_state (light::LightState *light)
 
void send_light_info (light::LightState *light)
 
void light_command (const LightCommandRequest &msg) override
 
bool send_sensor_state (sensor::Sensor *sensor, float state)
 
void send_sensor_info (sensor::Sensor *sensor)
 
bool send_switch_state (switch_::Switch *a_switch, bool state)
 
void send_switch_info (switch_::Switch *a_switch)
 
void switch_command (const SwitchCommandRequest &msg) override
 
bool send_text_sensor_state (text_sensor::TextSensor *text_sensor, std::string state)
 
void send_text_sensor_info (text_sensor::TextSensor *text_sensor)
 
void set_camera_state (std::shared_ptr< esp32_camera::CameraImage > image)
 
void send_camera_info (esp32_camera::ESP32Camera *camera)
 
void camera_image (const CameraImageRequest &msg) override
 
bool send_climate_state (climate::Climate *climate)
 
void send_climate_info (climate::Climate *climate)
 
void climate_command (const ClimateCommandRequest &msg) override
 
bool send_number_state (number::Number *number, float state)
 
void send_number_info (number::Number *number)
 
void number_command (const NumberCommandRequest &msg) override
 
bool send_date_state (datetime::DateEntity *date)
 
void send_date_info (datetime::DateEntity *date)
 
void date_command (const DateCommandRequest &msg) override
 
bool send_time_state (datetime::TimeEntity *time)
 
void send_time_info (datetime::TimeEntity *time)
 
void time_command (const TimeCommandRequest &msg) override
 
bool send_datetime_state (datetime::DateTimeEntity *datetime)
 
void send_datetime_info (datetime::DateTimeEntity *datetime)
 
void datetime_command (const DateTimeCommandRequest &msg) override
 
bool send_text_state (text::Text *text, std::string state)
 
void send_text_info (text::Text *text)
 
void text_command (const TextCommandRequest &msg) override
 
bool send_select_state (select::Select *select, std::string state)
 
void send_select_info (select::Select *select)
 
void select_command (const SelectCommandRequest &msg) override
 
void send_button_info (button::Button *button)
 
void button_command (const ButtonCommandRequest &msg) override
 
bool send_lock_state (lock::Lock *a_lock, lock::LockState state)
 
void send_lock_info (lock::Lock *a_lock)
 
void lock_command (const LockCommandRequest &msg) override
 
bool send_valve_state (valve::Valve *valve)
 
void send_valve_info (valve::Valve *valve)
 
void valve_command (const ValveCommandRequest &msg) override
 
bool send_media_player_state (media_player::MediaPlayer *media_player)
 
void send_media_player_info (media_player::MediaPlayer *media_player)
 
void media_player_command (const MediaPlayerCommandRequest &msg) override
 
bool try_send_log_message (int level, const char *tag, const char *line)
 
void send_homeassistant_service_call (const HomeassistantServiceResponse &call)
 
void subscribe_bluetooth_le_advertisements (const SubscribeBluetoothLEAdvertisementsRequest &msg) override
 
void unsubscribe_bluetooth_le_advertisements (const UnsubscribeBluetoothLEAdvertisementsRequest &msg) override
 
bool send_bluetooth_le_advertisement (const BluetoothLEAdvertisementResponse &msg)
 
void bluetooth_device_request (const BluetoothDeviceRequest &msg) override
 
void bluetooth_gatt_read (const BluetoothGATTReadRequest &msg) override
 
void bluetooth_gatt_write (const BluetoothGATTWriteRequest &msg) override
 
void bluetooth_gatt_read_descriptor (const BluetoothGATTReadDescriptorRequest &msg) override
 
void bluetooth_gatt_write_descriptor (const BluetoothGATTWriteDescriptorRequest &msg) override
 
void bluetooth_gatt_get_services (const BluetoothGATTGetServicesRequest &msg) override
 
void bluetooth_gatt_notify (const BluetoothGATTNotifyRequest &msg) override
 
BluetoothConnectionsFreeResponse subscribe_bluetooth_connections_free (const SubscribeBluetoothConnectionsFreeRequest &msg) override
 
void bluetooth_scanner_set_mode (const BluetoothScannerSetModeRequest &msg) override
 
void send_time_request ()
 
void subscribe_voice_assistant (const SubscribeVoiceAssistantRequest &msg) override
 
void on_voice_assistant_response (const VoiceAssistantResponse &msg) override
 
void on_voice_assistant_event_response (const VoiceAssistantEventResponse &msg) override
 
void on_voice_assistant_audio (const VoiceAssistantAudio &msg) override
 
void on_voice_assistant_timer_event_response (const VoiceAssistantTimerEventResponse &msg) override
 
void on_voice_assistant_announce_request (const VoiceAssistantAnnounceRequest &msg) override
 
VoiceAssistantConfigurationResponse voice_assistant_get_configuration (const VoiceAssistantConfigurationRequest &msg) override
 
void voice_assistant_set_configuration (const VoiceAssistantSetConfiguration &msg) override
 
bool send_alarm_control_panel_state (alarm_control_panel::AlarmControlPanel *a_alarm_control_panel)
 
void send_alarm_control_panel_info (alarm_control_panel::AlarmControlPanel *a_alarm_control_panel)
 
void alarm_control_panel_command (const AlarmControlPanelCommandRequest &msg) override
 
void send_event (event::Event *event, std::string event_type)
 
void send_event_info (event::Event *event)
 
bool send_update_state (update::UpdateEntity *update)
 
void send_update_info (update::UpdateEntity *update)
 
void update_command (const UpdateCommandRequest &msg) override
 
void on_disconnect_response (const DisconnectResponse &value) override
 
void on_ping_response (const PingResponse &value) override
 
void on_home_assistant_state_response (const HomeAssistantStateResponse &msg) override
 
void on_get_time_response (const GetTimeResponse &value) override
 
HelloResponse hello (const HelloRequest &msg) override
 
ConnectResponse connect (const ConnectRequest &msg) override
 
DisconnectResponse disconnect (const DisconnectRequest &msg) override
 
PingResponse ping (const PingRequest &msg) override
 
DeviceInfoResponse device_info (const DeviceInfoRequest &msg) override
 
void list_entities (const ListEntitiesRequest &msg) override
 
void subscribe_states (const SubscribeStatesRequest &msg) override
 
void subscribe_logs (const SubscribeLogsRequest &msg) override
 
void subscribe_homeassistant_services (const SubscribeHomeassistantServicesRequest &msg) override
 
void subscribe_home_assistant_states (const SubscribeHomeAssistantStatesRequest &msg) override
 
GetTimeResponse get_time (const GetTimeRequest &msg) override
 
void execute_service (const ExecuteServiceRequest &msg) override
 
NoiseEncryptionSetKeyResponse noise_encryption_set_key (const NoiseEncryptionSetKeyRequest &msg) override
 
bool is_authenticated () override
 
bool is_connection_setup () override
 
void on_fatal_error () override
 
void on_unauthenticated_access () override
 
void on_no_setup_connection () override
 
ProtoWriteBuffer create_buffer (uint32_t reserve_size) override
 
bool try_to_clear_buffer (bool log_out_of_space)
 
bool send_buffer (ProtoWriteBuffer buffer, uint32_t message_type) override
 
std::string get_client_combined_info () const
 
- Public Member Functions inherited from esphome::api::APIServerConnection
virtual void siren_command (const SirenCommandRequest &msg)=0
 
- Public Member Functions inherited from esphome::api::APIServerConnectionBase
bool send_hello_response (const HelloResponse &msg)
 
bool send_connect_response (const ConnectResponse &msg)
 
bool send_disconnect_request (const DisconnectRequest &msg)
 
bool send_disconnect_response (const DisconnectResponse &msg)
 
bool send_ping_request (const PingRequest &msg)
 
bool send_ping_response (const PingResponse &msg)
 
bool send_device_info_response (const DeviceInfoResponse &msg)
 
bool send_list_entities_done_response (const ListEntitiesDoneResponse &msg)
 
bool send_list_entities_binary_sensor_response (const ListEntitiesBinarySensorResponse &msg)
 
bool send_binary_sensor_state_response (const BinarySensorStateResponse &msg)
 
bool send_list_entities_cover_response (const ListEntitiesCoverResponse &msg)
 
bool send_cover_state_response (const CoverStateResponse &msg)
 
bool send_list_entities_fan_response (const ListEntitiesFanResponse &msg)
 
bool send_fan_state_response (const FanStateResponse &msg)
 
bool send_list_entities_light_response (const ListEntitiesLightResponse &msg)
 
bool send_light_state_response (const LightStateResponse &msg)
 
bool send_list_entities_sensor_response (const ListEntitiesSensorResponse &msg)
 
bool send_sensor_state_response (const SensorStateResponse &msg)
 
bool send_list_entities_switch_response (const ListEntitiesSwitchResponse &msg)
 
bool send_switch_state_response (const SwitchStateResponse &msg)
 
bool send_list_entities_text_sensor_response (const ListEntitiesTextSensorResponse &msg)
 
bool send_text_sensor_state_response (const TextSensorStateResponse &msg)
 
bool send_subscribe_logs_response (const SubscribeLogsResponse &msg)
 
bool send_noise_encryption_set_key_response (const NoiseEncryptionSetKeyResponse &msg)
 
bool send_homeassistant_service_response (const HomeassistantServiceResponse &msg)
 
bool send_subscribe_home_assistant_state_response (const SubscribeHomeAssistantStateResponse &msg)
 
bool send_get_time_request (const GetTimeRequest &msg)
 
bool send_get_time_response (const GetTimeResponse &msg)
 
bool send_list_entities_services_response (const ListEntitiesServicesResponse &msg)
 
bool send_list_entities_camera_response (const ListEntitiesCameraResponse &msg)
 
bool send_camera_image_response (const CameraImageResponse &msg)
 
bool send_list_entities_climate_response (const ListEntitiesClimateResponse &msg)
 
bool send_climate_state_response (const ClimateStateResponse &msg)
 
bool send_list_entities_number_response (const ListEntitiesNumberResponse &msg)
 
bool send_number_state_response (const NumberStateResponse &msg)
 
bool send_list_entities_select_response (const ListEntitiesSelectResponse &msg)
 
bool send_select_state_response (const SelectStateResponse &msg)
 
bool send_list_entities_siren_response (const ListEntitiesSirenResponse &msg)
 
bool send_siren_state_response (const SirenStateResponse &msg)
 
bool send_list_entities_lock_response (const ListEntitiesLockResponse &msg)
 
bool send_lock_state_response (const LockStateResponse &msg)
 
bool send_list_entities_button_response (const ListEntitiesButtonResponse &msg)
 
bool send_list_entities_media_player_response (const ListEntitiesMediaPlayerResponse &msg)
 
bool send_media_player_state_response (const MediaPlayerStateResponse &msg)
 
bool send_bluetooth_le_advertisement_response (const BluetoothLEAdvertisementResponse &msg)
 
bool send_bluetooth_le_raw_advertisements_response (const BluetoothLERawAdvertisementsResponse &msg)
 
bool send_bluetooth_device_connection_response (const BluetoothDeviceConnectionResponse &msg)
 
bool send_bluetooth_gatt_get_services_response (const BluetoothGATTGetServicesResponse &msg)
 
bool send_bluetooth_gatt_get_services_done_response (const BluetoothGATTGetServicesDoneResponse &msg)
 
bool send_bluetooth_gatt_read_response (const BluetoothGATTReadResponse &msg)
 
bool send_bluetooth_gatt_notify_data_response (const BluetoothGATTNotifyDataResponse &msg)
 
bool send_bluetooth_connections_free_response (const BluetoothConnectionsFreeResponse &msg)
 
bool send_bluetooth_gatt_error_response (const BluetoothGATTErrorResponse &msg)
 
bool send_bluetooth_gatt_write_response (const BluetoothGATTWriteResponse &msg)
 
bool send_bluetooth_gatt_notify_response (const BluetoothGATTNotifyResponse &msg)
 
bool send_bluetooth_device_pairing_response (const BluetoothDevicePairingResponse &msg)
 
bool send_bluetooth_device_unpairing_response (const BluetoothDeviceUnpairingResponse &msg)
 
bool send_bluetooth_device_clear_cache_response (const BluetoothDeviceClearCacheResponse &msg)
 
bool send_bluetooth_scanner_state_response (const BluetoothScannerStateResponse &msg)
 
bool send_voice_assistant_request (const VoiceAssistantRequest &msg)
 
bool send_voice_assistant_audio (const VoiceAssistantAudio &msg)
 
bool send_voice_assistant_announce_finished (const VoiceAssistantAnnounceFinished &msg)
 
bool send_voice_assistant_configuration_response (const VoiceAssistantConfigurationResponse &msg)
 
bool send_list_entities_alarm_control_panel_response (const ListEntitiesAlarmControlPanelResponse &msg)
 
bool send_alarm_control_panel_state_response (const AlarmControlPanelStateResponse &msg)
 
bool send_list_entities_text_response (const ListEntitiesTextResponse &msg)
 
bool send_text_state_response (const TextStateResponse &msg)
 
bool send_list_entities_date_response (const ListEntitiesDateResponse &msg)
 
bool send_date_state_response (const DateStateResponse &msg)
 
bool send_list_entities_time_response (const ListEntitiesTimeResponse &msg)
 
bool send_time_state_response (const TimeStateResponse &msg)
 
bool send_list_entities_event_response (const ListEntitiesEventResponse &msg)
 
bool send_event_response (const EventResponse &msg)
 
bool send_list_entities_valve_response (const ListEntitiesValveResponse &msg)
 
bool send_valve_state_response (const ValveStateResponse &msg)
 
bool send_list_entities_date_time_response (const ListEntitiesDateTimeResponse &msg)
 
bool send_date_time_state_response (const DateTimeStateResponse &msg)
 
bool send_list_entities_update_response (const ListEntitiesUpdateResponse &msg)
 
bool send_update_state_response (const UpdateStateResponse &msg)
 

Protected Types

enum class  ConnectionState { WAITING_FOR_HELLO , CONNECTED , AUTHENTICATED }
 

Protected Member Functions

bool try_send_binary_sensor_state_ (binary_sensor::BinarySensor *binary_sensor)
 
bool try_send_binary_sensor_state_ (binary_sensor::BinarySensor *binary_sensor, bool state)
 
bool try_send_binary_sensor_info_ (binary_sensor::BinarySensor *binary_sensor)
 
bool try_send_cover_state_ (cover::Cover *cover)
 
bool try_send_cover_info_ (cover::Cover *cover)
 
bool try_send_fan_state_ (fan::Fan *fan)
 
bool try_send_fan_info_ (fan::Fan *fan)
 
bool try_send_light_state_ (light::LightState *light)
 
bool try_send_light_info_ (light::LightState *light)
 
bool try_send_sensor_state_ (sensor::Sensor *sensor)
 
bool try_send_sensor_state_ (sensor::Sensor *sensor, float state)
 
bool try_send_sensor_info_ (sensor::Sensor *sensor)
 
bool try_send_switch_state_ (switch_::Switch *a_switch)
 
bool try_send_switch_state_ (switch_::Switch *a_switch, bool state)
 
bool try_send_switch_info_ (switch_::Switch *a_switch)
 
bool try_send_text_sensor_state_ (text_sensor::TextSensor *text_sensor)
 
bool try_send_text_sensor_state_ (text_sensor::TextSensor *text_sensor, std::string state)
 
bool try_send_text_sensor_info_ (text_sensor::TextSensor *text_sensor)
 
bool try_send_camera_info_ (esp32_camera::ESP32Camera *camera)
 
bool try_send_climate_state_ (climate::Climate *climate)
 
bool try_send_climate_info_ (climate::Climate *climate)
 
bool try_send_number_state_ (number::Number *number)
 
bool try_send_number_state_ (number::Number *number, float state)
 
bool try_send_number_info_ (number::Number *number)
 
bool try_send_date_state_ (datetime::DateEntity *date)
 
bool try_send_date_info_ (datetime::DateEntity *date)
 
bool try_send_time_state_ (datetime::TimeEntity *time)
 
bool try_send_time_info_ (datetime::TimeEntity *time)
 
bool try_send_datetime_state_ (datetime::DateTimeEntity *datetime)
 
bool try_send_datetime_info_ (datetime::DateTimeEntity *datetime)
 
bool try_send_text_state_ (text::Text *text)
 
bool try_send_text_state_ (text::Text *text, std::string state)
 
bool try_send_text_info_ (text::Text *text)
 
bool try_send_select_state_ (select::Select *select)
 
bool try_send_select_state_ (select::Select *select, std::string state)
 
bool try_send_select_info_ (select::Select *select)
 
bool try_send_button_info_ (button::Button *button)
 
bool try_send_lock_state_ (lock::Lock *a_lock)
 
bool try_send_lock_state_ (lock::Lock *a_lock, lock::LockState state)
 
bool try_send_lock_info_ (lock::Lock *a_lock)
 
bool try_send_valve_state_ (valve::Valve *valve)
 
bool try_send_valve_info_ (valve::Valve *valve)
 
bool try_send_media_player_state_ (media_player::MediaPlayer *media_player)
 
bool try_send_media_player_info_ (media_player::MediaPlayer *media_player)
 
bool try_send_alarm_control_panel_state_ (alarm_control_panel::AlarmControlPanel *a_alarm_control_panel)
 
bool try_send_alarm_control_panel_info_ (alarm_control_panel::AlarmControlPanel *a_alarm_control_panel)
 
bool try_send_event_ (event::Event *event)
 
bool try_send_event_ (event::Event *event, std::string event_type)
 
bool try_send_event_info_ (event::Event *event)
 
bool try_send_update_state_ (update::UpdateEntity *update)
 
bool try_send_update_info_ (update::UpdateEntity *update)
 
bool send_state_ (esphome::EntityBase *entity, send_message_t try_send_func)
 Generic send entity state method to reduce code duplication.
 
template<typename EntityT , typename StateT , typename... Args>
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.
 
void send_info_ (esphome::EntityBase *entity, send_message_t try_send_func)
 Generic send entity info method to reduce code duplication.
 
template<typename ResponseT >
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.
 
bool send_ (const void *buf, size_t len, bool force)
 
- Protected Member Functions inherited from esphome::api::APIServerConnection
void on_hello_request (const HelloRequest &msg) override
 
void on_connect_request (const ConnectRequest &msg) override
 
void on_disconnect_request (const DisconnectRequest &msg) override
 
void on_ping_request (const PingRequest &msg) override
 
void on_device_info_request (const DeviceInfoRequest &msg) override
 
void on_list_entities_request (const ListEntitiesRequest &msg) override
 
void on_subscribe_states_request (const SubscribeStatesRequest &msg) override
 
void on_subscribe_logs_request (const SubscribeLogsRequest &msg) override
 
void on_subscribe_homeassistant_services_request (const SubscribeHomeassistantServicesRequest &msg) override
 
void on_subscribe_home_assistant_states_request (const SubscribeHomeAssistantStatesRequest &msg) override
 
void on_get_time_request (const GetTimeRequest &msg) override
 
void on_execute_service_request (const ExecuteServiceRequest &msg) override
 
void on_noise_encryption_set_key_request (const NoiseEncryptionSetKeyRequest &msg) override
 
void on_button_command_request (const ButtonCommandRequest &msg) override
 
void on_camera_image_request (const CameraImageRequest &msg) override
 
void on_climate_command_request (const ClimateCommandRequest &msg) override
 
void on_cover_command_request (const CoverCommandRequest &msg) override
 
void on_date_command_request (const DateCommandRequest &msg) override
 
void on_date_time_command_request (const DateTimeCommandRequest &msg) override
 
void on_fan_command_request (const FanCommandRequest &msg) override
 
void on_light_command_request (const LightCommandRequest &msg) override
 
void on_lock_command_request (const LockCommandRequest &msg) override
 
void on_media_player_command_request (const MediaPlayerCommandRequest &msg) override
 
void on_number_command_request (const NumberCommandRequest &msg) override
 
void on_select_command_request (const SelectCommandRequest &msg) override
 
void on_siren_command_request (const SirenCommandRequest &msg) override
 
void on_switch_command_request (const SwitchCommandRequest &msg) override
 
void on_text_command_request (const TextCommandRequest &msg) override
 
void on_time_command_request (const TimeCommandRequest &msg) override
 
void on_update_command_request (const UpdateCommandRequest &msg) override
 
void on_valve_command_request (const ValveCommandRequest &msg) override
 
void on_subscribe_bluetooth_le_advertisements_request (const SubscribeBluetoothLEAdvertisementsRequest &msg) override
 
void on_bluetooth_device_request (const BluetoothDeviceRequest &msg) override
 
void on_bluetooth_gatt_get_services_request (const BluetoothGATTGetServicesRequest &msg) override
 
void on_bluetooth_gatt_read_request (const BluetoothGATTReadRequest &msg) override
 
void on_bluetooth_gatt_write_request (const BluetoothGATTWriteRequest &msg) override
 
void on_bluetooth_gatt_read_descriptor_request (const BluetoothGATTReadDescriptorRequest &msg) override
 
void on_bluetooth_gatt_write_descriptor_request (const BluetoothGATTWriteDescriptorRequest &msg) override
 
void on_bluetooth_gatt_notify_request (const BluetoothGATTNotifyRequest &msg) override
 
void on_subscribe_bluetooth_connections_free_request (const SubscribeBluetoothConnectionsFreeRequest &msg) override
 
void on_unsubscribe_bluetooth_le_advertisements_request (const UnsubscribeBluetoothLEAdvertisementsRequest &msg) override
 
void on_bluetooth_scanner_set_mode_request (const BluetoothScannerSetModeRequest &msg) override
 
void on_subscribe_voice_assistant_request (const SubscribeVoiceAssistantRequest &msg) override
 
void on_voice_assistant_configuration_request (const VoiceAssistantConfigurationRequest &msg) override
 
void on_voice_assistant_set_configuration (const VoiceAssistantSetConfiguration &msg) override
 
void on_alarm_control_panel_command_request (const AlarmControlPanelCommandRequest &msg) override
 
- Protected Member Functions inherited from esphome::api::APIServerConnectionBase
bool read_message (uint32_t msg_size, uint32_t msg_type, uint8_t *msg_data) override
 
- Protected Member Functions inherited from esphome::api::ProtoService
template<class C >
bool send_message_ (const C &msg, uint32_t message_type)
 

Protected Attributes

friend APIServer
 
enum esphome::api::APIConnection::ConnectionState WAITING_FOR_HELLO
 
bool remove_ {false}
 
std::vector< uint8_t > proto_write_buffer_
 
std::unique_ptr< APIFrameHelperhelper_
 
std::string client_info_
 
std::string client_peername_
 
std::string client_combined_info_
 
uint32_t client_api_version_major_ {0}
 
uint32_t client_api_version_minor_ {0}
 
esp32_camera::CameraImageReader image_reader_
 
bool state_subscription_ {false}
 
int log_subscription_ {ESPHOME_LOG_LEVEL_NONE}
 
uint32_t last_traffic_
 
uint32_t next_ping_retry_ {0}
 
uint8_t ping_retries_ {0}
 
bool sent_ping_ {false}
 
bool service_call_subscription_ {false}
 
bool next_close_ = false
 
APIServerparent_
 
DeferredMessageQueue deferred_message_queue_
 
InitialStateIterator initial_state_iterator_
 
ListEntitiesIterator list_entities_iterator_
 
int state_subs_at_ = -1
 

Detailed Description

Definition at line 62 of file api_connection.h.

Member Enumeration Documentation

◆ ConnectionState

Enumerator
WAITING_FOR_HELLO 
CONNECTED 
AUTHENTICATED 

Definition at line 524 of file api_connection.h.

Constructor & Destructor Documentation

◆ APIConnection()

esphome::api::APIConnection::APIConnection ( std::unique_ptr< socket::Socket > socket,
APIServer * parent )

Definition at line 62 of file api_connection.cpp.

◆ ~APIConnection()

esphome::api::APIConnection::~APIConnection ( )
virtual

Definition at line 100 of file api_connection.cpp.

Member Function Documentation

◆ alarm_control_panel_command()

void esphome::api::APIConnection::alarm_control_panel_command ( const AlarmControlPanelCommandRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1355 of file api_connection.cpp.

◆ bluetooth_device_request()

void esphome::api::APIConnection::bluetooth_device_request ( const BluetoothDeviceRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1190 of file api_connection.cpp.

◆ bluetooth_gatt_get_services()

void esphome::api::APIConnection::bluetooth_gatt_get_services ( const BluetoothGATTGetServicesRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1205 of file api_connection.cpp.

◆ bluetooth_gatt_notify()

void esphome::api::APIConnection::bluetooth_gatt_notify ( const BluetoothGATTNotifyRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1209 of file api_connection.cpp.

◆ bluetooth_gatt_read()

void esphome::api::APIConnection::bluetooth_gatt_read ( const BluetoothGATTReadRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1193 of file api_connection.cpp.

◆ bluetooth_gatt_read_descriptor()

void esphome::api::APIConnection::bluetooth_gatt_read_descriptor ( const BluetoothGATTReadDescriptorRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1199 of file api_connection.cpp.

◆ bluetooth_gatt_write()

void esphome::api::APIConnection::bluetooth_gatt_write ( const BluetoothGATTWriteRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1196 of file api_connection.cpp.

◆ bluetooth_gatt_write_descriptor()

void esphome::api::APIConnection::bluetooth_gatt_write_descriptor ( const BluetoothGATTWriteDescriptorRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1202 of file api_connection.cpp.

◆ bluetooth_scanner_set_mode()

void esphome::api::APIConnection::bluetooth_scanner_set_mode ( const BluetoothScannerSetModeRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1221 of file api_connection.cpp.

◆ button_command()

void esphome::api::APIConnection::button_command ( const ButtonCommandRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 967 of file api_connection.cpp.

◆ camera_image()

void esphome::api::APIConnection::camera_image ( const CameraImageRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1145 of file api_connection.cpp.

◆ climate_command()

void esphome::api::APIConnection::climate_command ( const ClimateCommandRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 695 of file api_connection.cpp.

◆ connect()

ConnectResponse esphome::api::APIConnection::connect ( const ConnectRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1522 of file api_connection.cpp.

◆ cover_command()

void esphome::api::APIConnection::cover_command ( const CoverCommandRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 336 of file api_connection.cpp.

◆ create_buffer()

ProtoWriteBuffer esphome::api::APIConnection::create_buffer ( uint32_t reserve_size)
inlineoverridevirtual

Implements esphome::api::ProtoService.

Definition at line 408 of file api_connection.h.

◆ date_command()

void esphome::api::APIConnection::date_command ( const DateCommandRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 793 of file api_connection.cpp.

◆ datetime_command()

void esphome::api::APIConnection::datetime_command ( const DateTimeCommandRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 866 of file api_connection.cpp.

◆ device_info()

DeviceInfoResponse esphome::api::APIConnection::device_info ( const DeviceInfoRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1540 of file api_connection.cpp.

◆ disconnect()

DisconnectResponse esphome::api::APIConnection::disconnect ( const DisconnectRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 261 of file api_connection.cpp.

◆ execute_service()

void esphome::api::APIConnection::execute_service ( const ExecuteServiceRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1592 of file api_connection.cpp.

◆ fan_command()

void esphome::api::APIConnection::fan_command ( const FanCommandRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 403 of file api_connection.cpp.

◆ get_client_combined_info()

std::string esphome::api::APIConnection::get_client_combined_info ( ) const
inline

Definition at line 424 of file api_connection.h.

◆ get_time()

GetTimeResponse esphome::api::APIConnection::get_time ( const GetTimeRequest & msg)
inlineoverridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 392 of file api_connection.h.

◆ hello()

HelloResponse esphome::api::APIConnection::hello ( const HelloRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1503 of file api_connection.cpp.

◆ is_authenticated()

bool esphome::api::APIConnection::is_authenticated ( )
inlineoverridevirtual

Implements esphome::api::ProtoService.

Definition at line 401 of file api_connection.h.

◆ is_connection_setup()

bool esphome::api::APIConnection::is_connection_setup ( )
inlineoverridevirtual

Implements esphome::api::ProtoService.

Definition at line 402 of file api_connection.h.

◆ light_command()

void esphome::api::APIConnection::light_command ( const LightCommandRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 481 of file api_connection.cpp.

◆ list_entities()

void esphome::api::APIConnection::list_entities ( const ListEntitiesRequest & msg)
inlineoverridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 378 of file api_connection.h.

◆ lock_command()

void esphome::api::APIConnection::lock_command ( const LockCommandRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1004 of file api_connection.cpp.

◆ loop()

void esphome::api::APIConnection::loop ( )

Definition at line 113 of file api_connection.cpp.

◆ media_player_command()

void esphome::api::APIConnection::media_player_command ( const MediaPlayerCommandRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1103 of file api_connection.cpp.

◆ noise_encryption_set_key()

NoiseEncryptionSetKeyResponse esphome::api::APIConnection::noise_encryption_set_key ( const NoiseEncryptionSetKeyRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1604 of file api_connection.cpp.

◆ number_command()

void esphome::api::APIConnection::number_command ( const NumberCommandRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 757 of file api_connection.cpp.

◆ on_disconnect_response()

void esphome::api::APIConnection::on_disconnect_response ( const DisconnectResponse & value)
overridevirtual

Reimplemented from esphome::api::APIServerConnectionBase.

Definition at line 270 of file api_connection.cpp.

◆ on_fatal_error()

void esphome::api::APIConnection::on_fatal_error ( )
overridevirtual

Implements esphome::api::ProtoService.

Definition at line 1675 of file api_connection.cpp.

◆ on_get_time_response()

void esphome::api::APIConnection::on_get_time_response ( const GetTimeResponse & value)
overridevirtual

Reimplemented from esphome::api::APIServerConnectionBase.

Definition at line 1162 of file api_connection.cpp.

◆ on_home_assistant_state_response()

void esphome::api::APIConnection::on_home_assistant_state_response ( const HomeAssistantStateResponse & msg)
overridevirtual

Reimplemented from esphome::api::APIServerConnectionBase.

Definition at line 1585 of file api_connection.cpp.

◆ on_no_setup_connection()

void esphome::api::APIConnection::on_no_setup_connection ( )
overridevirtual

Implements esphome::api::ProtoService.

Definition at line 1671 of file api_connection.cpp.

◆ on_ping_response()

void esphome::api::APIConnection::on_ping_response ( const PingResponse & value)
inlineoverridevirtual

Reimplemented from esphome::api::APIServerConnectionBase.

Definition at line 364 of file api_connection.h.

◆ on_unauthenticated_access()

void esphome::api::APIConnection::on_unauthenticated_access ( )
overridevirtual

Implements esphome::api::ProtoService.

Definition at line 1667 of file api_connection.cpp.

◆ on_voice_assistant_announce_request()

void esphome::api::APIConnection::on_voice_assistant_announce_request ( const VoiceAssistantAnnounceRequest & msg)
overridevirtual

Reimplemented from esphome::api::APIServerConnectionBase.

Definition at line 1282 of file api_connection.cpp.

◆ on_voice_assistant_audio()

void esphome::api::APIConnection::on_voice_assistant_audio ( const VoiceAssistantAudio & msg)
overridevirtual

Reimplemented from esphome::api::APIServerConnectionBase.

Definition at line 1263 of file api_connection.cpp.

◆ on_voice_assistant_event_response()

void esphome::api::APIConnection::on_voice_assistant_event_response ( const VoiceAssistantEventResponse & msg)
overridevirtual

Reimplemented from esphome::api::APIServerConnectionBase.

Definition at line 1254 of file api_connection.cpp.

◆ on_voice_assistant_response()

void esphome::api::APIConnection::on_voice_assistant_response ( const VoiceAssistantResponse & msg)
overridevirtual

Reimplemented from esphome::api::APIServerConnectionBase.

Definition at line 1233 of file api_connection.cpp.

◆ on_voice_assistant_timer_event_response()

void esphome::api::APIConnection::on_voice_assistant_timer_event_response ( const VoiceAssistantTimerEventResponse & msg)
overridevirtual

Reimplemented from esphome::api::APIServerConnectionBase.

Definition at line 1272 of file api_connection.cpp.

◆ ping()

PingResponse esphome::api::APIConnection::ping ( const PingRequest & msg)
inlineoverridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 376 of file api_connection.h.

◆ select_command()

void esphome::api::APIConnection::select_command ( const SelectCommandRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 944 of file api_connection.cpp.

◆ send_()

bool esphome::api::APIConnection::send_ ( const void * buf,
size_t len,
bool force )
protected

◆ send_alarm_control_panel_info()

void esphome::api::APIConnection::send_alarm_control_panel_info ( alarm_control_panel::AlarmControlPanel * a_alarm_control_panel)

Definition at line 1335 of file api_connection.cpp.

◆ send_alarm_control_panel_state()

bool esphome::api::APIConnection::send_alarm_control_panel_state ( alarm_control_panel::AlarmControlPanel * a_alarm_control_panel)

Definition at line 1331 of file api_connection.cpp.

◆ send_binary_sensor_info()

void esphome::api::APIConnection::send_binary_sensor_info ( binary_sensor::BinarySensor * binary_sensor)

Definition at line 279 of file api_connection.cpp.

◆ send_binary_sensor_state()

bool esphome::api::APIConnection::send_binary_sensor_state ( binary_sensor::BinarySensor * binary_sensor,
bool state )

Definition at line 275 of file api_connection.cpp.

◆ send_bluetooth_le_advertisement()

bool esphome::api::APIConnection::send_bluetooth_le_advertisement ( const BluetoothLEAdvertisementResponse & msg)

Definition at line 1175 of file api_connection.cpp.

◆ send_buffer()

bool esphome::api::APIConnection::send_buffer ( ProtoWriteBuffer buffer,
uint32_t message_type )
overridevirtual

Implements esphome::api::ProtoService.

Definition at line 1646 of file api_connection.cpp.

◆ send_button_info()

void esphome::api::APIConnection::send_button_info ( button::Button * button)

Definition at line 956 of file api_connection.cpp.

◆ send_camera_info()

void esphome::api::APIConnection::send_camera_info ( esp32_camera::ESP32Camera * camera)

Definition at line 1135 of file api_connection.cpp.

◆ send_climate_info()

void esphome::api::APIConnection::send_climate_info ( climate::Climate * climate)

Definition at line 629 of file api_connection.cpp.

◆ send_climate_state()

bool esphome::api::APIConnection::send_climate_state ( climate::Climate * climate)

Definition at line 625 of file api_connection.cpp.

◆ send_cover_info()

void esphome::api::APIConnection::send_cover_info ( cover::Cover * cover)

Definition at line 308 of file api_connection.cpp.

◆ send_cover_state()

bool esphome::api::APIConnection::send_cover_state ( cover::Cover * cover)

Definition at line 304 of file api_connection.cpp.

◆ send_date_info()

void esphome::api::APIConnection::send_date_info ( datetime::DateEntity * date)

Definition at line 773 of file api_connection.cpp.

◆ send_date_state()

bool esphome::api::APIConnection::send_date_state ( datetime::DateEntity * date)

Definition at line 769 of file api_connection.cpp.

◆ send_datetime_info()

void esphome::api::APIConnection::send_datetime_info ( datetime::DateTimeEntity * datetime)

Definition at line 845 of file api_connection.cpp.

◆ send_datetime_state()

bool esphome::api::APIConnection::send_datetime_state ( datetime::DateTimeEntity * datetime)

Definition at line 841 of file api_connection.cpp.

◆ send_event()

void esphome::api::APIConnection::send_event ( event::Event * event,
std::string event_type )

Definition at line 1390 of file api_connection.cpp.

◆ send_event_info()

void esphome::api::APIConnection::send_event_info ( event::Event * event)

Definition at line 1394 of file api_connection.cpp.

◆ send_fan_info()

void esphome::api::APIConnection::send_fan_info ( fan::Fan * fan)

Definition at line 370 of file api_connection.cpp.

◆ send_fan_state()

bool esphome::api::APIConnection::send_fan_state ( fan::Fan * fan)

Definition at line 366 of file api_connection.cpp.

◆ send_homeassistant_service_call()

void esphome::api::APIConnection::send_homeassistant_service_call ( const HomeassistantServiceResponse & call)
inline

Definition at line 286 of file api_connection.h.

◆ send_info_()

void esphome::api::APIConnection::send_info_ ( esphome::EntityBase * entity,
send_message_t try_send_func )
inlineprotected

Generic send entity info method to reduce code duplication.

Only attempts to build and send the message if the transmit buffer is available.

Parameters
entityThe entity to send info for
try_send_funcThe function that tries to send the info

Definition at line 487 of file api_connection.h.

◆ send_light_info()

void esphome::api::APIConnection::send_light_info ( light::LightState * light)

Definition at line 430 of file api_connection.cpp.

◆ send_light_state()

bool esphome::api::APIConnection::send_light_state ( light::LightState * light)

Definition at line 426 of file api_connection.cpp.

◆ send_list_info_done()

bool esphome::api::APIConnection::send_list_info_done ( )
inline

Definition at line 70 of file api_connection.h.

◆ send_lock_info()

void esphome::api::APIConnection::send_lock_info ( lock::Lock * a_lock)

Definition at line 981 of file api_connection.cpp.

◆ send_lock_state()

bool esphome::api::APIConnection::send_lock_state ( lock::Lock * a_lock,
lock::LockState state )

Definition at line 977 of file api_connection.cpp.

◆ send_media_player_info()

void esphome::api::APIConnection::send_media_player_info ( media_player::MediaPlayer * media_player)

Definition at line 1070 of file api_connection.cpp.

◆ send_media_player_state()

bool esphome::api::APIConnection::send_media_player_state ( media_player::MediaPlayer * media_player)

Definition at line 1066 of file api_connection.cpp.

◆ send_number_info()

void esphome::api::APIConnection::send_number_info ( number::Number * number)

Definition at line 730 of file api_connection.cpp.

◆ send_number_state()

bool esphome::api::APIConnection::send_number_state ( number::Number * number,
float state )

Definition at line 726 of file api_connection.cpp.

◆ send_select_info()

void esphome::api::APIConnection::send_select_info ( select::Select * select)

Definition at line 921 of file api_connection.cpp.

◆ send_select_state()

bool esphome::api::APIConnection::send_select_state ( select::Select * select,
std::string state )

Definition at line 917 of file api_connection.cpp.

◆ send_sensor_info()

void esphome::api::APIConnection::send_sensor_info ( sensor::Sensor * sensor)

Definition at line 523 of file api_connection.cpp.

◆ send_sensor_state()

bool esphome::api::APIConnection::send_sensor_state ( sensor::Sensor * sensor,
float state )

Definition at line 519 of file api_connection.cpp.

◆ send_state_()

bool esphome::api::APIConnection::send_state_ ( esphome::EntityBase * entity,
send_message_t try_send_func )
inlineprotected

Generic send entity state method to reduce code duplication.

Only attempts to build and send the message if the transmit buffer is available.

This is the base version for entities that use their current state.

Parameters
entityThe entity to send state for
try_send_funcThe function that tries to send the state
Returns
True on success or message deferred, false if subscription check failed

Definition at line 439 of file api_connection.h.

◆ send_state_with_value_()

template<typename EntityT , typename StateT , typename... Args>
bool esphome::api::APIConnection::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 )
inlineprotected

Send entity state method that handles explicit state values.

Only attempts to build and send the message if the transmit buffer is available.

This method accepts a state parameter to be used instead of the entity's current state. It attempts to send the state with the provided value first, and if that fails due to buffer constraints, it defers the entity for later processing using the entity-only function.

Template Parameters
EntityTThe entity type
StateTType of the state parameter
ArgsAdditional argument types (if any)
Parameters
entityThe entity to send state for
try_send_entity_funcThe function that tries to send the state with entity pointer only
try_send_state_funcThe function that tries to send the state with entity and state parameters
stateThe state value to send
argsAdditional arguments to pass to the try_send_state_func
Returns
True on success or message deferred, false if subscription check failed

Definition at line 468 of file api_connection.h.

◆ send_switch_info()

void esphome::api::APIConnection::send_switch_info ( switch_::Switch * a_switch)

Definition at line 558 of file api_connection.cpp.

◆ send_switch_state()

bool esphome::api::APIConnection::send_switch_state ( switch_::Switch * a_switch,
bool state )

Definition at line 554 of file api_connection.cpp.

◆ send_text_info()

void esphome::api::APIConnection::send_text_info ( text::Text * text)

Definition at line 882 of file api_connection.cpp.

◆ send_text_sensor_info()

void esphome::api::APIConnection::send_text_sensor_info ( text_sensor::TextSensor * text_sensor)

Definition at line 598 of file api_connection.cpp.

◆ send_text_sensor_state()

bool esphome::api::APIConnection::send_text_sensor_state ( text_sensor::TextSensor * text_sensor,
std::string state )

Definition at line 594 of file api_connection.cpp.

◆ send_text_state()

bool esphome::api::APIConnection::send_text_state ( text::Text * text,
std::string state )

Definition at line 878 of file api_connection.cpp.

◆ send_time_info()

void esphome::api::APIConnection::send_time_info ( datetime::TimeEntity * time)

Definition at line 809 of file api_connection.cpp.

◆ send_time_request()

void esphome::api::APIConnection::send_time_request ( )
inline

Definition at line 309 of file api_connection.h.

◆ send_time_state()

bool esphome::api::APIConnection::send_time_state ( datetime::TimeEntity * time)

Definition at line 805 of file api_connection.cpp.

◆ send_update_info()

void esphome::api::APIConnection::send_update_info ( update::UpdateEntity * update)

Definition at line 1424 of file api_connection.cpp.

◆ send_update_state()

bool esphome::api::APIConnection::send_update_state ( update::UpdateEntity * update)

Definition at line 1420 of file api_connection.cpp.

◆ send_valve_info()

void esphome::api::APIConnection::send_valve_info ( valve::Valve * valve)

Definition at line 1028 of file api_connection.cpp.

◆ send_valve_state()

bool esphome::api::APIConnection::send_valve_state ( valve::Valve * valve)

Definition at line 1024 of file api_connection.cpp.

◆ set_camera_state()

void esphome::api::APIConnection::set_camera_state ( std::shared_ptr< esp32_camera::CameraImage > image)

Definition at line 1126 of file api_connection.cpp.

◆ start()

void esphome::api::APIConnection::start ( )

Definition at line 81 of file api_connection.cpp.

◆ subscribe_bluetooth_connections_free()

BluetoothConnectionsFreeResponse esphome::api::APIConnection::subscribe_bluetooth_connections_free ( const SubscribeBluetoothConnectionsFreeRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1213 of file api_connection.cpp.

◆ subscribe_bluetooth_le_advertisements()

void esphome::api::APIConnection::subscribe_bluetooth_le_advertisements ( const SubscribeBluetoothLEAdvertisementsRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1169 of file api_connection.cpp.

◆ subscribe_home_assistant_states()

void esphome::api::APIConnection::subscribe_home_assistant_states ( const SubscribeHomeAssistantStatesRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1623 of file api_connection.cpp.

◆ subscribe_homeassistant_services()

void esphome::api::APIConnection::subscribe_homeassistant_services ( const SubscribeHomeassistantServicesRequest & msg)
inlineoverridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 388 of file api_connection.h.

◆ subscribe_logs()

void esphome::api::APIConnection::subscribe_logs ( const SubscribeLogsRequest & msg)
inlineoverridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 383 of file api_connection.h.

◆ subscribe_states()

void esphome::api::APIConnection::subscribe_states ( const SubscribeStatesRequest & msg)
inlineoverridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 379 of file api_connection.h.

◆ subscribe_voice_assistant()

void esphome::api::APIConnection::subscribe_voice_assistant ( const SubscribeVoiceAssistantRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1228 of file api_connection.cpp.

◆ switch_command()

void esphome::api::APIConnection::switch_command ( const SwitchCommandRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 580 of file api_connection.cpp.

◆ text_command()

void esphome::api::APIConnection::text_command ( const TextCommandRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 905 of file api_connection.cpp.

◆ time_command()

void esphome::api::APIConnection::time_command ( const TimeCommandRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 829 of file api_connection.cpp.

◆ try_send_alarm_control_panel_info_()

bool esphome::api::APIConnection::try_send_alarm_control_panel_info_ ( alarm_control_panel::AlarmControlPanel * a_alarm_control_panel)
protected

Definition at line 1346 of file api_connection.cpp.

◆ try_send_alarm_control_panel_state_()

bool esphome::api::APIConnection::try_send_alarm_control_panel_state_ ( alarm_control_panel::AlarmControlPanel * a_alarm_control_panel)
protected

Definition at line 1339 of file api_connection.cpp.

◆ try_send_binary_sensor_info_()

bool esphome::api::APIConnection::try_send_binary_sensor_info_ ( binary_sensor::BinarySensor * binary_sensor)
protected

Definition at line 293 of file api_connection.cpp.

◆ try_send_binary_sensor_state_() [1/2]

bool esphome::api::APIConnection::try_send_binary_sensor_state_ ( binary_sensor::BinarySensor * binary_sensor)
protected

Definition at line 283 of file api_connection.cpp.

◆ try_send_binary_sensor_state_() [2/2]

bool esphome::api::APIConnection::try_send_binary_sensor_state_ ( binary_sensor::BinarySensor * binary_sensor,
bool state )
protected

Definition at line 286 of file api_connection.cpp.

◆ try_send_button_info_()

bool esphome::api::APIConnection::try_send_button_info_ ( button::Button * button)
protected

Definition at line 960 of file api_connection.cpp.

◆ try_send_camera_info_()

bool esphome::api::APIConnection::try_send_camera_info_ ( esp32_camera::ESP32Camera * camera)
protected

Definition at line 1139 of file api_connection.cpp.

◆ try_send_climate_info_()

bool esphome::api::APIConnection::try_send_climate_info_ ( climate::Climate * climate)
protected

Definition at line 664 of file api_connection.cpp.

◆ try_send_climate_state_()

bool esphome::api::APIConnection::try_send_climate_state_ ( climate::Climate * climate)
protected

Definition at line 633 of file api_connection.cpp.

◆ try_send_cover_info_()

bool esphome::api::APIConnection::try_send_cover_info_ ( cover::Cover * cover)
protected

Definition at line 324 of file api_connection.cpp.

◆ try_send_cover_state_()

bool esphome::api::APIConnection::try_send_cover_state_ ( cover::Cover * cover)
protected

Definition at line 312 of file api_connection.cpp.

◆ try_send_date_info_()

bool esphome::api::APIConnection::try_send_date_info_ ( datetime::DateEntity * date)
protected

Definition at line 787 of file api_connection.cpp.

◆ try_send_date_state_()

bool esphome::api::APIConnection::try_send_date_state_ ( datetime::DateEntity * date)
protected

Definition at line 777 of file api_connection.cpp.

◆ try_send_datetime_info_()

bool esphome::api::APIConnection::try_send_datetime_info_ ( datetime::DateTimeEntity * datetime)
protected

Definition at line 860 of file api_connection.cpp.

◆ try_send_datetime_state_()

bool esphome::api::APIConnection::try_send_datetime_state_ ( datetime::DateTimeEntity * datetime)
protected

Definition at line 849 of file api_connection.cpp.

◆ try_send_entity_info_()

template<typename ResponseT >
bool esphome::api::APIConnection::try_send_entity_info_ ( esphome::EntityBase * entity,
ResponseT & response,
bool(APIServerConnectionBase::* send_response_func )(const ResponseT &) )
inlineprotected

Generic function for generating entity info response messages.

This is used to reduce duplication in the try_send_*_info functions.

Parameters
entityThe entity to generate info for
responseThe response object
send_response_funcFunction pointer to send the response
Returns
True if the message was sent successfully

Definition at line 504 of file api_connection.h.

◆ try_send_event_() [1/2]

bool esphome::api::APIConnection::try_send_event_ ( event::Event * event)
protected

Definition at line 1398 of file api_connection.cpp.

◆ try_send_event_() [2/2]

bool esphome::api::APIConnection::try_send_event_ ( event::Event * event,
std::string event_type )
protected

Definition at line 1401 of file api_connection.cpp.

◆ try_send_event_info_()

bool esphome::api::APIConnection::try_send_event_info_ ( event::Event * event)
protected

Definition at line 1408 of file api_connection.cpp.

◆ try_send_fan_info_()

bool esphome::api::APIConnection::try_send_fan_info_ ( fan::Fan * fan)
protected

Definition at line 390 of file api_connection.cpp.

◆ try_send_fan_state_()

bool esphome::api::APIConnection::try_send_fan_state_ ( fan::Fan * fan)
protected

Definition at line 374 of file api_connection.cpp.

◆ try_send_light_info_()

bool esphome::api::APIConnection::try_send_light_info_ ( light::LightState * light)
protected

Definition at line 455 of file api_connection.cpp.

◆ try_send_light_state_()

bool esphome::api::APIConnection::try_send_light_state_ ( light::LightState * light)
protected

Definition at line 434 of file api_connection.cpp.

◆ try_send_lock_info_()

bool esphome::api::APIConnection::try_send_lock_info_ ( lock::Lock * a_lock)
protected

Definition at line 995 of file api_connection.cpp.

◆ try_send_lock_state_() [1/2]

bool esphome::api::APIConnection::try_send_lock_state_ ( lock::Lock * a_lock)
protected

Definition at line 985 of file api_connection.cpp.

◆ try_send_lock_state_() [2/2]

bool esphome::api::APIConnection::try_send_lock_state_ ( lock::Lock * a_lock,
lock::LockState state )
protected

Definition at line 988 of file api_connection.cpp.

◆ try_send_log_message()

bool esphome::api::APIConnection::try_send_log_message ( int level,
const char * tag,
const char * line )

Definition at line 1476 of file api_connection.cpp.

◆ try_send_media_player_info_()

bool esphome::api::APIConnection::try_send_media_player_info_ ( media_player::MediaPlayer * media_player)
protected

Definition at line 1086 of file api_connection.cpp.

◆ try_send_media_player_state_()

bool esphome::api::APIConnection::try_send_media_player_state_ ( media_player::MediaPlayer * media_player)
protected

Definition at line 1074 of file api_connection.cpp.

◆ try_send_number_info_()

bool esphome::api::APIConnection::try_send_number_info_ ( number::Number * number)
protected

Definition at line 745 of file api_connection.cpp.

◆ try_send_number_state_() [1/2]

bool esphome::api::APIConnection::try_send_number_state_ ( number::Number * number)
protected

Definition at line 734 of file api_connection.cpp.

◆ try_send_number_state_() [2/2]

bool esphome::api::APIConnection::try_send_number_state_ ( number::Number * number,
float state )
protected

Definition at line 737 of file api_connection.cpp.

◆ try_send_select_info_()

bool esphome::api::APIConnection::try_send_select_info_ ( select::Select * select)
protected

Definition at line 936 of file api_connection.cpp.

◆ try_send_select_state_() [1/2]

bool esphome::api::APIConnection::try_send_select_state_ ( select::Select * select)
protected

Definition at line 925 of file api_connection.cpp.

◆ try_send_select_state_() [2/2]

bool esphome::api::APIConnection::try_send_select_state_ ( select::Select * select,
std::string state )
protected

Definition at line 928 of file api_connection.cpp.

◆ try_send_sensor_info_()

bool esphome::api::APIConnection::try_send_sensor_info_ ( sensor::Sensor * sensor)
protected

Definition at line 538 of file api_connection.cpp.

◆ try_send_sensor_state_() [1/2]

bool esphome::api::APIConnection::try_send_sensor_state_ ( sensor::Sensor * sensor)
protected

Definition at line 527 of file api_connection.cpp.

◆ try_send_sensor_state_() [2/2]

bool esphome::api::APIConnection::try_send_sensor_state_ ( sensor::Sensor * sensor,
float state )
protected

Definition at line 530 of file api_connection.cpp.

◆ try_send_switch_info_()

bool esphome::api::APIConnection::try_send_switch_info_ ( switch_::Switch * a_switch)
protected

Definition at line 572 of file api_connection.cpp.

◆ try_send_switch_state_() [1/2]

bool esphome::api::APIConnection::try_send_switch_state_ ( switch_::Switch * a_switch)
protected

Definition at line 562 of file api_connection.cpp.

◆ try_send_switch_state_() [2/2]

bool esphome::api::APIConnection::try_send_switch_state_ ( switch_::Switch * a_switch,
bool state )
protected

Definition at line 565 of file api_connection.cpp.

◆ try_send_text_info_()

bool esphome::api::APIConnection::try_send_text_info_ ( text::Text * text)
protected

Definition at line 895 of file api_connection.cpp.

◆ try_send_text_sensor_info_()

bool esphome::api::APIConnection::try_send_text_sensor_info_ ( text_sensor::TextSensor * text_sensor)
protected

Definition at line 613 of file api_connection.cpp.

◆ try_send_text_sensor_state_() [1/2]

bool esphome::api::APIConnection::try_send_text_sensor_state_ ( text_sensor::TextSensor * text_sensor)
protected

Definition at line 602 of file api_connection.cpp.

◆ try_send_text_sensor_state_() [2/2]

bool esphome::api::APIConnection::try_send_text_sensor_state_ ( text_sensor::TextSensor * text_sensor,
std::string state )
protected

Definition at line 605 of file api_connection.cpp.

◆ try_send_text_state_() [1/2]

bool esphome::api::APIConnection::try_send_text_state_ ( text::Text * text)
protected

Definition at line 886 of file api_connection.cpp.

◆ try_send_text_state_() [2/2]

bool esphome::api::APIConnection::try_send_text_state_ ( text::Text * text,
std::string state )
protected

Definition at line 887 of file api_connection.cpp.

◆ try_send_time_info_()

bool esphome::api::APIConnection::try_send_time_info_ ( datetime::TimeEntity * time)
protected

Definition at line 823 of file api_connection.cpp.

◆ try_send_time_state_()

bool esphome::api::APIConnection::try_send_time_state_ ( datetime::TimeEntity * time)
protected

Definition at line 813 of file api_connection.cpp.

◆ try_send_update_info_()

bool esphome::api::APIConnection::try_send_update_info_ ( update::UpdateEntity * update)
protected

Definition at line 1447 of file api_connection.cpp.

◆ try_send_update_state_()

bool esphome::api::APIConnection::try_send_update_state_ ( update::UpdateEntity * update)
protected

Definition at line 1428 of file api_connection.cpp.

◆ try_send_valve_info_()

bool esphome::api::APIConnection::try_send_valve_info_ ( valve::Valve * valve)
protected

Definition at line 1040 of file api_connection.cpp.

◆ try_send_valve_state_()

bool esphome::api::APIConnection::try_send_valve_state_ ( valve::Valve * valve)
protected

Definition at line 1032 of file api_connection.cpp.

◆ try_to_clear_buffer()

bool esphome::api::APIConnection::try_to_clear_buffer ( bool log_out_of_space)

Definition at line 1626 of file api_connection.cpp.

◆ unsubscribe_bluetooth_le_advertisements()

void esphome::api::APIConnection::unsubscribe_bluetooth_le_advertisements ( const UnsubscribeBluetoothLEAdvertisementsRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1172 of file api_connection.cpp.

◆ update_command()

void esphome::api::APIConnection::update_command ( const UpdateCommandRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1454 of file api_connection.cpp.

◆ valve_command()

void esphome::api::APIConnection::valve_command ( const ValveCommandRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1051 of file api_connection.cpp.

◆ voice_assistant_get_configuration()

VoiceAssistantConfigurationResponse esphome::api::APIConnection::voice_assistant_get_configuration ( const VoiceAssistantConfigurationRequest & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1292 of file api_connection.cpp.

◆ voice_assistant_set_configuration()

void esphome::api::APIConnection::voice_assistant_set_configuration ( const VoiceAssistantSetConfiguration & msg)
overridevirtual

Implements esphome::api::APIServerConnection.

Definition at line 1318 of file api_connection.cpp.

Field Documentation

◆ APIServer

friend esphome::api::APIConnection::APIServer
protected

Definition at line 427 of file api_connection.h.

◆ client_api_version_major_

uint32_t esphome::api::APIConnection::client_api_version_major_ {0}
protected

Definition at line 540 of file api_connection.h.

◆ client_api_version_minor_

uint32_t esphome::api::APIConnection::client_api_version_minor_ {0}
protected

Definition at line 541 of file api_connection.h.

◆ client_combined_info_

std::string esphome::api::APIConnection::client_combined_info_
protected

Definition at line 539 of file api_connection.h.

◆ client_info_

std::string esphome::api::APIConnection::client_info_
protected

Definition at line 537 of file api_connection.h.

◆ client_peername_

std::string esphome::api::APIConnection::client_peername_
protected

Definition at line 538 of file api_connection.h.

◆ deferred_message_queue_

DeferredMessageQueue esphome::api::APIConnection::deferred_message_queue_
protected

Definition at line 555 of file api_connection.h.

◆ helper_

std::unique_ptr<APIFrameHelper> esphome::api::APIConnection::helper_
protected

Definition at line 535 of file api_connection.h.

◆ image_reader_

esp32_camera::CameraImageReader esphome::api::APIConnection::image_reader_
protected

Definition at line 543 of file api_connection.h.

◆ initial_state_iterator_

InitialStateIterator esphome::api::APIConnection::initial_state_iterator_
protected

Definition at line 556 of file api_connection.h.

◆ last_traffic_

uint32_t esphome::api::APIConnection::last_traffic_
protected

Definition at line 548 of file api_connection.h.

◆ list_entities_iterator_

ListEntitiesIterator esphome::api::APIConnection::list_entities_iterator_
protected

Definition at line 557 of file api_connection.h.

◆ log_subscription_

int esphome::api::APIConnection::log_subscription_ {ESPHOME_LOG_LEVEL_NONE}
protected

Definition at line 547 of file api_connection.h.

◆ next_close_

bool esphome::api::APIConnection::next_close_ = false
protected

Definition at line 553 of file api_connection.h.

◆ next_ping_retry_

uint32_t esphome::api::APIConnection::next_ping_retry_ {0}
protected

Definition at line 549 of file api_connection.h.

◆ parent_

APIServer* esphome::api::APIConnection::parent_
protected

Definition at line 554 of file api_connection.h.

◆ ping_retries_

uint8_t esphome::api::APIConnection::ping_retries_ {0}
protected

Definition at line 550 of file api_connection.h.

◆ proto_write_buffer_

std::vector<uint8_t> esphome::api::APIConnection::proto_write_buffer_
protected

Definition at line 534 of file api_connection.h.

◆ remove_

bool esphome::api::APIConnection::remove_ {false}
protected

Definition at line 530 of file api_connection.h.

◆ sent_ping_

bool esphome::api::APIConnection::sent_ping_ {false}
protected

Definition at line 551 of file api_connection.h.

◆ service_call_subscription_

bool esphome::api::APIConnection::service_call_subscription_ {false}
protected

Definition at line 552 of file api_connection.h.

◆ state_subs_at_

int esphome::api::APIConnection::state_subs_at_ = -1
protected

Definition at line 558 of file api_connection.h.

◆ state_subscription_

bool esphome::api::APIConnection::state_subscription_ {false}
protected

Definition at line 546 of file api_connection.h.

◆ WAITING_FOR_HELLO

enum esphome::api::APIConnection::ConnectionState esphome::api::APIConnection::WAITING_FOR_HELLO
protected

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