15 #ifdef USE_HOMEASSISTANT_TIME 18 #ifdef USE_BLUETOOTH_PROXY 21 #ifdef USE_VOICE_ASSISTANT 28 static const char *
const TAG =
"api.connection";
29 static const int ESP32_CAMERA_STOP_STREAM = 5000;
32 : parent_(parent), initial_state_iterator_(this), list_entities_iterator_(this) {
35 #if defined(USE_API_PLAINTEXT) 37 #elif defined(USE_API_NOISE) 40 #error "No frame helper defined" 59 #ifdef USE_BLUETOOTH_PROXY 64 #ifdef USE_VOICE_ASSISTANT 97 err = this->
helper_->read_packet(&buffer);
122 static uint32_t keepalive = 60000;
123 static uint8_t max_ping_retries = 60;
124 static uint16_t ping_retry_interval = 1000;
125 const uint32_t now =
millis();
130 ESP_LOGW(TAG,
"%s didn't respond to ping request in time. Disconnecting...", this->
client_combined_info_.c_str());
133 ESP_LOGVV(TAG,
"Sending keepalive PING...");
140 ESP_LOGE(TAG,
"%s: Sending keepalive failed %d time(s). Disconnecting...", this->
client_combined_info_.c_str(),
143 ESP_LOGW(TAG,
"%s: Sending keepalive failed %d time(s), will retry in %d ms",
146 ESP_LOGD(TAG,
"%s: Sending keepalive failed %d time(s), will retry in %d ms",
152 #ifdef USE_ESP32_CAMERA 162 buffer.encode_bool(3, done);
168 if (success && done) {
208 #ifdef USE_BINARY_SENSOR 246 if (traits.get_supports_tilt())
247 resp.tilt = cover->
tilt;
248 resp.current_operation = static_cast<enums::CoverOperation>(cover->
current_operation);
271 if (cover ==
nullptr)
278 call.set_command_open();
281 call.set_command_close();
284 call.set_command_stop();
291 call.set_tilt(msg.
tilt);
293 call.set_command_stop();
306 resp.state = fan->
state;
307 if (traits.supports_oscillation())
309 if (traits.supports_speed()) {
310 resp.speed_level = fan->
speed;
312 if (traits.supports_direction())
313 resp.direction = static_cast<enums::FanDirection>(fan->
direction);
314 if (traits.supports_preset_modes())
316 return this->send_fan_state_response(resp);
330 for (
auto const &
preset : traits.supported_preset_modes())
370 resp.state = values.is_on();
372 resp.brightness = values.get_brightness();
373 resp.color_brightness = values.get_color_brightness();
374 resp.red = values.get_red();
375 resp.green = values.get_green();
376 resp.blue = values.get_blue();
377 resp.white = values.get_white();
378 resp.color_temperature = values.get_color_temperature();
379 resp.cold_white = values.get_cold_white();
380 resp.warm_white = values.get_warm_white();
398 for (
auto mode : traits.get_supported_color_modes())
414 msg.
effects.emplace_back(
"None");
416 msg.
effects.push_back(effect->get_name());
422 if (light ==
nullptr)
465 resp.missing_state = !sensor->
has_state();
515 if (a_switch ==
nullptr)
526 #ifdef USE_TEXT_SENSOR 533 resp.state = std::move(state);
534 resp.missing_state = !text_sensor->
has_state();
563 if (traits.get_supports_current_temperature())
565 if (traits.get_supports_two_point_target_temperature()) {
572 resp.fan_mode = static_cast<enums::ClimateFanMode>(climate->
fan_mode.
value());
580 if (traits.get_supports_swing_modes())
581 resp.swing_mode = static_cast<enums::ClimateSwingMode>(climate->
swing_mode);
582 if (traits.get_supports_current_humidity())
584 if (traits.get_supports_target_humidity())
586 return this->send_climate_state_response(resp);
606 for (
auto mode : traits.get_supported_modes())
619 for (
auto fan_mode : traits.get_supported_fan_modes())
621 for (
auto const &
custom_fan_mode : traits.get_supported_custom_fan_modes())
623 for (
auto preset : traits.get_supported_presets())
625 for (
auto const &
custom_preset : traits.get_supported_custom_presets())
627 for (
auto swing_mode : traits.get_supported_swing_modes())
633 if (climate ==
nullptr)
638 call.
set_mode(static_cast<climate::ClimateMode>(msg.
mode));
669 resp.missing_state = !number->
has_state();
694 if (number ==
nullptr)
703 #ifdef USE_DATETIME_DATE 711 resp.year = date->
year;
712 resp.month = date->
month;
713 resp.day = date->
day;
740 #ifdef USE_DATETIME_TIME 748 resp.hour = time->
hour;
749 resp.minute = time->
minute;
750 resp.second = time->
second;
777 #ifdef USE_DATETIME_DATETIME 784 resp.missing_state = !datetime->
has_state();
806 if (datetime ==
nullptr)
822 resp.state = std::move(state);
860 resp.state = std::move(state);
861 resp.missing_state = !select->
has_state();
882 if (select ==
nullptr)
907 if (button ==
nullptr)
941 if (a_lock ==
nullptr)
988 if (valve ==
nullptr)
1000 #ifdef USE_MEDIA_PLAYER 1010 : media_player->
state;
1012 resp.volume = media_player->
volume;
1013 resp.muted = media_player->
is_muted();
1030 for (
auto &supported_format : traits.get_supported_formats()) {
1032 media_format.
format = supported_format.format;
1033 media_format.
sample_rate = supported_format.sample_rate;
1034 media_format.
num_channels = supported_format.num_channels;
1036 media_format.
sample_bytes = supported_format.sample_bytes;
1044 if (media_player ==
nullptr)
1064 #ifdef USE_ESP32_CAMERA 1102 #ifdef USE_HOMEASSISTANT_TIME 1109 #ifdef USE_BLUETOOTH_PROXY 1120 service.legacy_data.assign(service.data.begin(), service.data.end());
1121 service.data.clear();
1124 manufacturer_data.legacy_data.assign(manufacturer_data.data.begin(), manufacturer_data.data.end());
1125 manufacturer_data.data.clear();
1163 #ifdef USE_VOICE_ASSISTANT 1179 if (msg.
port == 0) {
1237 for (
auto &wake_word : config.available_wake_words) {
1239 resp_wake_word.
id = wake_word.id;
1240 resp_wake_word.
wake_word = wake_word.wake_word;
1241 for (
const auto &lang : wake_word.trained_languages) {
1246 for (
auto &wake_word_id : config.active_wake_words) {
1266 #ifdef USE_ALARM_CONTROL_PANEL 1292 if (a_alarm_control_panel ==
nullptr)
1295 auto call = a_alarm_control_panel->
make_call();
1310 call.arm_vacation();
1313 call.arm_custom_bypass();
1319 call.set_code(msg.
code);
1327 resp.
key =
event->get_object_id_hash();
1328 resp.event_type = std::move(event_type);
1333 msg.
key =
event->get_object_id_hash();
1338 msg.
icon =
event->get_icon();
1355 resp.missing_state = !update->
has_state();
1359 resp.has_progress =
true;
1386 if (update ==
nullptr)
1397 ESP_LOGE(TAG,
"UPDATE_COMMAND_NONE not handled. Check client is sending the correct command");
1400 ESP_LOGW(TAG,
"Unknown update command: %" PRIu32, msg.
command);
1413 buffer.encode_uint32(1, static_cast<uint32_t>(level));
1415 buffer.encode_string(3, line, strlen(line));
1427 ESP_LOGV(TAG,
"Hello from client: '%s' | %s | API Version %" PRIu32
".%" PRIu32, this->
client_info_.c_str(),
1432 resp.api_version_minor = 10;
1433 resp.server_info =
App.
get_name() +
" (esphome v" ESPHOME_VERSION
")";
1449 #ifdef USE_HOMEASSISTANT_TIME 1464 resp.esphome_version = ESPHOME_VERSION;
1466 #if defined(USE_ESP8266) || defined(USE_ESP32) 1467 resp.manufacturer =
"Espressif";
1468 #elif defined(USE_RP2040) 1469 resp.manufacturer =
"Raspberry Pi";
1470 #elif defined(USE_BK72XX) 1471 resp.manufacturer =
"Beken";
1472 #elif defined(USE_RTL87XX) 1473 resp.manufacturer =
"Realtek";
1474 #elif defined(USE_HOST) 1475 resp.manufacturer =
"Host";
1477 resp.model = ESPHOME_BOARD;
1478 #ifdef USE_DEEP_SLEEP 1481 #ifdef ESPHOME_PROJECT_NAME 1482 resp.project_name = ESPHOME_PROJECT_NAME;
1483 resp.project_version = ESPHOME_PROJECT_VERSION;
1485 #ifdef USE_WEBSERVER 1486 resp.webserver_port = USE_WEBSERVER_PORT;
1488 #ifdef USE_BLUETOOTH_PROXY 1492 #ifdef USE_VOICE_ASSISTANT 1501 it.callback(msg.
state);
1508 if (service->execute_service(msg)) {
1513 ESP_LOGV(TAG,
"Could not find matching service!");
1522 if (!this->
helper_->can_write_without_blocking()) {
1531 if (!this->
helper_->can_write_without_blocking()) {
1533 if (message_type != 29) {
1534 ESP_LOGV(TAG,
"Cannot send message because of TCP buffer space");
uint32_t supported_features
std::string client_peername_
bool get_force_update() const
Get whether force update mode is enabled.
Base class for all switches.
value_type const & value() const
float current_humidity
The current humidity of the climate device, as reported from the integration.
bool send_list_entities_binary_sensor_response(const ListEntitiesBinarySensorResponse &msg)
bool state
The current on/off state of the fan.
bool send_text_sensor_state(text_sensor::TextSensor *text_sensor, std::string state)
ClimateSwingMode swing_mode
The active swing mode of the climate device.
bool send_alarm_control_panel_state(alarm_control_panel::AlarmControlPanel *a_alarm_control_panel)
bool has_own_name() const
bool send_date_state_response(const DateStateResponse &msg)
bool send_time_info(datetime::TimeEntity *time)
AlarmControlPanelState get_state() const
Get the state.
enums::EntityCategory entity_category
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
std::vector< std::string > supported_preset_modes
LightCall & set_color_brightness(optional< float > brightness)
Set the color brightness of the light from 0.0 (no color) to 1.0 (fully on)
bool oscillating
The current oscillation state of the fan.
std::string custom_preset
bool has_state() const
Return whether this number has gotten a full state yet.
float visual_min_temperature
void datetime_command(const DateTimeCommandRequest &msg) override
bool supports_oscillation
std::vector< uint8_t > * get_buffer() const
void request_image(CameraRequester requester)
std::vector< std::string > active_wake_words
media_player::MediaPlayer * get_media_player_by_key(uint32_t key, bool include_internal=false)
bool send_text_info(text::Text *text)
bool send_climate_info(climate::Climate *climate)
FanDirection direction
The current direction of the fan.
Base class for all cover devices.
const std::vector< UserServiceDescriptor * > & get_user_services() const
LightCall & set_red(optional< float > red)
Set the red RGB value of the light from 0.0 to 1.0.
void start_stream(CameraRequester requester)
enums::EntityCategory entity_category
LightCall & set_color_temperature(optional< float > color_temperature)
Set the color temperature of the light in mireds for CWWW or RGBWW lights.
void on_set_configuration(const std::vector< std::string > &active_wake_words)
void on_voice_assistant_audio(const VoiceAssistantAudio &msg) override
bool is_status_binary_sensor
void bluetooth_gatt_notify(const BluetoothGATTNotifyRequest &msg) override
TextMode get_mode() const
bool send_cover_info(cover::Cover *cover)
bool send_text_state_response(const TextStateResponse &msg)
bool send_ping_request(const PingRequest &msg)
LightCall & set_cold_white(optional< float > cold_white)
Set the cold white value of the light from 0.0 to 1.0.
bool send_switch_state(switch_::Switch *a_switch, bool state)
int get_bluetooth_connections_limit()
TimeCall & set_time(uint8_t hour, uint8_t minute, uint8_t second)
void update_command(const UpdateCommandRequest &msg) override
float target_temperature
The target temperature of the climate device.
VoiceAssistant * global_voice_assistant
std::string get_effect_name()
Return the name of the current effect, or if no effect is active "None".
climate::Climate * get_climate_by_key(uint32_t key, bool include_internal=false)
uint32_t transition_length
void on_fatal_error() override
std::string get_device_class()
Get the device class, using the manual override if set.
select::Select * get_select_by_key(uint32_t key, bool include_internal=false)
CoverCall make_call()
Construct a new cover call used to control the cover.
void alarm_control_panel_command(const AlarmControlPanelCommandRequest &msg) override
bool send_event_response(const EventResponse &msg)
bool global_has_deep_sleep
void on_voice_assistant_response(const VoiceAssistantResponse &msg) override
BluetoothConnectionsFreeResponse subscribe_bluetooth_connections_free(const SubscribeBluetoothConnectionsFreeRequest &msg) override
datetime::DateTimeEntity * get_datetime_by_key(uint32_t key, bool include_internal=false)
std::string get_default_unique_id(const std::string &component_type, EntityBase *entity)
InitialStateIterator initial_state_iterator_
const char * api_error_to_str(APIError err)
bool send_valve_state(valve::Valve *valve)
virtual std::string unique_id()
Override this method to set the unique ID of this sensor.
TextCall & set_value(const std::string &value)
CoverOperation current_operation
The current operation of the cover (idle, opening, closing).
std::vector< VoiceAssistantWakeWord > available_wake_words
float position
The position of the valve from 0.0 (fully closed) to 1.0 (fully open).
std::vector< enums::ClimatePreset > supported_presets
enums::EntityCategory entity_category
bool has_target_temperature
bool send_camera_info(esp32_camera::ESP32Camera *camera)
std::vector< std::string > options
bool send_fan_state(fan::Fan *fan)
A more user-friendly version of struct tm from time.h.
virtual FanTraits get_traits()=0
enums::EntityCategory entity_category
enums::EntityCategory entity_category
std::set< std::string > get_event_types() const
lock::Lock * get_lock_by_key(uint32_t key, bool include_internal=false)
bool send_binary_sensor_state_response(const BinarySensorStateResponse &msg)
const UpdateState & state
bool check_password(const std::string &password) const
bool supports_effects()
Return whether the light has any effects that meet the trait requirements.
bool send_climate_state(climate::Climate *climate)
bool legacy_supports_color_temperature
uint32_t get_legacy_version() const
ClimateMode mode
The active mode of the climate device.
virtual bool get_requires_code() const =0
Returns if the alarm_control_panel has a code.
bool send_button_info(button::Button *button)
bool send_list_entities_valve_response(const ListEntitiesValveResponse &msg)
button::Button * get_button_by_key(uint32_t key, bool include_internal=false)
int32_t supported_speed_count
virtual bool assumed_state()
Return whether this switch uses an assumed state - i.e.
std::string latest_version
bool send_list_entities_fan_response(const ListEntitiesFanResponse &msg)
DisconnectResponse disconnect(const DisconnectRequest &msg) override
virtual bool is_status_binary_sensor() const
bool send_number_state_response(const NumberStateResponse &msg)
std::string current_version
bool send_lock_state(lock::Lock *a_lock, lock::LockState state)
bool send_text_state(text::Text *text, std::string state)
uint32_t api_version_major
uint32_t api_version_major
const std::string & get_area() const
Get the area of this Application set by pre_setup().
const std::string & get_friendly_name() const
Get the friendly name of this Application set by pre_setup().
std::unique_ptr< APIFrameHelper > helper_
enums::ClimateSwingMode swing_mode
float target_temperature_high
The maximum target temperature of the climate device, for climate devices with split target temperatu...
void media_player_command(const MediaPlayerCommandRequest &msg) override
enums::EntityCategory entity_category
float current_temperature
The current temperature of the climate device, as reported from the integration.
bool send_list_entities_select_response(const ListEntitiesSelectResponse &msg)
Color temperature can be controlled.
void client_subscription(api::APIConnection *client, bool subscribe)
HomeassistantTime * global_homeassistant_time
LightCall & set_color_mode(optional< ColorMode > color_mode)
Set the color mode of the light.
enums::ColorMode color_mode
void send_camera_state(std::shared_ptr< esp32_camera::CameraImage > image)
bool send_date_info(datetime::DateEntity *date)
std::vector< BluetoothServiceData > service_data
NumberCall & set_value(float value)
bool send_list_entities_event_response(const ListEntitiesEventResponse &msg)
enums::EntityCategory entity_category
bool supports_two_point_target_temperature
void execute_service(const ExecuteServiceRequest &msg) override
std::vector< std::string > supported_custom_presets
int get_max_length() const
Base-class for all text inputs.
void consume_data(size_t consumed)
ValveCall & set_command_stop()
Set the command to stop the valve.
TextCall make_call()
Instantiate a TextCall object to modify this text component's state.
void subscribe_voice_assistant(const SubscribeVoiceAssistantRequest &msg) override
LightCall & set_transition_length(optional< uint32_t > transition_length)
Set the transition length of this call in milliseconds.
float target_humidity
The target humidity of the climate device.
virtual ValveTraits get_traits()=0
ClimateCall & set_swing_mode(ClimateSwingMode swing_mode)
Set the swing mode of the climate device.
AlarmControlPanelCall make_call()
Make a AlarmControlPanelCall.
bool send_number_info(number::Number *number)
bool send_event(event::Event *event, std::string event_type)
void subscribe_bluetooth_le_advertisements(const SubscribeBluetoothLEAdvertisementsRequest &msg) override
uint32_t max_active_wake_words
uint32_t api_version_minor
float tilt
The current tilt value of the cover from 0.0 to 1.0.
bool is_connected()
Return whether the node is connected to the network (through wifi, eth, ...)
void stop_stream(CameraRequester requester)
std::string get_object_id() const
uint32_t IRAM_ATTR HOT millis()
std::string client_combined_info_
ClimateSwingMode swing_mode
void on_no_setup_connection() override
void trigger(Ts... x)
Inform the parent automation that the event has triggered.
alarm_control_panel::AlarmControlPanel * get_alarm_control_panel_by_key(uint32_t key, bool include_internal=false)
ValveCall make_call()
Construct a new valve call used to control the valve.
bool send_binary_sensor_info(binary_sensor::BinarySensor *binary_sensor)
enums::ClimateFanMode fan_mode
optional< std::string > custom_fan_mode
The active custom fan mode of the climate device.
cover::Cover * get_cover_by_key(uint32_t key, bool include_internal=false)
virtual CoverTraits get_traits()=0
void bluetooth_device_request(const api::BluetoothDeviceRequest &msg)
BluetoothProxy * global_bluetooth_proxy
Device is in away preset.
uint8_t * peek_data_buffer()
ClimateCall & set_target_temperature_low(float target_temperature_low)
Set the low point target temperature of the climate device.
bool send_select_info(select::Select *select)
bool send_event_info(event::Event *event)
bool send_update_info(update::UpdateEntity *update)
virtual std::string unique_id()
Override this method to set the unique ID of this sensor.
bool send_bluetooth_le_advertisement_response(const BluetoothLEAdvertisementResponse &msg)
ClimateCall make_call()
Make a climate device control call, this is used to control the climate device, see the ClimateCall d...
std::vector< std::string > event_types
fan::Fan * get_fan_by_key(uint32_t key, bool include_internal=false)
float visual_max_temperature
void perform()
Perform the valve call.
void set_epoch_time(uint32_t epoch)
void lock()
Turn this lock on.
int32_t accuracy_decimals
float visual_max_humidity
enums::EntityCategory entity_category
std::string get_icon() const
std::shared_ptr< APINoiseContext > get_noise_ctx()
ClimateCall & set_target_temperature(float target_temperature)
Set the target temperature of the climate device.
enums::ClimatePreset preset
void time_command(const TimeCommandRequest &msg) override
void date_command(const DateCommandRequest &msg) override
enums::EntityCategory entity_category
Trigger< std::string, std::string > * get_client_connected_trigger() const
bool send_list_entities_text_sensor_response(const ListEntitiesTextSensorResponse &msg)
FanCall & set_speed(int speed)
std::vector< std::string > trained_languages
bool send_sensor_state(sensor::Sensor *sensor, float state)
Brightness of cold and warm white output can be controlled.
void bluetooth_gatt_read(const api::BluetoothGATTReadRequest &msg)
bool has_transition_length
bool send_select_state(select::Select *select, std::string state)
uint32_t get_legacy_version() const
std::vector< std::string > get_options() const
bool send_list_entities_light_response(const ListEntitiesLightResponse &msg)
DateCall & set_date(uint16_t year, uint8_t month, uint8_t day)
enums::EntityCategory entity_category
ESP32Camera * global_esp32_camera
optional< ClimatePreset > preset
The active preset of the climate device.
enums::FanDirection direction
const UpdateInfo & update_info
uint32_t client_api_version_minor_
std::vector< std::string > effects
time_t timestamp
unix epoch time (seconds since UTC Midnight January 1, 1970)
bool send_valve_info(valve::Valve *valve)
bool send_text_sensor_state_response(const TextSensorStateResponse &msg)
virtual bool has_state() const
Return whether this binary sensor has outputted a state.
std::vector< uint8_t > proto_write_buffer_
bool send_list_entities_cover_response(const ListEntitiesCoverResponse &msg)
bool send_log_message(int level, const char *tag, const char *line)
Base-class for all numbers.
bool send_datetime_info(datetime::DateTimeEntity *datetime)
bool send_time_state(datetime::TimeEntity *time)
Brightness of white channel can be controlled separately from other channels.
int speed
The current fan speed level.
bool send_list_entities_camera_response(const ListEntitiesCameraResponse &msg)
ClimateCall & set_preset(ClimatePreset preset)
Set the preset of the climate device.
bool has_state() const
Return whether this text input has gotten a full state yet.
std::vector< std::string > supported_custom_fan_modes
BedjetMode mode
BedJet operating mode.
bool supports_target_humidity
enums::LockCommand command
bool send_list_entities_button_response(const ListEntitiesButtonResponse &msg)
bool has_state() const
Return whether this Datetime has gotten a full state yet.
void on_voice_assistant_announce_request(const VoiceAssistantAnnounceRequest &msg) override
bool supports_current_temperature
ClimateCall & set_fan_mode(ClimateFanMode fan_mode)
Set the fan mode of the climate device.
bool send_media_player_info(media_player::MediaPlayer *media_player)
bool send_list_entities_media_player_response(const ListEntitiesMediaPlayerResponse &msg)
void bluetooth_gatt_write(const BluetoothGATTWriteRequest &msg) override
uint32_t client_api_version_major_
ClimateTraits get_traits()
Get the traits of this climate device with all overrides applied.
void turn_on()
Turn this switch on.
bool send_alarm_control_panel_info(alarm_control_panel::AlarmControlPanel *a_alarm_control_panel)
SelectCall make_call()
Instantiate a SelectCall object to modify this select component's state.
std::string get_unit_of_measurement()
Get the unit of measurement, using the manual override if set.
uint32_t get_feature_flags() const
bool send_binary_sensor_state(binary_sensor::BinarySensor *binary_sensor, bool state)
void bluetooth_device_request(const BluetoothDeviceRequest &msg) override
bool send_fan_info(fan::Fan *fan)
enums::AlarmControlPanelStateCommand command
float target_temperature_high
FanCall & set_oscillating(bool oscillating)
Application App
Global storage of Application pointer - only one Application can exist.
void bluetooth_gatt_write(const api::BluetoothGATTWriteRequest &msg)
std::string unit_of_measurement
StateClass get_state_class()
Get the state class, using the manual override if set.
bool send_update_state(update::UpdateEntity *update)
bool has_target_temperature_high
std::vector< std::string > active_wake_words
enums::EntityCategory entity_category
const std::vector< LightEffect * > & get_effects() const
Get all effects for this light state.
ColorMode get_color_mode() const
Get the color mode of these light color values.
LightCall & set_state(optional< bool > state)
Set the binary ON/OFF state of the light.
void on_disconnect_response(const DisconnectResponse &value) override
light::LightState * get_light_by_key(uint32_t key, bool include_internal=false)
enums::EntityCategory entity_category
void on_get_time_response(const GetTimeResponse &value) override
bool get_assumed_state() const
void button_command(const ButtonCommandRequest &msg) override
void bluetooth_gatt_write_descriptor(const api::BluetoothGATTWriteDescriptorRequest &msg)
Master brightness of the light can be controlled.
void bluetooth_gatt_read_descriptor(const BluetoothGATTReadDescriptorRequest &msg) override
const std::string & get_name() const
Get the name of this Application set by pre_setup().
bool send_list_entities_number_response(const ListEntitiesNumberResponse &msg)
bool send_switch_state_response(const SwitchStateResponse &msg)
bool has_target_temperature_low
enums::EntityCategory entity_category
bool send_cover_state(cover::Cover *cover)
bool read_message(uint32_t msg_size, uint32_t msg_type, uint8_t *msg_data) override
LightCall & set_warm_white(optional< float > warm_white)
Set the warm white value of the light from 0.0 to 1.0.
VoiceAssistantConfigurationResponse voice_assistant_get_configuration(const VoiceAssistantConfigurationRequest &msg) override
void subscribe_home_assistant_states(const SubscribeHomeAssistantStatesRequest &msg) override
switch_::Switch * get_switch_by_key(uint32_t key, bool include_internal=false)
bool send_list_entities_lock_response(const ListEntitiesLockResponse &msg)
ClimateCall & set_target_humidity(float target_humidity)
Set the target humidity of the climate device.
void unsubscribe_api_connection(api::APIConnection *api_connection)
std::string unit_of_measurement
bool send_date_time_state_response(const DateTimeStateResponse &msg)
bool send_buffer(ProtoWriteBuffer buffer, uint32_t message_type) override
esphome::binary_sensor::BinarySensor * binary_sensor
void bluetooth_gatt_write_descriptor(const BluetoothGATTWriteDescriptorRequest &msg) override
bool supports_current_humidity
void unsubscribe_bluetooth_le_advertisements(const UnsubscribeBluetoothLEAdvertisementsRequest &msg) override
void bluetooth_gatt_get_services(const BluetoothGATTGetServicesRequest &msg) override
bool send_list_entities_sensor_response(const ListEntitiesSensorResponse &msg)
std::vector< enums::ClimateFanMode > supported_fan_modes
void on_audio(const api::VoiceAssistantAudio &msg)
bool requires_code_to_arm
optional< std::string > custom_preset
The active custom preset mode of the climate device.
LightCall & set_effect(optional< std::string > effect)
Set the effect of the light by its name.
bool send_list_entities_alarm_control_panel_response(const ListEntitiesAlarmControlPanelResponse &msg)
ClimateCall & set_target_temperature_high(float target_temperature_high)
Set the high point target temperature of the climate device.
esp32_camera::CameraImageReader image_reader_
void bluetooth_gatt_notify(const api::BluetoothGATTNotifyRequest &msg)
void set_image(std::shared_ptr< CameraImage > image)
bool send_select_state_response(const SelectStateResponse &msg)
optional< ClimateFanMode > fan_mode
The active fan mode of the climate device.
float position
The position of the cover from 0.0 (fully closed) to 1.0 (fully open).
void on_timer_event(const api::VoiceAssistantTimerEventResponse &msg)
void switch_command(const SwitchCommandRequest &msg) override
ConnectResponse connect(const ConnectRequest &msg) override
bool send_light_info(light::LightState *light)
int get_bluetooth_connections_free()
bool has_color_temperature
EntityCategory get_entity_category() const
datetime::DateEntity * get_date_by_key(uint32_t key, bool include_internal=false)
bool legacy_supports_away
FanCall & set_state(bool binary_state)
void select_command(const SelectCommandRequest &msg) override
float target_temperature_low
std::string custom_fan_mode
bool send_light_state_response(const LightStateResponse &msg)
bool send_sensor_info(sensor::Sensor *sensor)
ESPTime state_as_esptime() const override
FanCall & set_preset_mode(const std::string &preset_mode)
void open()
Open (unlatch) this lock.
DeviceInfoResponse device_info(const DeviceInfoRequest &msg) override
bool send_list_entities_date_time_response(const ListEntitiesDateTimeResponse &msg)
bool send_date_state(datetime::DateEntity *date)
enums::EntityCategory entity_category
bool send_media_player_state_response(const MediaPlayerStateResponse &msg)
text::Text * get_text_by_key(uint32_t key, bool include_internal=false)
bool send_subscribe_home_assistant_state_response(const SubscribeHomeAssistantStateResponse &msg)
ClimateCall & set_mode(ClimateMode mode)
Set the mode of the climate device.
const std::vector< HomeAssistantStateSubscription > & get_state_subs() const
number::Number * get_number_by_key(uint32_t key, bool include_internal=false)
enums::EntityCategory entity_category
bool send_list_entities_switch_response(const ListEntitiesSwitchResponse &msg)
uint32_t get_feature_flags() const
enums::UpdateCommand command
LightCall & set_flash_length(optional< uint32_t > flash_length)
Start and set the flash length of this call in milliseconds.
bool send_list_entities_date_response(const ListEntitiesDateResponse &msg)
bool get_requires_code() const
LightCall & set_green(optional< float > green)
Set the green RGB value of the light from 0.0 to 1.0.
bool uses_password() const
enums::EntityCategory entity_category
Base-class for all selects.
bool send_light_state(light::LightState *light)
enums::EntityCategory entity_category
std::vector< enums::ColorMode > supported_color_modes
void set_timeout(Component *component, const std::string &name, uint32_t timeout, std::function< void()> func)
Implementation of SPI Controller mode.
void on_unauthenticated_access() override
bool has_state() const
Return whether this sensor has gotten a full state (that passed through all filters) yet...
void bluetooth_gatt_read_descriptor(const api::BluetoothGATTReadDescriptorRequest &msg)
void text_command(const TextCommandRequest &msg) override
float get_min_value() const
bool has_state() const
Return whether this select component has gotten a full state yet.
void lock_command(const LockCommandRequest &msg) override
std::vector< BluetoothServiceData > manufacturer_data
void unlock()
Turn this lock off.
Base class for all valve devices.
bool send_media_player_state(media_player::MediaPlayer *media_player)
bool send_sensor_state_response(const SensorStateResponse &msg)
bool send_cover_state_response(const CoverStateResponse &msg)
ValveOperation current_operation
The current operation of the valve (idle, opening, closing).
bool send_list_entities_text_response(const ListEntitiesTextResponse &msg)
Base class for all binary_sensor-type classes.
Color can be controlled using RGB format (includes a brightness control for the color).
LightColorValues remote_values
The remote color values reported to the frontend.
bool send_list_entities_update_response(const ListEntitiesUpdateResponse &msg)
float visual_target_temperature_step
LockState
Enum for all states a lock can be in.
void light_command(const LightCommandRequest &msg) override
bool send_lock_info(lock::Lock *a_lock)
bool send_list_entities_time_response(const ListEntitiesTimeResponse &msg)
NumberMode get_mode() const
bool legacy_supports_brightness
valve::Valve * get_valve_by_key(uint32_t key, bool include_internal=false)
const Configuration & get_configuration()
bool send_alarm_control_panel_state_response(const AlarmControlPanelStateResponse &msg)
bool send_list_entities_climate_response(const ListEntitiesClimateResponse &msg)
int8_t get_accuracy_decimals()
Get the accuracy in decimals, using the manual override if set.
void on_voice_assistant_timer_event_response(const VoiceAssistantTimerEventResponse &msg) override
LightCall & set_white(optional< float > white)
Set the white value value of the light from 0.0 to 1.0 for RGBW[W] lights.
LightCall & set_brightness(optional< float > brightness)
Set the target brightness of the light from 0.0 (fully off) to 1.0 (fully on)
bool send_datetime_state(datetime::DateTimeEntity *datetime)
update::UpdateEntity * get_update_by_key(uint32_t key, bool include_internal=false)
void number_command(const NumberCommandRequest &msg) override
ListEntitiesIterator list_entities_iterator_
void subscribe_api_connection(api::APIConnection *api_connection, uint32_t flags)
float visual_min_humidity
int get_min_length() const
bool send_switch_info(switch_::Switch *a_switch)
bool send_text_sensor_info(text_sensor::TextSensor *text_sensor)
enums::LegacyCoverCommand legacy_command
Base-class for all sensors.
std::string get_mac_address_pretty()
Get the device MAC address as a string, in colon-separated uppercase hex notation.
datetime::TimeEntity * get_time_by_key(uint32_t key, bool include_internal=false)
bool send_lock_state_response(const LockStateResponse &msg)
void on_home_assistant_state_response(const HomeAssistantStateResponse &msg) override
virtual uint32_t get_supported_features() const =0
A numeric representation of the supported features as per HomeAssistant.
LightCall & set_blue(optional< float > blue)
Set the blue RGB value of the light from 0.0 to 1.0.
std::vector< enums::ClimateSwingMode > supported_swing_modes
void on_announce(const api::VoiceAssistantAnnounceRequest &msg)
void on_voice_assistant_event_response(const VoiceAssistantEventResponse &msg) override
DateTimeCall & set_datetime(uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second)
enums::SensorStateClass state_class
HelloResponse hello(const HelloRequest &msg) override
bool send_valve_state_response(const ValveStateResponse &msg)
float get_max_value() const
bool has_color_brightness
float visual_current_temperature_step
std::string get_compilation_time() const
ValveCall & set_position(float position)
Set the call to a certain target position.
bool send_bluetooth_le_advertisement(const BluetoothLEAdvertisementResponse &msg)
enums::EntityCategory entity_category
bool send_time_state_response(const TimeStateResponse &msg)
enums::EntityCategory entity_category
std::vector< uint8_t > container
bool is_disabled_by_default() const
void climate_command(const ClimateCommandRequest &msg) override
bool send_number_state(number::Number *number, float state)
APIConnection(std::unique_ptr< socket::Socket > socket, APIServer *parent)
ProtoWriteBuffer create_buffer() override
bool get_supports_open() const
uint32_t get_object_id_hash()
uint32_t next_ping_retry_
esphome::sensor::Sensor * sensor
std::string get_pattern() const
float target_temperature_low
The minimum target temperature of the climate device, for climate devices with split target temperatu...
SelectCall & set_option(const std::string &option)
void cover_command(const CoverCommandRequest &msg) override
void bluetooth_gatt_send_services(const api::BluetoothGATTGetServicesRequest &msg)
std::vector< enums::ClimateMode > supported_modes
const StringRef & get_name() const
void bluetooth_gatt_read(const BluetoothGATTReadRequest &msg) override
void camera_image(const CameraImageRequest &msg) override
FanCall & set_direction(FanDirection direction)
bool legacy_supports_white_value
void valve_command(const ValveCommandRequest &msg) override
void voice_assistant_set_configuration(const VoiceAssistantSetConfiguration &msg) override
Base class for all locks.
ClimateAction action
The active state of the climate device.
ClimateDevice - This is the base class for all climate integrations.
void on_event(const api::VoiceAssistantEventResponse &msg)
void turn_off()
Turn this switch off.
void IRAM_ATTR HOT delay(uint32_t ms)
virtual bool get_requires_code_to_arm() const =0
Returns if the alarm_control_panel requires a code to arm.
void fan_command(const FanCommandRequest &msg) override
enums::EntityCategory entity_category
bool send_update_state_response(const UpdateStateResponse &msg)