8#if defined(USE_API_NOISE) || defined(USE_NOISE_SPARE_EPHEMERAL)
21#ifdef USE_PROVISIONING
37#ifdef USE_API_USER_DEFINED_ACTIONS
39class UserServiceDescriptor;
47#if defined(USE_API_NOISE) && defined(USE_OTA_ENCRYPTION_PROVISIONED)
61 void setup()
override;
69 void on_log(uint8_t level,
const char *tag,
const char *
message,
size_t message_len);
72 void on_camera_image(
const std::shared_ptr<camera::CameraImage> &image)
override;
84#ifndef USE_API_NOISE_PSK_FROM_YAML
94#ifdef USE_API_OUTGOING_CONNECTION
100#ifdef USE_BINARY_SENSOR
118#ifdef USE_TEXT_SENSOR
127#ifdef USE_DATETIME_DATE
130#ifdef USE_DATETIME_TIME
133#ifdef USE_DATETIME_DATETIME
148#ifdef USE_MEDIA_PLAYER
151#ifdef USE_WATER_HEATER
154#ifdef USE_API_HOMEASSISTANT_SERVICES
157#ifdef USE_API_HOMEASSISTANT_ACTION_RESPONSES
162#ifdef USE_API_HOMEASSISTANT_ACTION_RESPONSES_JSON
164 size_t response_data_len);
168#ifdef USE_API_USER_DEFINED_ACTIONS
172#ifdef USE_API_CUSTOM_SERVICES
176#ifdef USE_API_USER_DEFINED_ACTION_RESPONSES
184#ifdef USE_API_USER_DEFINED_ACTION_RESPONSES_JSON
186 const uint8_t *response_data,
size_t response_data_len);
190#ifdef USE_HOMEASSISTANT_TIME
194#ifdef USE_ALARM_CONTROL_PANEL
203#ifdef USE_ZWAVE_PROXY
206#ifdef USE_SERIAL_PROXY_USB_IDENTITY
237#ifdef USE_API_HOMEASSISTANT_STATES
262 std::function<
void(
const std::string &)> &&f);
264 std::function<
void(
const std::string &)> &&f);
266 const std::vector<HomeAssistantStateSubscription> &
get_state_subs()
const;
268#ifdef USE_API_USER_DEFINED_ACTIONS
272#ifdef USE_API_CLIENT_CONNECTED_TRIGGER
275#ifdef USE_API_CLIENT_DISCONNECTED_TRIGGER
286#ifdef USE_API_OUTGOING_CONNECTION
295#ifdef USE_PROVISIONING
309#ifndef USE_API_NOISE_PSK_FROM_YAML
316#ifdef USE_API_HOMEASSISTANT_STATES
321 std::function<
void(
StringRef)> &&f,
bool once);
324 std::function<
void(
const std::string &)> &&f,
bool once);
337#ifdef USE_API_CLIENT_CONNECTED_TRIGGER
340#ifdef USE_API_CLIENT_DISCONNECTED_TRIGGER
349 std::array<APIConnectionPtr, MAX_API_CONNECTIONS>
clients_{};
356#ifdef USE_API_HOMEASSISTANT_STATES
359#ifdef USE_API_USER_DEFINED_ACTIONS
361#ifdef USE_API_USER_DEFINED_ACTION_RESPONSES
373#ifdef USE_API_HOMEASSISTANT_ACTION_RESPONSES
387#ifdef USE_API_OUTGOING_CONNECTION
391#if defined(USE_PROVISIONING) && defined(USE_API_NOISE)
396#ifdef USE_NOISE_SPARE_EPHEMERAL
401#ifndef USE_API_NOISE_PSK_FROM_YAML
406#ifdef USE_API_OUTGOING_CONNECTION
StringRef is a reference to a string owned by something else.
Byte buffer that skips zero-initialization on resize().
const APIConnectionPtr * end() const
ActiveClientsView(const APIConnectionPtr *b, const APIConnectionPtr *e)
const APIConnectionPtr * begin() const
void on_media_player_update(media_player::MediaPlayer *obj)
void refill_spare_ephemeral_()
void on_log(uint8_t level, const char *tag, const char *message, size_t message_len)
bool is_connected_with_state_subscription() const
OutgoingConnectionManager outgoing_conn_
Trigger< std::string, std::string > * get_client_connected_trigger()
void on_valve_update(valve::Valve *obj)
std::array< APIConnectionPtr, MAX_API_CONNECTIONS > clients_
uint16_t get_batch_delay() const
std::unique_ptr< APIConnection > APIConnectionPtr
void register_action_response_callback(uint32_t call_id, ActionResponseCallback callback)
void on_lock_update(lock::Lock *obj)
void send_infrared_rf_receive_event(uint32_t device_id, uint32_t key, const std::vector< int32_t > *timings)
void on_update(update::UpdateEntity *obj)
APIBuffer & get_shared_buffer_ref()
void on_binary_sensor_update(binary_sensor::BinarySensor *obj)
void add_state_subscription_(const char *entity_id, const char *attribute, std::function< void(StringRef)> &&f, bool once)
void get_home_assistant_state(const char *entity_id, const char *attribute, std::function< void(StringRef)> &&f)
Trigger< std::string, std::string > * get_client_disconnected_trigger()
void on_sensor_update(sensor::Sensor *obj)
bool at_client_limit_() const
void on_switch_update(switch_::Switch *obj)
void on_alarm_control_panel_update(alarm_control_panel::AlarmControlPanel *obj)
void on_camera_image(const std::shared_ptr< camera::CameraImage > &image) override
std::vector< UserServiceDescriptor * > user_services_
void set_noise_psk(const uint8_t *psk)
psk points at 32 bytes that live in flash for the life of the program
void socket_failed_(const LogString *msg)
Log the failure, drop the listen socket, and mark the component failed unless this build can still di...
bool load_and_apply_noise_psk_()
const std::vector< UserServiceDescriptor * > & get_user_services() const
void initialize_user_services(std::initializer_list< UserServiceDescriptor * > services)
void set_port(uint16_t port)
void dump_config() override
void unregister_active_action_calls_for_connection(APIConnection *conn)
void handle_disconnect(APIConnection *conn)
void set_batch_delay(uint16_t batch_delay)
void set_reboot_timeout(uint32_t reboot_timeout)
Trigger< std::string, std::string > client_connected_trigger_
void set_listen_backlog(uint8_t listen_backlog)
void send_action_response(uint32_t action_call_id, bool success, StringRef error_message)
void on_fan_update(fan::Fan *obj)
void on_number_update(number::Number *obj)
void register_user_service(UserServiceDescriptor *descriptor)
bool is_connected(bool state_subscription_only) const
void on_climate_update(climate::Climate *obj)
uint8_t api_connection_count_
bool is_connected() const
void unregister_active_action_call(uint32_t action_call_id)
void send_homeassistant_action(const HomeassistantActionRequest &call)
socket::ListenSocket * socket_
uint32_t next_action_call_id_
void on_select_update(select::Select *obj)
std::vector< PendingActionResponse > action_response_callbacks_
void on_text_sensor_update(text_sensor::TextSensor *obj)
const std::vector< HomeAssistantStateSubscription > & get_state_subs() const
void on_cover_update(cover::Cover *obj)
void send_serial_proxy_identity(const SerialProxyIdentity &msg)
Tell every subscribed client that a serial proxy port's identity changed.
uint8_t provisioning_source_
uint8_t outgoing_target_count_
void subscribe_home_assistant_state(const char *entity_id, const char *attribute, std::function< void(StringRef)> &&f)
void on_date_update(datetime::DateEntity *obj)
void handle_action_response(uint32_t call_id, bool success, StringRef error_message)
std::function< void(const class ActionResponse &)> ActionResponseCallback
void on_light_update(light::LightState *obj)
void on_event(event::Event *obj)
bool provisioning_pending_() const
bool update_noise_psk_(const SavedNoisePsk &new_psk, const LogString *save_log_msg, const LogString *fail_log_msg, bool make_active)
ESPPreferenceObject noise_pref_
Trigger< std::string, std::string > client_disconnected_trigger_
std::vector< HomeAssistantStateSubscription > state_subs_
bool clear_noise_psk(bool make_active=true)
ActiveClientsView active_clients() const
uint16_t get_port() const
void on_outgoing_target_client(APIConnection *conn)
void __attribute__((noinline)) accept_new_connections_()
bool has_outgoing_target_client_() const
bool save_noise_psk(noise::psk_t psk, bool make_active=true)
void on_water_heater_update(water_heater::WaterHeater *obj)
void on_time_update(datetime::TimeEntity *obj)
APIConnection * add_client_(std::unique_ptr< socket::Socket > sock)
Takes the socket into a new connection and starts it; callers must have checked at_client_limit_() fi...
std::vector< ActiveActionCall > active_action_calls_
APIConnection * add_outgoing_client_(std::unique_ptr< socket::Socket > sock)
APIBuffer shared_write_buffer_
void __attribute__((noinline)) remove_client_(uint8_t client_index)
float get_setup_priority() const override
void on_text_update(text::Text *obj)
uint32_t register_active_action_call(uint32_t client_call_id, APIConnection *conn)
void on_datetime_update(datetime::DateTimeEntity *obj)
noise::NoiseContext noise_ctx_
void on_shutdown() override
void on_zwave_proxy_request(const ZWaveProxyRequest &msg)
noise::NoiseContext & get_noise_ctx()
Dials out when no dial-back target client is connected.
Base class for all binary_sensor-type classes.
Listener interface for camera events.
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.
void set_psk(const uint8_t *psk)
psk points at 32 bytes that outlive the context (PROGMEM or caller owned RAM); nullptr means no key.
Base-class for all numbers.
bool window_pending() const
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.
const LogString * message
std::vector< uint8_t > & out
APIServer * global_api_server
struct esphome::api::SavedOutgoingTarget PACKED
bool load_saved_noise_psk(noise::psk_t &out)
One-shot read of the provisioned key for a boot without an api server (safe mode); false when there i...
std::array< uint8_t, 32 > psk_t
ProvisioningManager * global_provisioning_manager
constexpr float AFTER_WIFI
For components that should be initialized after WiFi is connected.
APIConnection * connection
std::unique_ptr< std::string > entity_id_dynamic_storage
std::function< void(StringRef)> callback
std::unique_ptr< std::string > attribute_dynamic_storage
ActionResponseCallback callback