mirror of
https://github.com/esphome/esphome.git
synced 2025-08-02 16:37:46 +00:00
Merge remote-tracking branch 'upstream/dev' into entity_dupe_code
This commit is contained in:
commit
0448a66960
@ -118,10 +118,6 @@ class ADCSensor : public sensor::Sensor, public PollingComponent, public voltage
|
|||||||
void set_autorange(bool autorange) { this->autorange_ = autorange; }
|
void set_autorange(bool autorange) { this->autorange_ = autorange; }
|
||||||
#endif // USE_ESP32
|
#endif // USE_ESP32
|
||||||
|
|
||||||
#ifdef USE_ESP8266
|
|
||||||
std::string unique_id() override;
|
|
||||||
#endif // USE_ESP8266
|
|
||||||
|
|
||||||
#ifdef USE_RP2040
|
#ifdef USE_RP2040
|
||||||
void set_is_temperature() { this->is_temperature_ = true; }
|
void set_is_temperature() { this->is_temperature_ = true; }
|
||||||
#endif // USE_RP2040
|
#endif // USE_RP2040
|
||||||
|
@ -56,8 +56,6 @@ float ADCSensor::sample() {
|
|||||||
return aggr.aggregate() / 1024.0f;
|
return aggr.aggregate() / 1024.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ADCSensor::unique_id() { return get_mac_address() + "-adc"; }
|
|
||||||
|
|
||||||
} // namespace adc
|
} // namespace adc
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ message ListEntitiesBinarySensorResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
|
|
||||||
string device_class = 5;
|
string device_class = 5;
|
||||||
bool is_status_binary_sensor = 6;
|
bool is_status_binary_sensor = 6;
|
||||||
@ -324,7 +324,7 @@ message ListEntitiesCoverResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
|
|
||||||
bool assumed_state = 5;
|
bool assumed_state = 5;
|
||||||
bool supports_position = 6;
|
bool supports_position = 6;
|
||||||
@ -401,7 +401,7 @@ message ListEntitiesFanResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
|
|
||||||
bool supports_oscillation = 5;
|
bool supports_oscillation = 5;
|
||||||
bool supports_speed = 6;
|
bool supports_speed = 6;
|
||||||
@ -484,7 +484,7 @@ message ListEntitiesLightResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
|
|
||||||
repeated ColorMode supported_color_modes = 12;
|
repeated ColorMode supported_color_modes = 12;
|
||||||
// next four supports_* are for legacy clients, newer clients should use color modes
|
// next four supports_* are for legacy clients, newer clients should use color modes
|
||||||
@ -582,7 +582,7 @@ message ListEntitiesSensorResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
|
|
||||||
string icon = 5;
|
string icon = 5;
|
||||||
string unit_of_measurement = 6;
|
string unit_of_measurement = 6;
|
||||||
@ -621,7 +621,7 @@ message ListEntitiesSwitchResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
|
|
||||||
string icon = 5;
|
string icon = 5;
|
||||||
bool assumed_state = 6;
|
bool assumed_state = 6;
|
||||||
@ -663,7 +663,7 @@ message ListEntitiesTextSensorResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
|
|
||||||
string icon = 5;
|
string icon = 5;
|
||||||
bool disabled_by_default = 6;
|
bool disabled_by_default = 6;
|
||||||
@ -853,7 +853,7 @@ message ListEntitiesCameraResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
bool disabled_by_default = 5;
|
bool disabled_by_default = 5;
|
||||||
string icon = 6;
|
string icon = 6;
|
||||||
EntityCategory entity_category = 7;
|
EntityCategory entity_category = 7;
|
||||||
@ -937,7 +937,7 @@ message ListEntitiesClimateResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
|
|
||||||
bool supports_current_temperature = 5;
|
bool supports_current_temperature = 5;
|
||||||
bool supports_two_point_target_temperature = 6;
|
bool supports_two_point_target_temperature = 6;
|
||||||
@ -1038,7 +1038,7 @@ message ListEntitiesNumberResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
|
|
||||||
string icon = 5;
|
string icon = 5;
|
||||||
float min_value = 6;
|
float min_value = 6;
|
||||||
@ -1087,7 +1087,7 @@ message ListEntitiesSelectResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
|
|
||||||
string icon = 5;
|
string icon = 5;
|
||||||
repeated string options = 6;
|
repeated string options = 6;
|
||||||
@ -1131,7 +1131,7 @@ message ListEntitiesSirenResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
|
|
||||||
string icon = 5;
|
string icon = 5;
|
||||||
bool disabled_by_default = 6;
|
bool disabled_by_default = 6;
|
||||||
@ -1194,7 +1194,7 @@ message ListEntitiesLockResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
|
|
||||||
string icon = 5;
|
string icon = 5;
|
||||||
bool disabled_by_default = 6;
|
bool disabled_by_default = 6;
|
||||||
@ -1243,7 +1243,7 @@ message ListEntitiesButtonResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
|
|
||||||
string icon = 5;
|
string icon = 5;
|
||||||
bool disabled_by_default = 6;
|
bool disabled_by_default = 6;
|
||||||
@ -1298,7 +1298,7 @@ message ListEntitiesMediaPlayerResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
|
|
||||||
string icon = 5;
|
string icon = 5;
|
||||||
bool disabled_by_default = 6;
|
bool disabled_by_default = 6;
|
||||||
@ -1845,7 +1845,7 @@ message ListEntitiesAlarmControlPanelResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
string icon = 5;
|
string icon = 5;
|
||||||
bool disabled_by_default = 6;
|
bool disabled_by_default = 6;
|
||||||
EntityCategory entity_category = 7;
|
EntityCategory entity_category = 7;
|
||||||
@ -1892,7 +1892,7 @@ message ListEntitiesTextResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
string icon = 5;
|
string icon = 5;
|
||||||
bool disabled_by_default = 6;
|
bool disabled_by_default = 6;
|
||||||
EntityCategory entity_category = 7;
|
EntityCategory entity_category = 7;
|
||||||
@ -1940,7 +1940,7 @@ message ListEntitiesDateResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
|
|
||||||
string icon = 5;
|
string icon = 5;
|
||||||
bool disabled_by_default = 6;
|
bool disabled_by_default = 6;
|
||||||
@ -1987,7 +1987,7 @@ message ListEntitiesTimeResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
|
|
||||||
string icon = 5;
|
string icon = 5;
|
||||||
bool disabled_by_default = 6;
|
bool disabled_by_default = 6;
|
||||||
@ -2034,7 +2034,7 @@ message ListEntitiesEventResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
|
|
||||||
string icon = 5;
|
string icon = 5;
|
||||||
bool disabled_by_default = 6;
|
bool disabled_by_default = 6;
|
||||||
@ -2065,7 +2065,7 @@ message ListEntitiesValveResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
|
|
||||||
string icon = 5;
|
string icon = 5;
|
||||||
bool disabled_by_default = 6;
|
bool disabled_by_default = 6;
|
||||||
@ -2120,7 +2120,7 @@ message ListEntitiesDateTimeResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
|
|
||||||
string icon = 5;
|
string icon = 5;
|
||||||
bool disabled_by_default = 6;
|
bool disabled_by_default = 6;
|
||||||
@ -2163,7 +2163,7 @@ message ListEntitiesUpdateResponse {
|
|||||||
string object_id = 1;
|
string object_id = 1;
|
||||||
fixed32 key = 2;
|
fixed32 key = 2;
|
||||||
string name = 3;
|
string name = 3;
|
||||||
string unique_id = 4;
|
reserved 4; // Deprecated: was string unique_id
|
||||||
|
|
||||||
string icon = 5;
|
string icon = 5;
|
||||||
bool disabled_by_default = 6;
|
bool disabled_by_default = 6;
|
||||||
|
@ -180,7 +180,8 @@ void APIConnection::loop() {
|
|||||||
on_fatal_error();
|
on_fatal_error();
|
||||||
ESP_LOGW(TAG, "%s is unresponsive; disconnecting", this->get_client_combined_info().c_str());
|
ESP_LOGW(TAG, "%s is unresponsive; disconnecting", this->get_client_combined_info().c_str());
|
||||||
}
|
}
|
||||||
} else if (now - this->last_traffic_ > KEEPALIVE_TIMEOUT_MS) {
|
} else if (now - this->last_traffic_ > KEEPALIVE_TIMEOUT_MS && !this->flags_.remove) {
|
||||||
|
// Only send ping if we're not disconnecting
|
||||||
ESP_LOGVV(TAG, "Sending keepalive PING");
|
ESP_LOGVV(TAG, "Sending keepalive PING");
|
||||||
this->flags_.sent_ping = this->send_message(PingRequest());
|
this->flags_.sent_ping = this->send_message(PingRequest());
|
||||||
if (!this->flags_.sent_ping) {
|
if (!this->flags_.sent_ping) {
|
||||||
@ -240,10 +241,6 @@ void APIConnection::loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string get_default_unique_id(const std::string &component_type, EntityBase *entity) {
|
|
||||||
return App.get_name() + component_type + entity->get_object_id();
|
|
||||||
}
|
|
||||||
|
|
||||||
DisconnectResponse APIConnection::disconnect(const DisconnectRequest &msg) {
|
DisconnectResponse APIConnection::disconnect(const DisconnectRequest &msg) {
|
||||||
// remote initiated disconnect_client
|
// remote initiated disconnect_client
|
||||||
// don't close yet, we still need to send the disconnect response
|
// don't close yet, we still need to send the disconnect response
|
||||||
@ -330,7 +327,6 @@ uint16_t APIConnection::try_send_binary_sensor_info(EntityBase *entity, APIConne
|
|||||||
ListEntitiesBinarySensorResponse msg;
|
ListEntitiesBinarySensorResponse msg;
|
||||||
msg.device_class = binary_sensor->get_device_class();
|
msg.device_class = binary_sensor->get_device_class();
|
||||||
msg.is_status_binary_sensor = binary_sensor->is_status_binary_sensor();
|
msg.is_status_binary_sensor = binary_sensor->is_status_binary_sensor();
|
||||||
msg.unique_id = get_default_unique_id("binary_sensor", binary_sensor);
|
|
||||||
return fill_and_encode_entity_info(binary_sensor, msg, ListEntitiesBinarySensorResponse::MESSAGE_TYPE, conn,
|
return fill_and_encode_entity_info(binary_sensor, msg, ListEntitiesBinarySensorResponse::MESSAGE_TYPE, conn,
|
||||||
remaining_size, is_single);
|
remaining_size, is_single);
|
||||||
}
|
}
|
||||||
@ -364,7 +360,6 @@ uint16_t APIConnection::try_send_cover_info(EntityBase *entity, APIConnection *c
|
|||||||
msg.supports_tilt = traits.get_supports_tilt();
|
msg.supports_tilt = traits.get_supports_tilt();
|
||||||
msg.supports_stop = traits.get_supports_stop();
|
msg.supports_stop = traits.get_supports_stop();
|
||||||
msg.device_class = cover->get_device_class();
|
msg.device_class = cover->get_device_class();
|
||||||
msg.unique_id = get_default_unique_id("cover", cover);
|
|
||||||
return fill_and_encode_entity_info(cover, msg, ListEntitiesCoverResponse::MESSAGE_TYPE, conn, remaining_size,
|
return fill_and_encode_entity_info(cover, msg, ListEntitiesCoverResponse::MESSAGE_TYPE, conn, remaining_size,
|
||||||
is_single);
|
is_single);
|
||||||
}
|
}
|
||||||
@ -426,7 +421,6 @@ uint16_t APIConnection::try_send_fan_info(EntityBase *entity, APIConnection *con
|
|||||||
msg.supported_speed_count = traits.supported_speed_count();
|
msg.supported_speed_count = traits.supported_speed_count();
|
||||||
for (auto const &preset : traits.supported_preset_modes())
|
for (auto const &preset : traits.supported_preset_modes())
|
||||||
msg.supported_preset_modes.push_back(preset);
|
msg.supported_preset_modes.push_back(preset);
|
||||||
msg.unique_id = get_default_unique_id("fan", fan);
|
|
||||||
return fill_and_encode_entity_info(fan, msg, ListEntitiesFanResponse::MESSAGE_TYPE, conn, remaining_size, is_single);
|
return fill_and_encode_entity_info(fan, msg, ListEntitiesFanResponse::MESSAGE_TYPE, conn, remaining_size, is_single);
|
||||||
}
|
}
|
||||||
void APIConnection::fan_command(const FanCommandRequest &msg) {
|
void APIConnection::fan_command(const FanCommandRequest &msg) {
|
||||||
@ -498,7 +492,6 @@ uint16_t APIConnection::try_send_light_info(EntityBase *entity, APIConnection *c
|
|||||||
msg.effects.push_back(effect->get_name());
|
msg.effects.push_back(effect->get_name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
msg.unique_id = get_default_unique_id("light", light);
|
|
||||||
return fill_and_encode_entity_info(light, msg, ListEntitiesLightResponse::MESSAGE_TYPE, conn, remaining_size,
|
return fill_and_encode_entity_info(light, msg, ListEntitiesLightResponse::MESSAGE_TYPE, conn, remaining_size,
|
||||||
is_single);
|
is_single);
|
||||||
}
|
}
|
||||||
@ -559,9 +552,6 @@ uint16_t APIConnection::try_send_sensor_info(EntityBase *entity, APIConnection *
|
|||||||
msg.force_update = sensor->get_force_update();
|
msg.force_update = sensor->get_force_update();
|
||||||
msg.device_class = sensor->get_device_class();
|
msg.device_class = sensor->get_device_class();
|
||||||
msg.state_class = static_cast<enums::SensorStateClass>(sensor->get_state_class());
|
msg.state_class = static_cast<enums::SensorStateClass>(sensor->get_state_class());
|
||||||
msg.unique_id = sensor->unique_id();
|
|
||||||
if (msg.unique_id.empty())
|
|
||||||
msg.unique_id = get_default_unique_id("sensor", sensor);
|
|
||||||
return fill_and_encode_entity_info(sensor, msg, ListEntitiesSensorResponse::MESSAGE_TYPE, conn, remaining_size,
|
return fill_and_encode_entity_info(sensor, msg, ListEntitiesSensorResponse::MESSAGE_TYPE, conn, remaining_size,
|
||||||
is_single);
|
is_single);
|
||||||
}
|
}
|
||||||
@ -588,7 +578,6 @@ uint16_t APIConnection::try_send_switch_info(EntityBase *entity, APIConnection *
|
|||||||
ListEntitiesSwitchResponse msg;
|
ListEntitiesSwitchResponse msg;
|
||||||
msg.assumed_state = a_switch->assumed_state();
|
msg.assumed_state = a_switch->assumed_state();
|
||||||
msg.device_class = a_switch->get_device_class();
|
msg.device_class = a_switch->get_device_class();
|
||||||
msg.unique_id = get_default_unique_id("switch", a_switch);
|
|
||||||
return fill_and_encode_entity_info(a_switch, msg, ListEntitiesSwitchResponse::MESSAGE_TYPE, conn, remaining_size,
|
return fill_and_encode_entity_info(a_switch, msg, ListEntitiesSwitchResponse::MESSAGE_TYPE, conn, remaining_size,
|
||||||
is_single);
|
is_single);
|
||||||
}
|
}
|
||||||
@ -623,9 +612,6 @@ uint16_t APIConnection::try_send_text_sensor_info(EntityBase *entity, APIConnect
|
|||||||
auto *text_sensor = static_cast<text_sensor::TextSensor *>(entity);
|
auto *text_sensor = static_cast<text_sensor::TextSensor *>(entity);
|
||||||
ListEntitiesTextSensorResponse msg;
|
ListEntitiesTextSensorResponse msg;
|
||||||
msg.device_class = text_sensor->get_device_class();
|
msg.device_class = text_sensor->get_device_class();
|
||||||
msg.unique_id = text_sensor->unique_id();
|
|
||||||
if (msg.unique_id.empty())
|
|
||||||
msg.unique_id = get_default_unique_id("text_sensor", text_sensor);
|
|
||||||
return fill_and_encode_entity_info(text_sensor, msg, ListEntitiesTextSensorResponse::MESSAGE_TYPE, conn,
|
return fill_and_encode_entity_info(text_sensor, msg, ListEntitiesTextSensorResponse::MESSAGE_TYPE, conn,
|
||||||
remaining_size, is_single);
|
remaining_size, is_single);
|
||||||
}
|
}
|
||||||
@ -698,7 +684,6 @@ uint16_t APIConnection::try_send_climate_info(EntityBase *entity, APIConnection
|
|||||||
msg.supported_custom_presets.push_back(custom_preset);
|
msg.supported_custom_presets.push_back(custom_preset);
|
||||||
for (auto swing_mode : traits.get_supported_swing_modes())
|
for (auto swing_mode : traits.get_supported_swing_modes())
|
||||||
msg.supported_swing_modes.push_back(static_cast<enums::ClimateSwingMode>(swing_mode));
|
msg.supported_swing_modes.push_back(static_cast<enums::ClimateSwingMode>(swing_mode));
|
||||||
msg.unique_id = get_default_unique_id("climate", climate);
|
|
||||||
return fill_and_encode_entity_info(climate, msg, ListEntitiesClimateResponse::MESSAGE_TYPE, conn, remaining_size,
|
return fill_and_encode_entity_info(climate, msg, ListEntitiesClimateResponse::MESSAGE_TYPE, conn, remaining_size,
|
||||||
is_single);
|
is_single);
|
||||||
}
|
}
|
||||||
@ -753,7 +738,6 @@ uint16_t APIConnection::try_send_number_info(EntityBase *entity, APIConnection *
|
|||||||
msg.min_value = number->traits.get_min_value();
|
msg.min_value = number->traits.get_min_value();
|
||||||
msg.max_value = number->traits.get_max_value();
|
msg.max_value = number->traits.get_max_value();
|
||||||
msg.step = number->traits.get_step();
|
msg.step = number->traits.get_step();
|
||||||
msg.unique_id = get_default_unique_id("number", number);
|
|
||||||
return fill_and_encode_entity_info(number, msg, ListEntitiesNumberResponse::MESSAGE_TYPE, conn, remaining_size,
|
return fill_and_encode_entity_info(number, msg, ListEntitiesNumberResponse::MESSAGE_TYPE, conn, remaining_size,
|
||||||
is_single);
|
is_single);
|
||||||
}
|
}
|
||||||
@ -783,7 +767,6 @@ uint16_t APIConnection::try_send_date_info(EntityBase *entity, APIConnection *co
|
|||||||
bool is_single) {
|
bool is_single) {
|
||||||
auto *date = static_cast<datetime::DateEntity *>(entity);
|
auto *date = static_cast<datetime::DateEntity *>(entity);
|
||||||
ListEntitiesDateResponse msg;
|
ListEntitiesDateResponse msg;
|
||||||
msg.unique_id = get_default_unique_id("date", date);
|
|
||||||
return fill_and_encode_entity_info(date, msg, ListEntitiesDateResponse::MESSAGE_TYPE, conn, remaining_size,
|
return fill_and_encode_entity_info(date, msg, ListEntitiesDateResponse::MESSAGE_TYPE, conn, remaining_size,
|
||||||
is_single);
|
is_single);
|
||||||
}
|
}
|
||||||
@ -813,7 +796,6 @@ uint16_t APIConnection::try_send_time_info(EntityBase *entity, APIConnection *co
|
|||||||
bool is_single) {
|
bool is_single) {
|
||||||
auto *time = static_cast<datetime::TimeEntity *>(entity);
|
auto *time = static_cast<datetime::TimeEntity *>(entity);
|
||||||
ListEntitiesTimeResponse msg;
|
ListEntitiesTimeResponse msg;
|
||||||
msg.unique_id = get_default_unique_id("time", time);
|
|
||||||
return fill_and_encode_entity_info(time, msg, ListEntitiesTimeResponse::MESSAGE_TYPE, conn, remaining_size,
|
return fill_and_encode_entity_info(time, msg, ListEntitiesTimeResponse::MESSAGE_TYPE, conn, remaining_size,
|
||||||
is_single);
|
is_single);
|
||||||
}
|
}
|
||||||
@ -845,7 +827,6 @@ uint16_t APIConnection::try_send_datetime_info(EntityBase *entity, APIConnection
|
|||||||
bool is_single) {
|
bool is_single) {
|
||||||
auto *datetime = static_cast<datetime::DateTimeEntity *>(entity);
|
auto *datetime = static_cast<datetime::DateTimeEntity *>(entity);
|
||||||
ListEntitiesDateTimeResponse msg;
|
ListEntitiesDateTimeResponse msg;
|
||||||
msg.unique_id = get_default_unique_id("datetime", datetime);
|
|
||||||
return fill_and_encode_entity_info(datetime, msg, ListEntitiesDateTimeResponse::MESSAGE_TYPE, conn, remaining_size,
|
return fill_and_encode_entity_info(datetime, msg, ListEntitiesDateTimeResponse::MESSAGE_TYPE, conn, remaining_size,
|
||||||
is_single);
|
is_single);
|
||||||
}
|
}
|
||||||
@ -879,7 +860,6 @@ uint16_t APIConnection::try_send_text_info(EntityBase *entity, APIConnection *co
|
|||||||
msg.min_length = text->traits.get_min_length();
|
msg.min_length = text->traits.get_min_length();
|
||||||
msg.max_length = text->traits.get_max_length();
|
msg.max_length = text->traits.get_max_length();
|
||||||
msg.pattern = text->traits.get_pattern();
|
msg.pattern = text->traits.get_pattern();
|
||||||
msg.unique_id = get_default_unique_id("text", text);
|
|
||||||
return fill_and_encode_entity_info(text, msg, ListEntitiesTextResponse::MESSAGE_TYPE, conn, remaining_size,
|
return fill_and_encode_entity_info(text, msg, ListEntitiesTextResponse::MESSAGE_TYPE, conn, remaining_size,
|
||||||
is_single);
|
is_single);
|
||||||
}
|
}
|
||||||
@ -911,7 +891,6 @@ uint16_t APIConnection::try_send_select_info(EntityBase *entity, APIConnection *
|
|||||||
ListEntitiesSelectResponse msg;
|
ListEntitiesSelectResponse msg;
|
||||||
for (const auto &option : select->traits.get_options())
|
for (const auto &option : select->traits.get_options())
|
||||||
msg.options.push_back(option);
|
msg.options.push_back(option);
|
||||||
msg.unique_id = get_default_unique_id("select", select);
|
|
||||||
return fill_and_encode_entity_info(select, msg, ListEntitiesSelectResponse::MESSAGE_TYPE, conn, remaining_size,
|
return fill_and_encode_entity_info(select, msg, ListEntitiesSelectResponse::MESSAGE_TYPE, conn, remaining_size,
|
||||||
is_single);
|
is_single);
|
||||||
}
|
}
|
||||||
@ -928,7 +907,6 @@ uint16_t APIConnection::try_send_button_info(EntityBase *entity, APIConnection *
|
|||||||
auto *button = static_cast<button::Button *>(entity);
|
auto *button = static_cast<button::Button *>(entity);
|
||||||
ListEntitiesButtonResponse msg;
|
ListEntitiesButtonResponse msg;
|
||||||
msg.device_class = button->get_device_class();
|
msg.device_class = button->get_device_class();
|
||||||
msg.unique_id = get_default_unique_id("button", button);
|
|
||||||
return fill_and_encode_entity_info(button, msg, ListEntitiesButtonResponse::MESSAGE_TYPE, conn, remaining_size,
|
return fill_and_encode_entity_info(button, msg, ListEntitiesButtonResponse::MESSAGE_TYPE, conn, remaining_size,
|
||||||
is_single);
|
is_single);
|
||||||
}
|
}
|
||||||
@ -959,7 +937,6 @@ uint16_t APIConnection::try_send_lock_info(EntityBase *entity, APIConnection *co
|
|||||||
msg.assumed_state = a_lock->traits.get_assumed_state();
|
msg.assumed_state = a_lock->traits.get_assumed_state();
|
||||||
msg.supports_open = a_lock->traits.get_supports_open();
|
msg.supports_open = a_lock->traits.get_supports_open();
|
||||||
msg.requires_code = a_lock->traits.get_requires_code();
|
msg.requires_code = a_lock->traits.get_requires_code();
|
||||||
msg.unique_id = get_default_unique_id("lock", a_lock);
|
|
||||||
return fill_and_encode_entity_info(a_lock, msg, ListEntitiesLockResponse::MESSAGE_TYPE, conn, remaining_size,
|
return fill_and_encode_entity_info(a_lock, msg, ListEntitiesLockResponse::MESSAGE_TYPE, conn, remaining_size,
|
||||||
is_single);
|
is_single);
|
||||||
}
|
}
|
||||||
@ -1002,7 +979,6 @@ uint16_t APIConnection::try_send_valve_info(EntityBase *entity, APIConnection *c
|
|||||||
msg.assumed_state = traits.get_is_assumed_state();
|
msg.assumed_state = traits.get_is_assumed_state();
|
||||||
msg.supports_position = traits.get_supports_position();
|
msg.supports_position = traits.get_supports_position();
|
||||||
msg.supports_stop = traits.get_supports_stop();
|
msg.supports_stop = traits.get_supports_stop();
|
||||||
msg.unique_id = get_default_unique_id("valve", valve);
|
|
||||||
return fill_and_encode_entity_info(valve, msg, ListEntitiesValveResponse::MESSAGE_TYPE, conn, remaining_size,
|
return fill_and_encode_entity_info(valve, msg, ListEntitiesValveResponse::MESSAGE_TYPE, conn, remaining_size,
|
||||||
is_single);
|
is_single);
|
||||||
}
|
}
|
||||||
@ -1049,7 +1025,6 @@ uint16_t APIConnection::try_send_media_player_info(EntityBase *entity, APIConnec
|
|||||||
media_format.sample_bytes = supported_format.sample_bytes;
|
media_format.sample_bytes = supported_format.sample_bytes;
|
||||||
msg.supported_formats.push_back(media_format);
|
msg.supported_formats.push_back(media_format);
|
||||||
}
|
}
|
||||||
msg.unique_id = get_default_unique_id("media_player", media_player);
|
|
||||||
return fill_and_encode_entity_info(media_player, msg, ListEntitiesMediaPlayerResponse::MESSAGE_TYPE, conn,
|
return fill_and_encode_entity_info(media_player, msg, ListEntitiesMediaPlayerResponse::MESSAGE_TYPE, conn,
|
||||||
remaining_size, is_single);
|
remaining_size, is_single);
|
||||||
}
|
}
|
||||||
@ -1086,7 +1061,6 @@ uint16_t APIConnection::try_send_camera_info(EntityBase *entity, APIConnection *
|
|||||||
bool is_single) {
|
bool is_single) {
|
||||||
auto *camera = static_cast<camera::Camera *>(entity);
|
auto *camera = static_cast<camera::Camera *>(entity);
|
||||||
ListEntitiesCameraResponse msg;
|
ListEntitiesCameraResponse msg;
|
||||||
msg.unique_id = get_default_unique_id("camera", camera);
|
|
||||||
return fill_and_encode_entity_info(camera, msg, ListEntitiesCameraResponse::MESSAGE_TYPE, conn, remaining_size,
|
return fill_and_encode_entity_info(camera, msg, ListEntitiesCameraResponse::MESSAGE_TYPE, conn, remaining_size,
|
||||||
is_single);
|
is_single);
|
||||||
}
|
}
|
||||||
@ -1276,7 +1250,6 @@ uint16_t APIConnection::try_send_alarm_control_panel_info(EntityBase *entity, AP
|
|||||||
msg.supported_features = a_alarm_control_panel->get_supported_features();
|
msg.supported_features = a_alarm_control_panel->get_supported_features();
|
||||||
msg.requires_code = a_alarm_control_panel->get_requires_code();
|
msg.requires_code = a_alarm_control_panel->get_requires_code();
|
||||||
msg.requires_code_to_arm = a_alarm_control_panel->get_requires_code_to_arm();
|
msg.requires_code_to_arm = a_alarm_control_panel->get_requires_code_to_arm();
|
||||||
msg.unique_id = get_default_unique_id("alarm_control_panel", a_alarm_control_panel);
|
|
||||||
return fill_and_encode_entity_info(a_alarm_control_panel, msg, ListEntitiesAlarmControlPanelResponse::MESSAGE_TYPE,
|
return fill_and_encode_entity_info(a_alarm_control_panel, msg, ListEntitiesAlarmControlPanelResponse::MESSAGE_TYPE,
|
||||||
conn, remaining_size, is_single);
|
conn, remaining_size, is_single);
|
||||||
}
|
}
|
||||||
@ -1329,7 +1302,6 @@ uint16_t APIConnection::try_send_event_info(EntityBase *entity, APIConnection *c
|
|||||||
msg.device_class = event->get_device_class();
|
msg.device_class = event->get_device_class();
|
||||||
for (const auto &event_type : event->get_event_types())
|
for (const auto &event_type : event->get_event_types())
|
||||||
msg.event_types.push_back(event_type);
|
msg.event_types.push_back(event_type);
|
||||||
msg.unique_id = get_default_unique_id("event", event);
|
|
||||||
return fill_and_encode_entity_info(event, msg, ListEntitiesEventResponse::MESSAGE_TYPE, conn, remaining_size,
|
return fill_and_encode_entity_info(event, msg, ListEntitiesEventResponse::MESSAGE_TYPE, conn, remaining_size,
|
||||||
is_single);
|
is_single);
|
||||||
}
|
}
|
||||||
@ -1364,7 +1336,6 @@ uint16_t APIConnection::try_send_update_info(EntityBase *entity, APIConnection *
|
|||||||
auto *update = static_cast<update::UpdateEntity *>(entity);
|
auto *update = static_cast<update::UpdateEntity *>(entity);
|
||||||
ListEntitiesUpdateResponse msg;
|
ListEntitiesUpdateResponse msg;
|
||||||
msg.device_class = update->get_device_class();
|
msg.device_class = update->get_device_class();
|
||||||
msg.unique_id = get_default_unique_id("update", update);
|
|
||||||
return fill_and_encode_entity_info(update, msg, ListEntitiesUpdateResponse::MESSAGE_TYPE, conn, remaining_size,
|
return fill_and_encode_entity_info(update, msg, ListEntitiesUpdateResponse::MESSAGE_TYPE, conn, remaining_size,
|
||||||
is_single);
|
is_single);
|
||||||
}
|
}
|
||||||
@ -1389,9 +1360,6 @@ void APIConnection::update_command(const UpdateCommandRequest &msg) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool APIConnection::try_send_log_message(int level, const char *tag, const char *line, size_t message_len) {
|
bool APIConnection::try_send_log_message(int level, const char *tag, const char *line, size_t message_len) {
|
||||||
if (this->flags_.log_subscription < level)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Pre-calculate message size to avoid reallocations
|
// Pre-calculate message size to avoid reallocations
|
||||||
uint32_t msg_size = 0;
|
uint32_t msg_size = 0;
|
||||||
|
|
||||||
@ -1653,8 +1621,15 @@ void APIConnection::DeferredBatch::add_item(EntityBase *entity, MessageCreator c
|
|||||||
|
|
||||||
void APIConnection::DeferredBatch::add_item_front(EntityBase *entity, MessageCreator creator, uint8_t message_type,
|
void APIConnection::DeferredBatch::add_item_front(EntityBase *entity, MessageCreator creator, uint8_t message_type,
|
||||||
uint8_t estimated_size) {
|
uint8_t estimated_size) {
|
||||||
// Insert at front for high priority messages (no deduplication check)
|
// Add high priority message and swap to front
|
||||||
items.insert(items.begin(), BatchItem(entity, std::move(creator), message_type, estimated_size));
|
// This avoids expensive vector::insert which shifts all elements
|
||||||
|
// Note: We only ever have one high-priority message at a time (ping OR disconnect)
|
||||||
|
// If we're disconnecting, pings are blocked, so this simple swap is sufficient
|
||||||
|
items.emplace_back(entity, std::move(creator), message_type, estimated_size);
|
||||||
|
if (items.size() > 1) {
|
||||||
|
// Swap the new high-priority item to the front
|
||||||
|
std::swap(items.front(), items.back());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APIConnection::schedule_batch_() {
|
bool APIConnection::schedule_batch_() {
|
||||||
|
@ -209,6 +209,7 @@ class APIConnection : public APIServerConnection {
|
|||||||
return static_cast<ConnectionState>(this->flags_.connection_state) == ConnectionState::CONNECTED ||
|
return static_cast<ConnectionState>(this->flags_.connection_state) == ConnectionState::CONNECTED ||
|
||||||
this->is_authenticated();
|
this->is_authenticated();
|
||||||
}
|
}
|
||||||
|
uint8_t get_log_subscription_level() const { return this->flags_.log_subscription; }
|
||||||
void on_fatal_error() override;
|
void on_fatal_error() override;
|
||||||
void on_unauthenticated_access() override;
|
void on_unauthenticated_access() override;
|
||||||
void on_no_setup_connection() override;
|
void on_no_setup_connection() override;
|
||||||
|
@ -174,7 +174,6 @@ void ListEntitiesBinarySensorResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
buffer.encode_string(5, this->device_class);
|
buffer.encode_string(5, this->device_class);
|
||||||
buffer.encode_bool(6, this->is_status_binary_sensor);
|
buffer.encode_bool(6, this->is_status_binary_sensor);
|
||||||
buffer.encode_bool(7, this->disabled_by_default);
|
buffer.encode_bool(7, this->disabled_by_default);
|
||||||
@ -184,9 +183,8 @@ void ListEntitiesBinarySensorResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesBinarySensorResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesBinarySensorResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
ProtoSize::add_string_field(total_size, 1, this->device_class);
|
ProtoSize::add_string_field(total_size, 1, this->device_class);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->is_status_binary_sensor);
|
ProtoSize::add_bool_field(total_size, 1, this->is_status_binary_sensor);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
||||||
@ -201,7 +199,7 @@ void BinarySensorStateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_uint32(4, this->device_id);
|
buffer.encode_uint32(4, this->device_id);
|
||||||
}
|
}
|
||||||
void BinarySensorStateResponse::calculate_size(uint32_t &total_size) const {
|
void BinarySensorStateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->state);
|
ProtoSize::add_bool_field(total_size, 1, this->state);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||||
@ -212,7 +210,6 @@ void ListEntitiesCoverResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
buffer.encode_bool(5, this->assumed_state);
|
buffer.encode_bool(5, this->assumed_state);
|
||||||
buffer.encode_bool(6, this->supports_position);
|
buffer.encode_bool(6, this->supports_position);
|
||||||
buffer.encode_bool(7, this->supports_tilt);
|
buffer.encode_bool(7, this->supports_tilt);
|
||||||
@ -225,9 +222,8 @@ void ListEntitiesCoverResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesCoverResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesCoverResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->assumed_state);
|
ProtoSize::add_bool_field(total_size, 1, this->assumed_state);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->supports_position);
|
ProtoSize::add_bool_field(total_size, 1, this->supports_position);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->supports_tilt);
|
ProtoSize::add_bool_field(total_size, 1, this->supports_tilt);
|
||||||
@ -247,10 +243,10 @@ void CoverStateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_uint32(6, this->device_id);
|
buffer.encode_uint32(6, this->device_id);
|
||||||
}
|
}
|
||||||
void CoverStateResponse::calculate_size(uint32_t &total_size) const {
|
void CoverStateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->legacy_state));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->legacy_state));
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->position != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->position);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->tilt != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->tilt);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->current_operation));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->current_operation));
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||||
}
|
}
|
||||||
@ -301,7 +297,6 @@ void ListEntitiesFanResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
buffer.encode_bool(5, this->supports_oscillation);
|
buffer.encode_bool(5, this->supports_oscillation);
|
||||||
buffer.encode_bool(6, this->supports_speed);
|
buffer.encode_bool(6, this->supports_speed);
|
||||||
buffer.encode_bool(7, this->supports_direction);
|
buffer.encode_bool(7, this->supports_direction);
|
||||||
@ -316,9 +311,8 @@ void ListEntitiesFanResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesFanResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesFanResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->supports_oscillation);
|
ProtoSize::add_bool_field(total_size, 1, this->supports_oscillation);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->supports_speed);
|
ProtoSize::add_bool_field(total_size, 1, this->supports_speed);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->supports_direction);
|
ProtoSize::add_bool_field(total_size, 1, this->supports_direction);
|
||||||
@ -344,7 +338,7 @@ void FanStateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_uint32(8, this->device_id);
|
buffer.encode_uint32(8, this->device_id);
|
||||||
}
|
}
|
||||||
void FanStateResponse::calculate_size(uint32_t &total_size) const {
|
void FanStateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->state);
|
ProtoSize::add_bool_field(total_size, 1, this->state);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->oscillating);
|
ProtoSize::add_bool_field(total_size, 1, this->oscillating);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->speed));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->speed));
|
||||||
@ -422,7 +416,6 @@ void ListEntitiesLightResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
for (auto &it : this->supported_color_modes) {
|
for (auto &it : this->supported_color_modes) {
|
||||||
buffer.encode_uint32(12, static_cast<uint32_t>(it), true);
|
buffer.encode_uint32(12, static_cast<uint32_t>(it), true);
|
||||||
}
|
}
|
||||||
@ -442,9 +435,8 @@ void ListEntitiesLightResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesLightResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesLightResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
if (!this->supported_color_modes.empty()) {
|
if (!this->supported_color_modes.empty()) {
|
||||||
for (const auto &it : this->supported_color_modes) {
|
for (const auto &it : this->supported_color_modes) {
|
||||||
ProtoSize::add_enum_field_repeated(total_size, 1, static_cast<uint32_t>(it));
|
ProtoSize::add_enum_field_repeated(total_size, 1, static_cast<uint32_t>(it));
|
||||||
@ -454,8 +446,8 @@ void ListEntitiesLightResponse::calculate_size(uint32_t &total_size) const {
|
|||||||
ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_rgb);
|
ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_rgb);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_white_value);
|
ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_white_value);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_color_temperature);
|
ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_color_temperature);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->min_mireds != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->min_mireds);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->max_mireds != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->max_mireds);
|
||||||
if (!this->effects.empty()) {
|
if (!this->effects.empty()) {
|
||||||
for (const auto &it : this->effects) {
|
for (const auto &it : this->effects) {
|
||||||
ProtoSize::add_string_field_repeated(total_size, 1, it);
|
ProtoSize::add_string_field_repeated(total_size, 1, it);
|
||||||
@ -483,18 +475,18 @@ void LightStateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_uint32(14, this->device_id);
|
buffer.encode_uint32(14, this->device_id);
|
||||||
}
|
}
|
||||||
void LightStateResponse::calculate_size(uint32_t &total_size) const {
|
void LightStateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->state);
|
ProtoSize::add_bool_field(total_size, 1, this->state);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->brightness != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->brightness);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->color_mode));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->color_mode));
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->color_brightness != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->color_brightness);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->red != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->red);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->green != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->green);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->blue != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->blue);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->white != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->white);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->color_temperature != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->color_temperature);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->cold_white != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->cold_white);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->warm_white != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->warm_white);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->effect);
|
ProtoSize::add_string_field(total_size, 1, this->effect);
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||||
}
|
}
|
||||||
@ -609,7 +601,6 @@ void ListEntitiesSensorResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
buffer.encode_string(5, this->icon);
|
buffer.encode_string(5, this->icon);
|
||||||
buffer.encode_string(6, this->unit_of_measurement);
|
buffer.encode_string(6, this->unit_of_measurement);
|
||||||
buffer.encode_int32(7, this->accuracy_decimals);
|
buffer.encode_int32(7, this->accuracy_decimals);
|
||||||
@ -623,9 +614,8 @@ void ListEntitiesSensorResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesSensorResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesSensorResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
ProtoSize::add_string_field(total_size, 1, this->icon);
|
ProtoSize::add_string_field(total_size, 1, this->icon);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unit_of_measurement);
|
ProtoSize::add_string_field(total_size, 1, this->unit_of_measurement);
|
||||||
ProtoSize::add_int32_field(total_size, 1, this->accuracy_decimals);
|
ProtoSize::add_int32_field(total_size, 1, this->accuracy_decimals);
|
||||||
@ -644,8 +634,8 @@ void SensorStateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_uint32(4, this->device_id);
|
buffer.encode_uint32(4, this->device_id);
|
||||||
}
|
}
|
||||||
void SensorStateResponse::calculate_size(uint32_t &total_size) const {
|
void SensorStateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->state != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->state);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||||
}
|
}
|
||||||
@ -655,7 +645,6 @@ void ListEntitiesSwitchResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
buffer.encode_string(5, this->icon);
|
buffer.encode_string(5, this->icon);
|
||||||
buffer.encode_bool(6, this->assumed_state);
|
buffer.encode_bool(6, this->assumed_state);
|
||||||
buffer.encode_bool(7, this->disabled_by_default);
|
buffer.encode_bool(7, this->disabled_by_default);
|
||||||
@ -665,9 +654,8 @@ void ListEntitiesSwitchResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesSwitchResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesSwitchResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
ProtoSize::add_string_field(total_size, 1, this->icon);
|
ProtoSize::add_string_field(total_size, 1, this->icon);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->assumed_state);
|
ProtoSize::add_bool_field(total_size, 1, this->assumed_state);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
||||||
@ -681,7 +669,7 @@ void SwitchStateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_uint32(3, this->device_id);
|
buffer.encode_uint32(3, this->device_id);
|
||||||
}
|
}
|
||||||
void SwitchStateResponse::calculate_size(uint32_t &total_size) const {
|
void SwitchStateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->state);
|
ProtoSize::add_bool_field(total_size, 1, this->state);
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||||
}
|
}
|
||||||
@ -714,7 +702,6 @@ void ListEntitiesTextSensorResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
buffer.encode_string(5, this->icon);
|
buffer.encode_string(5, this->icon);
|
||||||
buffer.encode_bool(6, this->disabled_by_default);
|
buffer.encode_bool(6, this->disabled_by_default);
|
||||||
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -723,9 +710,8 @@ void ListEntitiesTextSensorResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesTextSensorResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesTextSensorResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
ProtoSize::add_string_field(total_size, 1, this->icon);
|
ProtoSize::add_string_field(total_size, 1, this->icon);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -739,7 +725,7 @@ void TextSensorStateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_uint32(4, this->device_id);
|
buffer.encode_uint32(4, this->device_id);
|
||||||
}
|
}
|
||||||
void TextSensorStateResponse::calculate_size(uint32_t &total_size) const {
|
void TextSensorStateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->state);
|
ProtoSize::add_string_field(total_size, 1, this->state);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||||
@ -863,7 +849,7 @@ bool GetTimeResponse::decode_32bit(uint32_t field_id, Proto32Bit value) {
|
|||||||
}
|
}
|
||||||
void GetTimeResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->epoch_seconds); }
|
void GetTimeResponse::encode(ProtoWriteBuffer buffer) const { buffer.encode_fixed32(1, this->epoch_seconds); }
|
||||||
void GetTimeResponse::calculate_size(uint32_t &total_size) const {
|
void GetTimeResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->epoch_seconds != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->epoch_seconds);
|
||||||
}
|
}
|
||||||
#ifdef USE_API_SERVICES
|
#ifdef USE_API_SERVICES
|
||||||
bool ListEntitiesServicesArgument::decode_varint(uint32_t field_id, ProtoVarInt value) {
|
bool ListEntitiesServicesArgument::decode_varint(uint32_t field_id, ProtoVarInt value) {
|
||||||
@ -903,7 +889,7 @@ void ListEntitiesServicesResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesServicesResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesServicesResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_repeated_message(total_size, 1, this->args);
|
ProtoSize::add_repeated_message(total_size, 1, this->args);
|
||||||
}
|
}
|
||||||
bool ExecuteServiceArgument::decode_varint(uint32_t field_id, ProtoVarInt value) {
|
bool ExecuteServiceArgument::decode_varint(uint32_t field_id, ProtoVarInt value) {
|
||||||
@ -976,7 +962,7 @@ void ExecuteServiceArgument::encode(ProtoWriteBuffer buffer) const {
|
|||||||
void ExecuteServiceArgument::calculate_size(uint32_t &total_size) const {
|
void ExecuteServiceArgument::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->bool_);
|
ProtoSize::add_bool_field(total_size, 1, this->bool_);
|
||||||
ProtoSize::add_int32_field(total_size, 1, this->legacy_int);
|
ProtoSize::add_int32_field(total_size, 1, this->legacy_int);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->float_ != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->float_);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->string_);
|
ProtoSize::add_string_field(total_size, 1, this->string_);
|
||||||
ProtoSize::add_sint32_field(total_size, 1, this->int_);
|
ProtoSize::add_sint32_field(total_size, 1, this->int_);
|
||||||
if (!this->bool_array.empty()) {
|
if (!this->bool_array.empty()) {
|
||||||
@ -1025,7 +1011,6 @@ void ListEntitiesCameraResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
buffer.encode_bool(5, this->disabled_by_default);
|
buffer.encode_bool(5, this->disabled_by_default);
|
||||||
buffer.encode_string(6, this->icon);
|
buffer.encode_string(6, this->icon);
|
||||||
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -1033,9 +1018,8 @@ void ListEntitiesCameraResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesCameraResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesCameraResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->icon);
|
ProtoSize::add_string_field(total_size, 1, this->icon);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -1048,7 +1032,7 @@ void CameraImageResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_uint32(4, this->device_id);
|
buffer.encode_uint32(4, this->device_id);
|
||||||
}
|
}
|
||||||
void CameraImageResponse::calculate_size(uint32_t &total_size) const {
|
void CameraImageResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->data);
|
ProtoSize::add_string_field(total_size, 1, this->data);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->done);
|
ProtoSize::add_bool_field(total_size, 1, this->done);
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||||
@ -1072,7 +1056,6 @@ void ListEntitiesClimateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
buffer.encode_bool(5, this->supports_current_temperature);
|
buffer.encode_bool(5, this->supports_current_temperature);
|
||||||
buffer.encode_bool(6, this->supports_two_point_target_temperature);
|
buffer.encode_bool(6, this->supports_two_point_target_temperature);
|
||||||
for (auto &it : this->supported_modes) {
|
for (auto &it : this->supported_modes) {
|
||||||
@ -1110,9 +1093,8 @@ void ListEntitiesClimateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesClimateResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesClimateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->supports_current_temperature);
|
ProtoSize::add_bool_field(total_size, 1, this->supports_current_temperature);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->supports_two_point_target_temperature);
|
ProtoSize::add_bool_field(total_size, 1, this->supports_two_point_target_temperature);
|
||||||
if (!this->supported_modes.empty()) {
|
if (!this->supported_modes.empty()) {
|
||||||
@ -1120,9 +1102,9 @@ void ListEntitiesClimateResponse::calculate_size(uint32_t &total_size) const {
|
|||||||
ProtoSize::add_enum_field_repeated(total_size, 1, static_cast<uint32_t>(it));
|
ProtoSize::add_enum_field_repeated(total_size, 1, static_cast<uint32_t>(it));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->visual_min_temperature != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->visual_min_temperature);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->visual_max_temperature != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->visual_max_temperature);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->visual_target_temperature_step != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->visual_target_temperature_step);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_away);
|
ProtoSize::add_bool_field(total_size, 1, this->legacy_supports_away);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->supports_action);
|
ProtoSize::add_bool_field(total_size, 1, this->supports_action);
|
||||||
if (!this->supported_fan_modes.empty()) {
|
if (!this->supported_fan_modes.empty()) {
|
||||||
@ -1153,11 +1135,11 @@ void ListEntitiesClimateResponse::calculate_size(uint32_t &total_size) const {
|
|||||||
ProtoSize::add_bool_field(total_size, 2, this->disabled_by_default);
|
ProtoSize::add_bool_field(total_size, 2, this->disabled_by_default);
|
||||||
ProtoSize::add_string_field(total_size, 2, this->icon);
|
ProtoSize::add_string_field(total_size, 2, this->icon);
|
||||||
ProtoSize::add_enum_field(total_size, 2, static_cast<uint32_t>(this->entity_category));
|
ProtoSize::add_enum_field(total_size, 2, static_cast<uint32_t>(this->entity_category));
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 2, this->visual_current_temperature_step != 0.0f);
|
ProtoSize::add_float_field(total_size, 2, this->visual_current_temperature_step);
|
||||||
ProtoSize::add_bool_field(total_size, 2, this->supports_current_humidity);
|
ProtoSize::add_bool_field(total_size, 2, this->supports_current_humidity);
|
||||||
ProtoSize::add_bool_field(total_size, 2, this->supports_target_humidity);
|
ProtoSize::add_bool_field(total_size, 2, this->supports_target_humidity);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 2, this->visual_min_humidity != 0.0f);
|
ProtoSize::add_float_field(total_size, 2, this->visual_min_humidity);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 2, this->visual_max_humidity != 0.0f);
|
ProtoSize::add_float_field(total_size, 2, this->visual_max_humidity);
|
||||||
ProtoSize::add_uint32_field(total_size, 2, this->device_id);
|
ProtoSize::add_uint32_field(total_size, 2, this->device_id);
|
||||||
}
|
}
|
||||||
void ClimateStateResponse::encode(ProtoWriteBuffer buffer) const {
|
void ClimateStateResponse::encode(ProtoWriteBuffer buffer) const {
|
||||||
@ -1179,12 +1161,12 @@ void ClimateStateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_uint32(16, this->device_id);
|
buffer.encode_uint32(16, this->device_id);
|
||||||
}
|
}
|
||||||
void ClimateStateResponse::calculate_size(uint32_t &total_size) const {
|
void ClimateStateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->mode));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->mode));
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->current_temperature != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->current_temperature);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->target_temperature != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->target_temperature);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->target_temperature_low != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->target_temperature_low);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->target_temperature_high != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->target_temperature_high);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->unused_legacy_away);
|
ProtoSize::add_bool_field(total_size, 1, this->unused_legacy_away);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->action));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->action));
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->fan_mode));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->fan_mode));
|
||||||
@ -1192,8 +1174,8 @@ void ClimateStateResponse::calculate_size(uint32_t &total_size) const {
|
|||||||
ProtoSize::add_string_field(total_size, 1, this->custom_fan_mode);
|
ProtoSize::add_string_field(total_size, 1, this->custom_fan_mode);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->preset));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->preset));
|
||||||
ProtoSize::add_string_field(total_size, 1, this->custom_preset);
|
ProtoSize::add_string_field(total_size, 1, this->custom_preset);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->current_humidity != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->current_humidity);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->target_humidity != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->target_humidity);
|
||||||
ProtoSize::add_uint32_field(total_size, 2, this->device_id);
|
ProtoSize::add_uint32_field(total_size, 2, this->device_id);
|
||||||
}
|
}
|
||||||
bool ClimateCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
|
bool ClimateCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
|
||||||
@ -1295,7 +1277,6 @@ void ListEntitiesNumberResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
buffer.encode_string(5, this->icon);
|
buffer.encode_string(5, this->icon);
|
||||||
buffer.encode_float(6, this->min_value);
|
buffer.encode_float(6, this->min_value);
|
||||||
buffer.encode_float(7, this->max_value);
|
buffer.encode_float(7, this->max_value);
|
||||||
@ -1309,13 +1290,12 @@ void ListEntitiesNumberResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesNumberResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesNumberResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
ProtoSize::add_string_field(total_size, 1, this->icon);
|
ProtoSize::add_string_field(total_size, 1, this->icon);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->min_value != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->min_value);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->max_value != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->max_value);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->step != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->step);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unit_of_measurement);
|
ProtoSize::add_string_field(total_size, 1, this->unit_of_measurement);
|
||||||
@ -1330,8 +1310,8 @@ void NumberStateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_uint32(4, this->device_id);
|
buffer.encode_uint32(4, this->device_id);
|
||||||
}
|
}
|
||||||
void NumberStateResponse::calculate_size(uint32_t &total_size) const {
|
void NumberStateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->state != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->state);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||||
}
|
}
|
||||||
@ -1364,7 +1344,6 @@ void ListEntitiesSelectResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
buffer.encode_string(5, this->icon);
|
buffer.encode_string(5, this->icon);
|
||||||
for (auto &it : this->options) {
|
for (auto &it : this->options) {
|
||||||
buffer.encode_string(6, it, true);
|
buffer.encode_string(6, it, true);
|
||||||
@ -1375,9 +1354,8 @@ void ListEntitiesSelectResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesSelectResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesSelectResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
ProtoSize::add_string_field(total_size, 1, this->icon);
|
ProtoSize::add_string_field(total_size, 1, this->icon);
|
||||||
if (!this->options.empty()) {
|
if (!this->options.empty()) {
|
||||||
for (const auto &it : this->options) {
|
for (const auto &it : this->options) {
|
||||||
@ -1395,7 +1373,7 @@ void SelectStateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_uint32(4, this->device_id);
|
buffer.encode_uint32(4, this->device_id);
|
||||||
}
|
}
|
||||||
void SelectStateResponse::calculate_size(uint32_t &total_size) const {
|
void SelectStateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->state);
|
ProtoSize::add_string_field(total_size, 1, this->state);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||||
@ -1436,7 +1414,6 @@ void ListEntitiesSirenResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
buffer.encode_string(5, this->icon);
|
buffer.encode_string(5, this->icon);
|
||||||
buffer.encode_bool(6, this->disabled_by_default);
|
buffer.encode_bool(6, this->disabled_by_default);
|
||||||
for (auto &it : this->tones) {
|
for (auto &it : this->tones) {
|
||||||
@ -1449,9 +1426,8 @@ void ListEntitiesSirenResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesSirenResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesSirenResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
ProtoSize::add_string_field(total_size, 1, this->icon);
|
ProtoSize::add_string_field(total_size, 1, this->icon);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
||||||
if (!this->tones.empty()) {
|
if (!this->tones.empty()) {
|
||||||
@ -1470,7 +1446,7 @@ void SirenStateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_uint32(3, this->device_id);
|
buffer.encode_uint32(3, this->device_id);
|
||||||
}
|
}
|
||||||
void SirenStateResponse::calculate_size(uint32_t &total_size) const {
|
void SirenStateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->state);
|
ProtoSize::add_bool_field(total_size, 1, this->state);
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||||
}
|
}
|
||||||
@ -1531,7 +1507,6 @@ void ListEntitiesLockResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
buffer.encode_string(5, this->icon);
|
buffer.encode_string(5, this->icon);
|
||||||
buffer.encode_bool(6, this->disabled_by_default);
|
buffer.encode_bool(6, this->disabled_by_default);
|
||||||
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -1543,9 +1518,8 @@ void ListEntitiesLockResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesLockResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesLockResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
ProtoSize::add_string_field(total_size, 1, this->icon);
|
ProtoSize::add_string_field(total_size, 1, this->icon);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -1561,7 +1535,7 @@ void LockStateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_uint32(3, this->device_id);
|
buffer.encode_uint32(3, this->device_id);
|
||||||
}
|
}
|
||||||
void LockStateResponse::calculate_size(uint32_t &total_size) const {
|
void LockStateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->state));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->state));
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||||
}
|
}
|
||||||
@ -1607,7 +1581,6 @@ void ListEntitiesButtonResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
buffer.encode_string(5, this->icon);
|
buffer.encode_string(5, this->icon);
|
||||||
buffer.encode_bool(6, this->disabled_by_default);
|
buffer.encode_bool(6, this->disabled_by_default);
|
||||||
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -1616,9 +1589,8 @@ void ListEntitiesButtonResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesButtonResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesButtonResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
ProtoSize::add_string_field(total_size, 1, this->icon);
|
ProtoSize::add_string_field(total_size, 1, this->icon);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -1694,7 +1666,6 @@ void ListEntitiesMediaPlayerResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
buffer.encode_string(5, this->icon);
|
buffer.encode_string(5, this->icon);
|
||||||
buffer.encode_bool(6, this->disabled_by_default);
|
buffer.encode_bool(6, this->disabled_by_default);
|
||||||
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -1706,9 +1677,8 @@ void ListEntitiesMediaPlayerResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesMediaPlayerResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesMediaPlayerResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
ProtoSize::add_string_field(total_size, 1, this->icon);
|
ProtoSize::add_string_field(total_size, 1, this->icon);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -1724,9 +1694,9 @@ void MediaPlayerStateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_uint32(5, this->device_id);
|
buffer.encode_uint32(5, this->device_id);
|
||||||
}
|
}
|
||||||
void MediaPlayerStateResponse::calculate_size(uint32_t &total_size) const {
|
void MediaPlayerStateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->state));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->state));
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->volume != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->volume);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->muted);
|
ProtoSize::add_bool_field(total_size, 1, this->muted);
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||||
}
|
}
|
||||||
@ -2326,7 +2296,7 @@ void VoiceAssistantAudioSettings::encode(ProtoWriteBuffer buffer) const {
|
|||||||
void VoiceAssistantAudioSettings::calculate_size(uint32_t &total_size) const {
|
void VoiceAssistantAudioSettings::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->noise_suppression_level);
|
ProtoSize::add_uint32_field(total_size, 1, this->noise_suppression_level);
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->auto_gain);
|
ProtoSize::add_uint32_field(total_size, 1, this->auto_gain);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->volume_multiplier != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->volume_multiplier);
|
||||||
}
|
}
|
||||||
void VoiceAssistantRequest::encode(ProtoWriteBuffer buffer) const {
|
void VoiceAssistantRequest::encode(ProtoWriteBuffer buffer) const {
|
||||||
buffer.encode_bool(1, this->start);
|
buffer.encode_bool(1, this->start);
|
||||||
@ -2553,7 +2523,6 @@ void ListEntitiesAlarmControlPanelResponse::encode(ProtoWriteBuffer buffer) cons
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
buffer.encode_string(5, this->icon);
|
buffer.encode_string(5, this->icon);
|
||||||
buffer.encode_bool(6, this->disabled_by_default);
|
buffer.encode_bool(6, this->disabled_by_default);
|
||||||
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -2564,9 +2533,8 @@ void ListEntitiesAlarmControlPanelResponse::encode(ProtoWriteBuffer buffer) cons
|
|||||||
}
|
}
|
||||||
void ListEntitiesAlarmControlPanelResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesAlarmControlPanelResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
ProtoSize::add_string_field(total_size, 1, this->icon);
|
ProtoSize::add_string_field(total_size, 1, this->icon);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -2581,7 +2549,7 @@ void AlarmControlPanelStateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_uint32(3, this->device_id);
|
buffer.encode_uint32(3, this->device_id);
|
||||||
}
|
}
|
||||||
void AlarmControlPanelStateResponse::calculate_size(uint32_t &total_size) const {
|
void AlarmControlPanelStateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->state));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->state));
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||||
}
|
}
|
||||||
@ -2624,7 +2592,6 @@ void ListEntitiesTextResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
buffer.encode_string(5, this->icon);
|
buffer.encode_string(5, this->icon);
|
||||||
buffer.encode_bool(6, this->disabled_by_default);
|
buffer.encode_bool(6, this->disabled_by_default);
|
||||||
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -2636,9 +2603,8 @@ void ListEntitiesTextResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesTextResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesTextResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
ProtoSize::add_string_field(total_size, 1, this->icon);
|
ProtoSize::add_string_field(total_size, 1, this->icon);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -2655,7 +2621,7 @@ void TextStateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_uint32(4, this->device_id);
|
buffer.encode_uint32(4, this->device_id);
|
||||||
}
|
}
|
||||||
void TextStateResponse::calculate_size(uint32_t &total_size) const {
|
void TextStateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->state);
|
ProtoSize::add_string_field(total_size, 1, this->state);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||||
@ -2696,7 +2662,6 @@ void ListEntitiesDateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
buffer.encode_string(5, this->icon);
|
buffer.encode_string(5, this->icon);
|
||||||
buffer.encode_bool(6, this->disabled_by_default);
|
buffer.encode_bool(6, this->disabled_by_default);
|
||||||
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -2704,9 +2669,8 @@ void ListEntitiesDateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesDateResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesDateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
ProtoSize::add_string_field(total_size, 1, this->icon);
|
ProtoSize::add_string_field(total_size, 1, this->icon);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -2721,7 +2685,7 @@ void DateStateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_uint32(6, this->device_id);
|
buffer.encode_uint32(6, this->device_id);
|
||||||
}
|
}
|
||||||
void DateStateResponse::calculate_size(uint32_t &total_size) const {
|
void DateStateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->year);
|
ProtoSize::add_uint32_field(total_size, 1, this->year);
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->month);
|
ProtoSize::add_uint32_field(total_size, 1, this->month);
|
||||||
@ -2763,7 +2727,6 @@ void ListEntitiesTimeResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
buffer.encode_string(5, this->icon);
|
buffer.encode_string(5, this->icon);
|
||||||
buffer.encode_bool(6, this->disabled_by_default);
|
buffer.encode_bool(6, this->disabled_by_default);
|
||||||
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -2771,9 +2734,8 @@ void ListEntitiesTimeResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesTimeResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesTimeResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
ProtoSize::add_string_field(total_size, 1, this->icon);
|
ProtoSize::add_string_field(total_size, 1, this->icon);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -2788,7 +2750,7 @@ void TimeStateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_uint32(6, this->device_id);
|
buffer.encode_uint32(6, this->device_id);
|
||||||
}
|
}
|
||||||
void TimeStateResponse::calculate_size(uint32_t &total_size) const {
|
void TimeStateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->hour);
|
ProtoSize::add_uint32_field(total_size, 1, this->hour);
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->minute);
|
ProtoSize::add_uint32_field(total_size, 1, this->minute);
|
||||||
@ -2830,7 +2792,6 @@ void ListEntitiesEventResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
buffer.encode_string(5, this->icon);
|
buffer.encode_string(5, this->icon);
|
||||||
buffer.encode_bool(6, this->disabled_by_default);
|
buffer.encode_bool(6, this->disabled_by_default);
|
||||||
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -2842,9 +2803,8 @@ void ListEntitiesEventResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesEventResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesEventResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
ProtoSize::add_string_field(total_size, 1, this->icon);
|
ProtoSize::add_string_field(total_size, 1, this->icon);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -2862,7 +2822,7 @@ void EventResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_uint32(3, this->device_id);
|
buffer.encode_uint32(3, this->device_id);
|
||||||
}
|
}
|
||||||
void EventResponse::calculate_size(uint32_t &total_size) const {
|
void EventResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->event_type);
|
ProtoSize::add_string_field(total_size, 1, this->event_type);
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||||
}
|
}
|
||||||
@ -2872,7 +2832,6 @@ void ListEntitiesValveResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
buffer.encode_string(5, this->icon);
|
buffer.encode_string(5, this->icon);
|
||||||
buffer.encode_bool(6, this->disabled_by_default);
|
buffer.encode_bool(6, this->disabled_by_default);
|
||||||
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -2884,9 +2843,8 @@ void ListEntitiesValveResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesValveResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesValveResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
ProtoSize::add_string_field(total_size, 1, this->icon);
|
ProtoSize::add_string_field(total_size, 1, this->icon);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -2903,8 +2861,8 @@ void ValveStateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_uint32(4, this->device_id);
|
buffer.encode_uint32(4, this->device_id);
|
||||||
}
|
}
|
||||||
void ValveStateResponse::calculate_size(uint32_t &total_size) const {
|
void ValveStateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->position != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->position);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->current_operation));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->current_operation));
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||||
}
|
}
|
||||||
@ -2943,7 +2901,6 @@ void ListEntitiesDateTimeResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
buffer.encode_string(5, this->icon);
|
buffer.encode_string(5, this->icon);
|
||||||
buffer.encode_bool(6, this->disabled_by_default);
|
buffer.encode_bool(6, this->disabled_by_default);
|
||||||
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -2951,9 +2908,8 @@ void ListEntitiesDateTimeResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesDateTimeResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesDateTimeResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
ProtoSize::add_string_field(total_size, 1, this->icon);
|
ProtoSize::add_string_field(total_size, 1, this->icon);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -2966,9 +2922,9 @@ void DateTimeStateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_uint32(4, this->device_id);
|
buffer.encode_uint32(4, this->device_id);
|
||||||
}
|
}
|
||||||
void DateTimeStateResponse::calculate_size(uint32_t &total_size) const {
|
void DateTimeStateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->epoch_seconds != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->epoch_seconds);
|
||||||
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
ProtoSize::add_uint32_field(total_size, 1, this->device_id);
|
||||||
}
|
}
|
||||||
bool DateTimeCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
|
bool DateTimeCommandRequest::decode_varint(uint32_t field_id, ProtoVarInt value) {
|
||||||
@ -3000,7 +2956,6 @@ void ListEntitiesUpdateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_string(1, this->object_id);
|
buffer.encode_string(1, this->object_id);
|
||||||
buffer.encode_fixed32(2, this->key);
|
buffer.encode_fixed32(2, this->key);
|
||||||
buffer.encode_string(3, this->name);
|
buffer.encode_string(3, this->name);
|
||||||
buffer.encode_string(4, this->unique_id);
|
|
||||||
buffer.encode_string(5, this->icon);
|
buffer.encode_string(5, this->icon);
|
||||||
buffer.encode_bool(6, this->disabled_by_default);
|
buffer.encode_bool(6, this->disabled_by_default);
|
||||||
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
buffer.encode_uint32(7, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -3009,9 +2964,8 @@ void ListEntitiesUpdateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
}
|
}
|
||||||
void ListEntitiesUpdateResponse::calculate_size(uint32_t &total_size) const {
|
void ListEntitiesUpdateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
ProtoSize::add_string_field(total_size, 1, this->object_id);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->name);
|
ProtoSize::add_string_field(total_size, 1, this->name);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->unique_id);
|
|
||||||
ProtoSize::add_string_field(total_size, 1, this->icon);
|
ProtoSize::add_string_field(total_size, 1, this->icon);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
ProtoSize::add_bool_field(total_size, 1, this->disabled_by_default);
|
||||||
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
ProtoSize::add_enum_field(total_size, 1, static_cast<uint32_t>(this->entity_category));
|
||||||
@ -3032,11 +2986,11 @@ void UpdateStateResponse::encode(ProtoWriteBuffer buffer) const {
|
|||||||
buffer.encode_uint32(11, this->device_id);
|
buffer.encode_uint32(11, this->device_id);
|
||||||
}
|
}
|
||||||
void UpdateStateResponse::calculate_size(uint32_t &total_size) const {
|
void UpdateStateResponse::calculate_size(uint32_t &total_size) const {
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->key != 0);
|
ProtoSize::add_fixed32_field(total_size, 1, this->key);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
ProtoSize::add_bool_field(total_size, 1, this->missing_state);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->in_progress);
|
ProtoSize::add_bool_field(total_size, 1, this->in_progress);
|
||||||
ProtoSize::add_bool_field(total_size, 1, this->has_progress);
|
ProtoSize::add_bool_field(total_size, 1, this->has_progress);
|
||||||
ProtoSize::add_fixed_field<4>(total_size, 1, this->progress != 0.0f);
|
ProtoSize::add_float_field(total_size, 1, this->progress);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->current_version);
|
ProtoSize::add_string_field(total_size, 1, this->current_version);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->latest_version);
|
ProtoSize::add_string_field(total_size, 1, this->latest_version);
|
||||||
ProtoSize::add_string_field(total_size, 1, this->title);
|
ProtoSize::add_string_field(total_size, 1, this->title);
|
||||||
|
@ -291,7 +291,6 @@ class InfoResponseProtoMessage : public ProtoMessage {
|
|||||||
std::string object_id{};
|
std::string object_id{};
|
||||||
uint32_t key{0};
|
uint32_t key{0};
|
||||||
std::string name{};
|
std::string name{};
|
||||||
std::string unique_id{};
|
|
||||||
bool disabled_by_default{false};
|
bool disabled_by_default{false};
|
||||||
std::string icon{};
|
std::string icon{};
|
||||||
enums::EntityCategory entity_category{};
|
enums::EntityCategory entity_category{};
|
||||||
@ -559,7 +558,7 @@ class SubscribeStatesRequest : public ProtoMessage {
|
|||||||
class ListEntitiesBinarySensorResponse : public InfoResponseProtoMessage {
|
class ListEntitiesBinarySensorResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 12;
|
static constexpr uint8_t MESSAGE_TYPE = 12;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 60;
|
static constexpr uint8_t ESTIMATED_SIZE = 51;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_binary_sensor_response"; }
|
const char *message_name() const override { return "list_entities_binary_sensor_response"; }
|
||||||
#endif
|
#endif
|
||||||
@ -595,7 +594,7 @@ class BinarySensorStateResponse : public StateResponseProtoMessage {
|
|||||||
class ListEntitiesCoverResponse : public InfoResponseProtoMessage {
|
class ListEntitiesCoverResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 13;
|
static constexpr uint8_t MESSAGE_TYPE = 13;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 66;
|
static constexpr uint8_t ESTIMATED_SIZE = 57;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_cover_response"; }
|
const char *message_name() const override { return "list_entities_cover_response"; }
|
||||||
#endif
|
#endif
|
||||||
@ -658,7 +657,7 @@ class CoverCommandRequest : public CommandProtoMessage {
|
|||||||
class ListEntitiesFanResponse : public InfoResponseProtoMessage {
|
class ListEntitiesFanResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 14;
|
static constexpr uint8_t MESSAGE_TYPE = 14;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 77;
|
static constexpr uint8_t ESTIMATED_SIZE = 68;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_fan_response"; }
|
const char *message_name() const override { return "list_entities_fan_response"; }
|
||||||
#endif
|
#endif
|
||||||
@ -729,7 +728,7 @@ class FanCommandRequest : public CommandProtoMessage {
|
|||||||
class ListEntitiesLightResponse : public InfoResponseProtoMessage {
|
class ListEntitiesLightResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 15;
|
static constexpr uint8_t MESSAGE_TYPE = 15;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 90;
|
static constexpr uint8_t ESTIMATED_SIZE = 81;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_light_response"; }
|
const char *message_name() const override { return "list_entities_light_response"; }
|
||||||
#endif
|
#endif
|
||||||
@ -823,7 +822,7 @@ class LightCommandRequest : public CommandProtoMessage {
|
|||||||
class ListEntitiesSensorResponse : public InfoResponseProtoMessage {
|
class ListEntitiesSensorResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 16;
|
static constexpr uint8_t MESSAGE_TYPE = 16;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 77;
|
static constexpr uint8_t ESTIMATED_SIZE = 68;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_sensor_response"; }
|
const char *message_name() const override { return "list_entities_sensor_response"; }
|
||||||
#endif
|
#endif
|
||||||
@ -863,7 +862,7 @@ class SensorStateResponse : public StateResponseProtoMessage {
|
|||||||
class ListEntitiesSwitchResponse : public InfoResponseProtoMessage {
|
class ListEntitiesSwitchResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 17;
|
static constexpr uint8_t MESSAGE_TYPE = 17;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 60;
|
static constexpr uint8_t ESTIMATED_SIZE = 51;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_switch_response"; }
|
const char *message_name() const override { return "list_entities_switch_response"; }
|
||||||
#endif
|
#endif
|
||||||
@ -914,7 +913,7 @@ class SwitchCommandRequest : public CommandProtoMessage {
|
|||||||
class ListEntitiesTextSensorResponse : public InfoResponseProtoMessage {
|
class ListEntitiesTextSensorResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 18;
|
static constexpr uint8_t MESSAGE_TYPE = 18;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 58;
|
static constexpr uint8_t ESTIMATED_SIZE = 49;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_text_sensor_response"; }
|
const char *message_name() const override { return "list_entities_text_sensor_response"; }
|
||||||
#endif
|
#endif
|
||||||
@ -1213,7 +1212,7 @@ class ExecuteServiceRequest : public ProtoMessage {
|
|||||||
class ListEntitiesCameraResponse : public InfoResponseProtoMessage {
|
class ListEntitiesCameraResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 43;
|
static constexpr uint8_t MESSAGE_TYPE = 43;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 49;
|
static constexpr uint8_t ESTIMATED_SIZE = 40;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_camera_response"; }
|
const char *message_name() const override { return "list_entities_camera_response"; }
|
||||||
#endif
|
#endif
|
||||||
@ -1263,7 +1262,7 @@ class CameraImageRequest : public ProtoMessage {
|
|||||||
class ListEntitiesClimateResponse : public InfoResponseProtoMessage {
|
class ListEntitiesClimateResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 46;
|
static constexpr uint8_t MESSAGE_TYPE = 46;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 156;
|
static constexpr uint8_t ESTIMATED_SIZE = 147;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_climate_response"; }
|
const char *message_name() const override { return "list_entities_climate_response"; }
|
||||||
#endif
|
#endif
|
||||||
@ -1365,7 +1364,7 @@ class ClimateCommandRequest : public CommandProtoMessage {
|
|||||||
class ListEntitiesNumberResponse : public InfoResponseProtoMessage {
|
class ListEntitiesNumberResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 49;
|
static constexpr uint8_t MESSAGE_TYPE = 49;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 84;
|
static constexpr uint8_t ESTIMATED_SIZE = 75;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_number_response"; }
|
const char *message_name() const override { return "list_entities_number_response"; }
|
||||||
#endif
|
#endif
|
||||||
@ -1421,7 +1420,7 @@ class NumberCommandRequest : public CommandProtoMessage {
|
|||||||
class ListEntitiesSelectResponse : public InfoResponseProtoMessage {
|
class ListEntitiesSelectResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 52;
|
static constexpr uint8_t MESSAGE_TYPE = 52;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 67;
|
static constexpr uint8_t ESTIMATED_SIZE = 58;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_select_response"; }
|
const char *message_name() const override { return "list_entities_select_response"; }
|
||||||
#endif
|
#endif
|
||||||
@ -1473,7 +1472,7 @@ class SelectCommandRequest : public CommandProtoMessage {
|
|||||||
class ListEntitiesSirenResponse : public InfoResponseProtoMessage {
|
class ListEntitiesSirenResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 55;
|
static constexpr uint8_t MESSAGE_TYPE = 55;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 71;
|
static constexpr uint8_t ESTIMATED_SIZE = 62;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_siren_response"; }
|
const char *message_name() const override { return "list_entities_siren_response"; }
|
||||||
#endif
|
#endif
|
||||||
@ -1533,7 +1532,7 @@ class SirenCommandRequest : public CommandProtoMessage {
|
|||||||
class ListEntitiesLockResponse : public InfoResponseProtoMessage {
|
class ListEntitiesLockResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 58;
|
static constexpr uint8_t MESSAGE_TYPE = 58;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 64;
|
static constexpr uint8_t ESTIMATED_SIZE = 55;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_lock_response"; }
|
const char *message_name() const override { return "list_entities_lock_response"; }
|
||||||
#endif
|
#endif
|
||||||
@ -1589,7 +1588,7 @@ class LockCommandRequest : public CommandProtoMessage {
|
|||||||
class ListEntitiesButtonResponse : public InfoResponseProtoMessage {
|
class ListEntitiesButtonResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 61;
|
static constexpr uint8_t MESSAGE_TYPE = 61;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 58;
|
static constexpr uint8_t ESTIMATED_SIZE = 49;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_button_response"; }
|
const char *message_name() const override { return "list_entities_button_response"; }
|
||||||
#endif
|
#endif
|
||||||
@ -1639,7 +1638,7 @@ class MediaPlayerSupportedFormat : public ProtoMessage {
|
|||||||
class ListEntitiesMediaPlayerResponse : public InfoResponseProtoMessage {
|
class ListEntitiesMediaPlayerResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 63;
|
static constexpr uint8_t MESSAGE_TYPE = 63;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 85;
|
static constexpr uint8_t ESTIMATED_SIZE = 76;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_media_player_response"; }
|
const char *message_name() const override { return "list_entities_media_player_response"; }
|
||||||
#endif
|
#endif
|
||||||
@ -2453,7 +2452,7 @@ class VoiceAssistantSetConfiguration : public ProtoMessage {
|
|||||||
class ListEntitiesAlarmControlPanelResponse : public InfoResponseProtoMessage {
|
class ListEntitiesAlarmControlPanelResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 94;
|
static constexpr uint8_t MESSAGE_TYPE = 94;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 57;
|
static constexpr uint8_t ESTIMATED_SIZE = 48;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_alarm_control_panel_response"; }
|
const char *message_name() const override { return "list_entities_alarm_control_panel_response"; }
|
||||||
#endif
|
#endif
|
||||||
@ -2507,7 +2506,7 @@ class AlarmControlPanelCommandRequest : public CommandProtoMessage {
|
|||||||
class ListEntitiesTextResponse : public InfoResponseProtoMessage {
|
class ListEntitiesTextResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 97;
|
static constexpr uint8_t MESSAGE_TYPE = 97;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 68;
|
static constexpr uint8_t ESTIMATED_SIZE = 59;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_text_response"; }
|
const char *message_name() const override { return "list_entities_text_response"; }
|
||||||
#endif
|
#endif
|
||||||
@ -2562,7 +2561,7 @@ class TextCommandRequest : public CommandProtoMessage {
|
|||||||
class ListEntitiesDateResponse : public InfoResponseProtoMessage {
|
class ListEntitiesDateResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 100;
|
static constexpr uint8_t MESSAGE_TYPE = 100;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 49;
|
static constexpr uint8_t ESTIMATED_SIZE = 40;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_date_response"; }
|
const char *message_name() const override { return "list_entities_date_response"; }
|
||||||
#endif
|
#endif
|
||||||
@ -2616,7 +2615,7 @@ class DateCommandRequest : public CommandProtoMessage {
|
|||||||
class ListEntitiesTimeResponse : public InfoResponseProtoMessage {
|
class ListEntitiesTimeResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 103;
|
static constexpr uint8_t MESSAGE_TYPE = 103;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 49;
|
static constexpr uint8_t ESTIMATED_SIZE = 40;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_time_response"; }
|
const char *message_name() const override { return "list_entities_time_response"; }
|
||||||
#endif
|
#endif
|
||||||
@ -2670,7 +2669,7 @@ class TimeCommandRequest : public CommandProtoMessage {
|
|||||||
class ListEntitiesEventResponse : public InfoResponseProtoMessage {
|
class ListEntitiesEventResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 107;
|
static constexpr uint8_t MESSAGE_TYPE = 107;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 76;
|
static constexpr uint8_t ESTIMATED_SIZE = 67;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_event_response"; }
|
const char *message_name() const override { return "list_entities_event_response"; }
|
||||||
#endif
|
#endif
|
||||||
@ -2705,7 +2704,7 @@ class EventResponse : public StateResponseProtoMessage {
|
|||||||
class ListEntitiesValveResponse : public InfoResponseProtoMessage {
|
class ListEntitiesValveResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 109;
|
static constexpr uint8_t MESSAGE_TYPE = 109;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 64;
|
static constexpr uint8_t ESTIMATED_SIZE = 55;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_valve_response"; }
|
const char *message_name() const override { return "list_entities_valve_response"; }
|
||||||
#endif
|
#endif
|
||||||
@ -2761,7 +2760,7 @@ class ValveCommandRequest : public CommandProtoMessage {
|
|||||||
class ListEntitiesDateTimeResponse : public InfoResponseProtoMessage {
|
class ListEntitiesDateTimeResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 112;
|
static constexpr uint8_t MESSAGE_TYPE = 112;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 49;
|
static constexpr uint8_t ESTIMATED_SIZE = 40;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_date_time_response"; }
|
const char *message_name() const override { return "list_entities_date_time_response"; }
|
||||||
#endif
|
#endif
|
||||||
@ -2811,7 +2810,7 @@ class DateTimeCommandRequest : public CommandProtoMessage {
|
|||||||
class ListEntitiesUpdateResponse : public InfoResponseProtoMessage {
|
class ListEntitiesUpdateResponse : public InfoResponseProtoMessage {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t MESSAGE_TYPE = 116;
|
static constexpr uint8_t MESSAGE_TYPE = 116;
|
||||||
static constexpr uint8_t ESTIMATED_SIZE = 58;
|
static constexpr uint8_t ESTIMATED_SIZE = 49;
|
||||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||||
const char *message_name() const override { return "list_entities_update_response"; }
|
const char *message_name() const override { return "list_entities_update_response"; }
|
||||||
#endif
|
#endif
|
||||||
|
@ -807,10 +807,6 @@ void ListEntitiesBinarySensorResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
out.append(" device_class: ");
|
out.append(" device_class: ");
|
||||||
out.append("'").append(this->device_class).append("'");
|
out.append("'").append(this->device_class).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
@ -877,10 +873,6 @@ void ListEntitiesCoverResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
out.append(" assumed_state: ");
|
out.append(" assumed_state: ");
|
||||||
out.append(YESNO(this->assumed_state));
|
out.append(YESNO(this->assumed_state));
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
@ -1013,10 +1005,6 @@ void ListEntitiesFanResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
out.append(" supports_oscillation: ");
|
out.append(" supports_oscillation: ");
|
||||||
out.append(YESNO(this->supports_oscillation));
|
out.append(YESNO(this->supports_oscillation));
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
@ -1178,10 +1166,6 @@ void ListEntitiesLightResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
for (const auto &it : this->supported_color_modes) {
|
for (const auto &it : this->supported_color_modes) {
|
||||||
out.append(" supported_color_modes: ");
|
out.append(" supported_color_modes: ");
|
||||||
out.append(proto_enum_to_string<enums::ColorMode>(it));
|
out.append(proto_enum_to_string<enums::ColorMode>(it));
|
||||||
@ -1456,10 +1440,6 @@ void ListEntitiesSensorResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
out.append(" icon: ");
|
out.append(" icon: ");
|
||||||
out.append("'").append(this->icon).append("'");
|
out.append("'").append(this->icon).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
@ -1544,10 +1524,6 @@ void ListEntitiesSwitchResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
out.append(" icon: ");
|
out.append(" icon: ");
|
||||||
out.append("'").append(this->icon).append("'");
|
out.append("'").append(this->icon).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
@ -1628,10 +1604,6 @@ void ListEntitiesTextSensorResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
out.append(" icon: ");
|
out.append(" icon: ");
|
||||||
out.append("'").append(this->icon).append("'");
|
out.append("'").append(this->icon).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
@ -1931,10 +1903,6 @@ void ListEntitiesCameraResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
out.append(" disabled_by_default: ");
|
out.append(" disabled_by_default: ");
|
||||||
out.append(YESNO(this->disabled_by_default));
|
out.append(YESNO(this->disabled_by_default));
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
@ -2005,10 +1973,6 @@ void ListEntitiesClimateResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
out.append(" supports_current_temperature: ");
|
out.append(" supports_current_temperature: ");
|
||||||
out.append(YESNO(this->supports_current_temperature));
|
out.append(YESNO(this->supports_current_temperature));
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
@ -2317,10 +2281,6 @@ void ListEntitiesNumberResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
out.append(" icon: ");
|
out.append(" icon: ");
|
||||||
out.append("'").append(this->icon).append("'");
|
out.append("'").append(this->icon).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
@ -2426,10 +2386,6 @@ void ListEntitiesSelectResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
out.append(" icon: ");
|
out.append(" icon: ");
|
||||||
out.append("'").append(this->icon).append("'");
|
out.append("'").append(this->icon).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
@ -2512,10 +2468,6 @@ void ListEntitiesSirenResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
out.append(" icon: ");
|
out.append(" icon: ");
|
||||||
out.append("'").append(this->icon).append("'");
|
out.append("'").append(this->icon).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
@ -2632,10 +2584,6 @@ void ListEntitiesLockResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
out.append(" icon: ");
|
out.append(" icon: ");
|
||||||
out.append("'").append(this->icon).append("'");
|
out.append("'").append(this->icon).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
@ -2732,10 +2680,6 @@ void ListEntitiesButtonResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
out.append(" icon: ");
|
out.append(" icon: ");
|
||||||
out.append("'").append(this->icon).append("'");
|
out.append("'").append(this->icon).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
@ -2817,10 +2761,6 @@ void ListEntitiesMediaPlayerResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
out.append(" icon: ");
|
out.append(" icon: ");
|
||||||
out.append("'").append(this->icon).append("'");
|
out.append("'").append(this->icon).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
@ -3678,10 +3618,6 @@ void ListEntitiesAlarmControlPanelResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
out.append(" icon: ");
|
out.append(" icon: ");
|
||||||
out.append("'").append(this->icon).append("'");
|
out.append("'").append(this->icon).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
@ -3771,10 +3707,6 @@ void ListEntitiesTextResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
out.append(" icon: ");
|
out.append(" icon: ");
|
||||||
out.append("'").append(this->icon).append("'");
|
out.append("'").append(this->icon).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
@ -3869,10 +3801,6 @@ void ListEntitiesDateResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
out.append(" icon: ");
|
out.append(" icon: ");
|
||||||
out.append("'").append(this->icon).append("'");
|
out.append("'").append(this->icon).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
@ -3971,10 +3899,6 @@ void ListEntitiesTimeResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
out.append(" icon: ");
|
out.append(" icon: ");
|
||||||
out.append("'").append(this->icon).append("'");
|
out.append("'").append(this->icon).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
@ -4073,10 +3997,6 @@ void ListEntitiesEventResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
out.append(" icon: ");
|
out.append(" icon: ");
|
||||||
out.append("'").append(this->icon).append("'");
|
out.append("'").append(this->icon).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
@ -4141,10 +4061,6 @@ void ListEntitiesValveResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
out.append(" icon: ");
|
out.append(" icon: ");
|
||||||
out.append("'").append(this->icon).append("'");
|
out.append("'").append(this->icon).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
@ -4247,10 +4163,6 @@ void ListEntitiesDateTimeResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
out.append(" icon: ");
|
out.append(" icon: ");
|
||||||
out.append("'").append(this->icon).append("'");
|
out.append("'").append(this->icon).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
@ -4329,10 +4241,6 @@ void ListEntitiesUpdateResponse::dump_to(std::string &out) const {
|
|||||||
out.append("'").append(this->name).append("'");
|
out.append("'").append(this->name).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
|
||||||
out.append(" unique_id: ");
|
|
||||||
out.append("'").append(this->unique_id).append("'");
|
|
||||||
out.append("\n");
|
|
||||||
|
|
||||||
out.append(" icon: ");
|
out.append(" icon: ");
|
||||||
out.append("'").append(this->icon).append("'");
|
out.append("'").append(this->icon).append("'");
|
||||||
out.append("\n");
|
out.append("\n");
|
||||||
|
@ -31,7 +31,6 @@ APIServer::APIServer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void APIServer::setup() {
|
void APIServer::setup() {
|
||||||
ESP_LOGCONFIG(TAG, "Running setup");
|
|
||||||
this->setup_controller();
|
this->setup_controller();
|
||||||
|
|
||||||
#ifdef USE_API_NOISE
|
#ifdef USE_API_NOISE
|
||||||
@ -105,7 +104,7 @@ void APIServer::setup() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (auto &c : this->clients_) {
|
for (auto &c : this->clients_) {
|
||||||
if (!c->flags_.remove)
|
if (!c->flags_.remove && c->get_log_subscription_level() >= level)
|
||||||
c->try_send_log_message(level, tag, message, message_len);
|
c->try_send_log_message(level, tag, message, message_len);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -205,16 +204,16 @@ void APIServer::loop() {
|
|||||||
|
|
||||||
void APIServer::dump_config() {
|
void APIServer::dump_config() {
|
||||||
ESP_LOGCONFIG(TAG,
|
ESP_LOGCONFIG(TAG,
|
||||||
"API Server:\n"
|
"Server:\n"
|
||||||
" Address: %s:%u",
|
" Address: %s:%u",
|
||||||
network::get_use_address().c_str(), this->port_);
|
network::get_use_address().c_str(), this->port_);
|
||||||
#ifdef USE_API_NOISE
|
#ifdef USE_API_NOISE
|
||||||
ESP_LOGCONFIG(TAG, " Using noise encryption: %s", YESNO(this->noise_ctx_->has_psk()));
|
ESP_LOGCONFIG(TAG, " Noise encryption: %s", YESNO(this->noise_ctx_->has_psk()));
|
||||||
if (!this->noise_ctx_->has_psk()) {
|
if (!this->noise_ctx_->has_psk()) {
|
||||||
ESP_LOGCONFIG(TAG, " Supports noise encryption: YES");
|
ESP_LOGCONFIG(TAG, " Supports encryption: YES");
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
ESP_LOGCONFIG(TAG, " Using noise encryption: NO");
|
ESP_LOGCONFIG(TAG, " Noise encryption: NO");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,9 +189,9 @@ class ProtoWriteBuffer {
|
|||||||
* @param field_id Field number (tag) in the protobuf message
|
* @param field_id Field number (tag) in the protobuf message
|
||||||
* @param type Wire type value:
|
* @param type Wire type value:
|
||||||
* - 0: Varint (int32, int64, uint32, uint64, sint32, sint64, bool, enum)
|
* - 0: Varint (int32, int64, uint32, uint64, sint32, sint64, bool, enum)
|
||||||
* - 1: 64-bit (fixed64, sfixed64, double)
|
|
||||||
* - 2: Length-delimited (string, bytes, embedded messages, packed repeated fields)
|
* - 2: Length-delimited (string, bytes, embedded messages, packed repeated fields)
|
||||||
* - 5: 32-bit (fixed32, sfixed32, float)
|
* - 5: 32-bit (fixed32, sfixed32, float)
|
||||||
|
* - Note: Wire type 1 (64-bit fixed) is not supported
|
||||||
*
|
*
|
||||||
* Following https://protobuf.dev/programming-guides/encoding/#structure
|
* Following https://protobuf.dev/programming-guides/encoding/#structure
|
||||||
*/
|
*/
|
||||||
@ -540,6 +540,42 @@ class ProtoSize {
|
|||||||
total_size += field_id_size + NumBytes;
|
total_size += field_id_size + NumBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Calculates and adds the size of a float field to the total message size
|
||||||
|
*/
|
||||||
|
static inline void add_float_field(uint32_t &total_size, uint32_t field_id_size, float value) {
|
||||||
|
if (value != 0.0f) {
|
||||||
|
total_size += field_id_size + 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: add_double_field removed - wire type 1 (64-bit: double) not supported
|
||||||
|
// to reduce overhead on embedded systems
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Calculates and adds the size of a fixed32 field to the total message size
|
||||||
|
*/
|
||||||
|
static inline void add_fixed32_field(uint32_t &total_size, uint32_t field_id_size, uint32_t value) {
|
||||||
|
if (value != 0) {
|
||||||
|
total_size += field_id_size + 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: add_fixed64_field removed - wire type 1 (64-bit: fixed64) not supported
|
||||||
|
// to reduce overhead on embedded systems
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Calculates and adds the size of a sfixed32 field to the total message size
|
||||||
|
*/
|
||||||
|
static inline void add_sfixed32_field(uint32_t &total_size, uint32_t field_id_size, int32_t value) {
|
||||||
|
if (value != 0) {
|
||||||
|
total_size += field_id_size + 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: add_sfixed64_field removed - wire type 1 (64-bit: sfixed64) not supported
|
||||||
|
// to reduce overhead on embedded systems
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Calculates and adds the size of an enum field to the total message size
|
* @brief Calculates and adds the size of an enum field to the total message size
|
||||||
*
|
*
|
||||||
|
@ -29,7 +29,6 @@ class IPAddressEthernetInfo : public PollingComponent, public text_sensor::TextS
|
|||||||
}
|
}
|
||||||
|
|
||||||
float get_setup_priority() const override { return setup_priority::ETHERNET; }
|
float get_setup_priority() const override { return setup_priority::ETHERNET; }
|
||||||
std::string unique_id() override { return get_mac_address() + "-ethernetinfo"; }
|
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
void add_ip_sensors(uint8_t index, text_sensor::TextSensor *s) { this->ip_sensors_[index] = s; }
|
void add_ip_sensors(uint8_t index, text_sensor::TextSensor *s) { this->ip_sensors_[index] = s; }
|
||||||
|
|
||||||
@ -52,7 +51,6 @@ class DNSAddressEthernetInfo : public PollingComponent, public text_sensor::Text
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
float get_setup_priority() const override { return setup_priority::ETHERNET; }
|
float get_setup_priority() const override { return setup_priority::ETHERNET; }
|
||||||
std::string unique_id() override { return get_mac_address() + "-ethernetinfo-dns"; }
|
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -63,7 +61,6 @@ class MACAddressEthernetInfo : public Component, public text_sensor::TextSensor
|
|||||||
public:
|
public:
|
||||||
void setup() override { this->publish_state(ethernet::global_eth_component->get_eth_mac_address_pretty()); }
|
void setup() override { this->publish_state(ethernet::global_eth_component->get_eth_mac_address_pretty()); }
|
||||||
float get_setup_priority() const override { return setup_priority::ETHERNET; }
|
float get_setup_priority() const override { return setup_priority::ETHERNET; }
|
||||||
std::string unique_id() override { return get_mac_address() + "-ethernetinfo-mac"; }
|
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "esphome/core/hal.h"
|
#include "esphome/core/hal.h"
|
||||||
#include "esphome/core/helpers.h"
|
#include "esphome/core/helpers.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
#include <driver/gpio.h>
|
||||||
|
|
||||||
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 0)
|
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 3, 0)
|
||||||
#define SOC_HP_I2C_NUM SOC_I2C_NUM
|
#define SOC_HP_I2C_NUM SOC_I2C_NUM
|
||||||
@ -20,21 +21,72 @@ static const char *const TAG = "i2c.idf";
|
|||||||
void IDFI2CBus::setup() {
|
void IDFI2CBus::setup() {
|
||||||
ESP_LOGCONFIG(TAG, "Running setup");
|
ESP_LOGCONFIG(TAG, "Running setup");
|
||||||
static i2c_port_t next_port = I2C_NUM_0;
|
static i2c_port_t next_port = I2C_NUM_0;
|
||||||
port_ = next_port;
|
this->port_ = next_port;
|
||||||
|
if (this->port_ == I2C_NUM_MAX) {
|
||||||
|
ESP_LOGE(TAG, "No more than %u buses supported", I2C_NUM_MAX);
|
||||||
|
this->mark_failed();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->timeout_ > 13000) {
|
||||||
|
ESP_LOGW(TAG, "Using max allowed timeout: 13 ms");
|
||||||
|
this->timeout_ = 13000;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->recover_();
|
||||||
|
|
||||||
|
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 2)
|
||||||
|
next_port = (i2c_port_t) (next_port + 1);
|
||||||
|
|
||||||
|
i2c_master_bus_config_t bus_conf{};
|
||||||
|
memset(&bus_conf, 0, sizeof(bus_conf));
|
||||||
|
bus_conf.sda_io_num = gpio_num_t(sda_pin_);
|
||||||
|
bus_conf.scl_io_num = gpio_num_t(scl_pin_);
|
||||||
|
bus_conf.i2c_port = this->port_;
|
||||||
|
bus_conf.glitch_ignore_cnt = 7;
|
||||||
|
#if SOC_LP_I2C_SUPPORTED
|
||||||
|
if (this->port_ < SOC_HP_I2C_NUM) {
|
||||||
|
bus_conf.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||||
|
} else {
|
||||||
|
bus_conf.lp_source_clk = LP_I2C_SCLK_DEFAULT;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
bus_conf.clk_source = I2C_CLK_SRC_DEFAULT;
|
||||||
|
#endif
|
||||||
|
bus_conf.flags.enable_internal_pullup = sda_pullup_enabled_ || scl_pullup_enabled_;
|
||||||
|
esp_err_t err = i2c_new_master_bus(&bus_conf, &this->bus_);
|
||||||
|
if (err != ESP_OK) {
|
||||||
|
ESP_LOGW(TAG, "i2c_new_master_bus failed: %s", esp_err_to_name(err));
|
||||||
|
this->mark_failed();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
i2c_device_config_t dev_conf{};
|
||||||
|
memset(&dev_conf, 0, sizeof(dev_conf));
|
||||||
|
dev_conf.dev_addr_length = I2C_ADDR_BIT_LEN_7;
|
||||||
|
dev_conf.device_address = I2C_DEVICE_ADDRESS_NOT_USED;
|
||||||
|
dev_conf.scl_speed_hz = this->frequency_;
|
||||||
|
dev_conf.scl_wait_us = this->timeout_;
|
||||||
|
err = i2c_master_bus_add_device(this->bus_, &dev_conf, &this->dev_);
|
||||||
|
if (err != ESP_OK) {
|
||||||
|
ESP_LOGW(TAG, "i2c_master_bus_add_device failed: %s", esp_err_to_name(err));
|
||||||
|
this->mark_failed();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->initialized_ = true;
|
||||||
|
|
||||||
|
if (this->scan_) {
|
||||||
|
ESP_LOGV(TAG, "Scanning for devices");
|
||||||
|
this->i2c_scan_();
|
||||||
|
}
|
||||||
|
#else
|
||||||
#if SOC_HP_I2C_NUM > 1
|
#if SOC_HP_I2C_NUM > 1
|
||||||
next_port = (next_port == I2C_NUM_0) ? I2C_NUM_1 : I2C_NUM_MAX;
|
next_port = (next_port == I2C_NUM_0) ? I2C_NUM_1 : I2C_NUM_MAX;
|
||||||
#else
|
#else
|
||||||
next_port = I2C_NUM_MAX;
|
next_port = I2C_NUM_MAX;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (port_ == I2C_NUM_MAX) {
|
|
||||||
ESP_LOGE(TAG, "No more than %u buses supported", SOC_HP_I2C_NUM);
|
|
||||||
this->mark_failed();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
recover_();
|
|
||||||
|
|
||||||
i2c_config_t conf{};
|
i2c_config_t conf{};
|
||||||
memset(&conf, 0, sizeof(conf));
|
memset(&conf, 0, sizeof(conf));
|
||||||
conf.mode = I2C_MODE_MASTER;
|
conf.mode = I2C_MODE_MASTER;
|
||||||
@ -53,11 +105,7 @@ void IDFI2CBus::setup() {
|
|||||||
this->mark_failed();
|
this->mark_failed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (timeout_ > 0) { // if timeout specified in yaml:
|
if (timeout_ > 0) {
|
||||||
if (timeout_ > 13000) {
|
|
||||||
ESP_LOGW(TAG, "i2c timeout of %" PRIu32 "us greater than max of 13ms on esp-idf, setting to max", timeout_);
|
|
||||||
timeout_ = 13000;
|
|
||||||
}
|
|
||||||
err = i2c_set_timeout(port_, timeout_ * 80); // unit: APB 80MHz clock cycle
|
err = i2c_set_timeout(port_, timeout_ * 80); // unit: APB 80MHz clock cycle
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGW(TAG, "i2c_set_timeout failed: %s", esp_err_to_name(err));
|
ESP_LOGW(TAG, "i2c_set_timeout failed: %s", esp_err_to_name(err));
|
||||||
@ -73,12 +121,15 @@ void IDFI2CBus::setup() {
|
|||||||
this->mark_failed();
|
this->mark_failed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
initialized_ = true;
|
initialized_ = true;
|
||||||
if (this->scan_) {
|
if (this->scan_) {
|
||||||
ESP_LOGV(TAG, "Scanning bus for active devices");
|
ESP_LOGV(TAG, "Scanning bus for active devices");
|
||||||
this->i2c_scan_();
|
this->i2c_scan_();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void IDFI2CBus::dump_config() {
|
void IDFI2CBus::dump_config() {
|
||||||
ESP_LOGCONFIG(TAG, "I2C Bus:");
|
ESP_LOGCONFIG(TAG, "I2C Bus:");
|
||||||
ESP_LOGCONFIG(TAG,
|
ESP_LOGCONFIG(TAG,
|
||||||
@ -123,6 +174,74 @@ ErrorCode IDFI2CBus::readv(uint8_t address, ReadBuffer *buffers, size_t cnt) {
|
|||||||
ESP_LOGVV(TAG, "i2c bus not initialized!");
|
ESP_LOGVV(TAG, "i2c bus not initialized!");
|
||||||
return ERROR_NOT_INITIALIZED;
|
return ERROR_NOT_INITIALIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 2)
|
||||||
|
i2c_operation_job_t jobs[cnt + 4];
|
||||||
|
uint8_t read = (address << 1) | I2C_MASTER_READ;
|
||||||
|
size_t last = 0, num = 0;
|
||||||
|
|
||||||
|
jobs[num].command = I2C_MASTER_CMD_START;
|
||||||
|
num++;
|
||||||
|
|
||||||
|
jobs[num].command = I2C_MASTER_CMD_WRITE;
|
||||||
|
jobs[num].write.ack_check = true;
|
||||||
|
jobs[num].write.data = &read;
|
||||||
|
jobs[num].write.total_bytes = 1;
|
||||||
|
num++;
|
||||||
|
|
||||||
|
// find the last valid index
|
||||||
|
for (size_t i = 0; i < cnt; i++) {
|
||||||
|
const auto &buf = buffers[i];
|
||||||
|
if (buf.len == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
last = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < cnt; i++) {
|
||||||
|
const auto &buf = buffers[i];
|
||||||
|
if (buf.len == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (i == last) {
|
||||||
|
// the last byte read before stop should always be a nack,
|
||||||
|
// split the last read if len is larger than 1
|
||||||
|
if (buf.len > 1) {
|
||||||
|
jobs[num].command = I2C_MASTER_CMD_READ;
|
||||||
|
jobs[num].read.ack_value = I2C_ACK_VAL;
|
||||||
|
jobs[num].read.data = (uint8_t *) buf.data;
|
||||||
|
jobs[num].read.total_bytes = buf.len - 1;
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
jobs[num].command = I2C_MASTER_CMD_READ;
|
||||||
|
jobs[num].read.ack_value = I2C_NACK_VAL;
|
||||||
|
jobs[num].read.data = (uint8_t *) buf.data + buf.len - 1;
|
||||||
|
jobs[num].read.total_bytes = 1;
|
||||||
|
num++;
|
||||||
|
} else {
|
||||||
|
jobs[num].command = I2C_MASTER_CMD_READ;
|
||||||
|
jobs[num].read.ack_value = I2C_ACK_VAL;
|
||||||
|
jobs[num].read.data = (uint8_t *) buf.data;
|
||||||
|
jobs[num].read.total_bytes = buf.len;
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jobs[num].command = I2C_MASTER_CMD_STOP;
|
||||||
|
num++;
|
||||||
|
|
||||||
|
esp_err_t err = i2c_master_execute_defined_operations(this->dev_, jobs, num, 20);
|
||||||
|
if (err == ESP_ERR_INVALID_STATE) {
|
||||||
|
ESP_LOGVV(TAG, "RX from %02X failed: not acked", address);
|
||||||
|
return ERROR_NOT_ACKNOWLEDGED;
|
||||||
|
} else if (err == ESP_ERR_TIMEOUT) {
|
||||||
|
ESP_LOGVV(TAG, "RX from %02X failed: timeout", address);
|
||||||
|
return ERROR_TIMEOUT;
|
||||||
|
} else if (err != ESP_OK) {
|
||||||
|
ESP_LOGVV(TAG, "RX from %02X failed: %s", address, esp_err_to_name(err));
|
||||||
|
return ERROR_UNKNOWN;
|
||||||
|
}
|
||||||
|
#else
|
||||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||||
esp_err_t err = i2c_master_start(cmd);
|
esp_err_t err = i2c_master_start(cmd);
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
@ -168,6 +287,7 @@ ErrorCode IDFI2CBus::readv(uint8_t address, ReadBuffer *buffers, size_t cnt) {
|
|||||||
ESP_LOGVV(TAG, "RX from %02X failed: %s", address, esp_err_to_name(err));
|
ESP_LOGVV(TAG, "RX from %02X failed: %s", address, esp_err_to_name(err));
|
||||||
return ERROR_UNKNOWN;
|
return ERROR_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ESPHOME_LOG_HAS_VERY_VERBOSE
|
#ifdef ESPHOME_LOG_HAS_VERY_VERBOSE
|
||||||
char debug_buf[4];
|
char debug_buf[4];
|
||||||
@ -185,6 +305,7 @@ ErrorCode IDFI2CBus::readv(uint8_t address, ReadBuffer *buffers, size_t cnt) {
|
|||||||
|
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorCode IDFI2CBus::writev(uint8_t address, WriteBuffer *buffers, size_t cnt, bool stop) {
|
ErrorCode IDFI2CBus::writev(uint8_t address, WriteBuffer *buffers, size_t cnt, bool stop) {
|
||||||
// logging is only enabled with vv level, if warnings are shown the caller
|
// logging is only enabled with vv level, if warnings are shown the caller
|
||||||
// should log them
|
// should log them
|
||||||
@ -207,6 +328,49 @@ ErrorCode IDFI2CBus::writev(uint8_t address, WriteBuffer *buffers, size_t cnt, b
|
|||||||
ESP_LOGVV(TAG, "0x%02X TX %s", address, debug_hex.c_str());
|
ESP_LOGVV(TAG, "0x%02X TX %s", address, debug_hex.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 2)
|
||||||
|
i2c_operation_job_t jobs[cnt + 3];
|
||||||
|
uint8_t write = (address << 1) | I2C_MASTER_WRITE;
|
||||||
|
size_t num = 0;
|
||||||
|
|
||||||
|
jobs[num].command = I2C_MASTER_CMD_START;
|
||||||
|
num++;
|
||||||
|
|
||||||
|
jobs[num].command = I2C_MASTER_CMD_WRITE;
|
||||||
|
jobs[num].write.ack_check = true;
|
||||||
|
jobs[num].write.data = &write;
|
||||||
|
jobs[num].write.total_bytes = 1;
|
||||||
|
num++;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < cnt; i++) {
|
||||||
|
const auto &buf = buffers[i];
|
||||||
|
if (buf.len == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
jobs[num].command = I2C_MASTER_CMD_WRITE;
|
||||||
|
jobs[num].write.ack_check = true;
|
||||||
|
jobs[num].write.data = (uint8_t *) buf.data;
|
||||||
|
jobs[num].write.total_bytes = buf.len;
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stop) {
|
||||||
|
jobs[num].command = I2C_MASTER_CMD_STOP;
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
|
||||||
|
esp_err_t err = i2c_master_execute_defined_operations(this->dev_, jobs, num, 20);
|
||||||
|
if (err == ESP_ERR_INVALID_STATE) {
|
||||||
|
ESP_LOGVV(TAG, "TX to %02X failed: not acked", address);
|
||||||
|
return ERROR_NOT_ACKNOWLEDGED;
|
||||||
|
} else if (err == ESP_ERR_TIMEOUT) {
|
||||||
|
ESP_LOGVV(TAG, "TX to %02X failed: timeout", address);
|
||||||
|
return ERROR_TIMEOUT;
|
||||||
|
} else if (err != ESP_OK) {
|
||||||
|
ESP_LOGVV(TAG, "TX to %02X failed: %s", address, esp_err_to_name(err));
|
||||||
|
return ERROR_UNKNOWN;
|
||||||
|
}
|
||||||
|
#else
|
||||||
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
|
||||||
esp_err_t err = i2c_master_start(cmd);
|
esp_err_t err = i2c_master_start(cmd);
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
@ -252,6 +416,7 @@ ErrorCode IDFI2CBus::writev(uint8_t address, WriteBuffer *buffers, size_t cnt, b
|
|||||||
ESP_LOGVV(TAG, "TX to %02X failed: %s", address, esp_err_to_name(err));
|
ESP_LOGVV(TAG, "TX to %02X failed: %s", address, esp_err_to_name(err));
|
||||||
return ERROR_UNKNOWN;
|
return ERROR_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,9 +2,14 @@
|
|||||||
|
|
||||||
#ifdef USE_ESP_IDF
|
#ifdef USE_ESP_IDF
|
||||||
|
|
||||||
#include <driver/i2c.h>
|
|
||||||
#include "esphome/core/component.h"
|
#include "esphome/core/component.h"
|
||||||
#include "i2c_bus.h"
|
#include "i2c_bus.h"
|
||||||
|
#include "esp_idf_version.h"
|
||||||
|
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 2)
|
||||||
|
#include <driver/i2c_master.h>
|
||||||
|
#else
|
||||||
|
#include <driver/i2c.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace i2c {
|
namespace i2c {
|
||||||
@ -38,6 +43,10 @@ class IDFI2CBus : public InternalI2CBus, public Component {
|
|||||||
RecoveryCode recovery_result_;
|
RecoveryCode recovery_result_;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 2)
|
||||||
|
i2c_master_dev_handle_t dev_;
|
||||||
|
i2c_master_bus_handle_t bus_;
|
||||||
|
#endif
|
||||||
i2c_port_t port_;
|
i2c_port_t port_;
|
||||||
uint8_t sda_pin_;
|
uint8_t sda_pin_;
|
||||||
bool sda_pullup_enabled_;
|
bool sda_pullup_enabled_;
|
||||||
|
@ -129,21 +129,16 @@ bool MQTTComponent::send_discovery_() {
|
|||||||
root[MQTT_PAYLOAD_NOT_AVAILABLE] = this->availability_->payload_not_available;
|
root[MQTT_PAYLOAD_NOT_AVAILABLE] = this->availability_->payload_not_available;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string unique_id = this->unique_id();
|
|
||||||
const MQTTDiscoveryInfo &discovery_info = global_mqtt_client->get_discovery_info();
|
const MQTTDiscoveryInfo &discovery_info = global_mqtt_client->get_discovery_info();
|
||||||
if (!unique_id.empty()) {
|
if (discovery_info.unique_id_generator == MQTT_MAC_ADDRESS_UNIQUE_ID_GENERATOR) {
|
||||||
root[MQTT_UNIQUE_ID] = unique_id;
|
char friendly_name_hash[9];
|
||||||
|
sprintf(friendly_name_hash, "%08" PRIx32, fnv1_hash(this->friendly_name()));
|
||||||
|
friendly_name_hash[8] = 0; // ensure the hash-string ends with null
|
||||||
|
root[MQTT_UNIQUE_ID] = get_mac_address() + "-" + this->component_type() + "-" + friendly_name_hash;
|
||||||
} else {
|
} else {
|
||||||
if (discovery_info.unique_id_generator == MQTT_MAC_ADDRESS_UNIQUE_ID_GENERATOR) {
|
// default to almost-unique ID. It's a hack but the only way to get that
|
||||||
char friendly_name_hash[9];
|
// gorgeous device registry view.
|
||||||
sprintf(friendly_name_hash, "%08" PRIx32, fnv1_hash(this->friendly_name()));
|
root[MQTT_UNIQUE_ID] = "ESP" + this->component_type() + this->get_default_object_id_();
|
||||||
friendly_name_hash[8] = 0; // ensure the hash-string ends with null
|
|
||||||
root[MQTT_UNIQUE_ID] = get_mac_address() + "-" + this->component_type() + "-" + friendly_name_hash;
|
|
||||||
} else {
|
|
||||||
// default to almost-unique ID. It's a hack but the only way to get that
|
|
||||||
// gorgeous device registry view.
|
|
||||||
root[MQTT_UNIQUE_ID] = "ESP" + this->component_type() + this->get_default_object_id_();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string &node_name = App.get_name();
|
const std::string &node_name = App.get_name();
|
||||||
@ -286,7 +281,6 @@ void MQTTComponent::call_dump_config() {
|
|||||||
this->dump_config();
|
this->dump_config();
|
||||||
}
|
}
|
||||||
void MQTTComponent::schedule_resend_state() { this->resend_state_ = true; }
|
void MQTTComponent::schedule_resend_state() { this->resend_state_ = true; }
|
||||||
std::string MQTTComponent::unique_id() { return ""; }
|
|
||||||
bool MQTTComponent::is_connected_() const { return global_mqtt_client->is_connected(); }
|
bool MQTTComponent::is_connected_() const { return global_mqtt_client->is_connected(); }
|
||||||
|
|
||||||
// Pull these properties from EntityBase if not overridden
|
// Pull these properties from EntityBase if not overridden
|
||||||
|
@ -164,13 +164,6 @@ class MQTTComponent : public Component {
|
|||||||
*/
|
*/
|
||||||
virtual const EntityBase *get_entity() const = 0;
|
virtual const EntityBase *get_entity() const = 0;
|
||||||
|
|
||||||
/** A unique ID for this MQTT component, empty for no unique id. See unique ID requirements:
|
|
||||||
* https://developers.home-assistant.io/docs/en/entity_registry_index.html#unique-id-requirements
|
|
||||||
*
|
|
||||||
* @return The unique id as a string.
|
|
||||||
*/
|
|
||||||
virtual std::string unique_id();
|
|
||||||
|
|
||||||
/// Get the friendly name of this MQTT component.
|
/// Get the friendly name of this MQTT component.
|
||||||
virtual std::string friendly_name() const;
|
virtual std::string friendly_name() const;
|
||||||
|
|
||||||
|
@ -76,7 +76,6 @@ bool MQTTSensorComponent::publish_state(float value) {
|
|||||||
int8_t accuracy = this->sensor_->get_accuracy_decimals();
|
int8_t accuracy = this->sensor_->get_accuracy_decimals();
|
||||||
return this->publish(this->get_state_topic_(), value_accuracy_to_string(value, accuracy));
|
return this->publish(this->get_state_topic_(), value_accuracy_to_string(value, accuracy));
|
||||||
}
|
}
|
||||||
std::string MQTTSensorComponent::unique_id() { return this->sensor_->unique_id(); }
|
|
||||||
|
|
||||||
} // namespace mqtt
|
} // namespace mqtt
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
@ -46,7 +46,6 @@ class MQTTSensorComponent : public mqtt::MQTTComponent {
|
|||||||
/// Override for MQTTComponent, returns "sensor".
|
/// Override for MQTTComponent, returns "sensor".
|
||||||
std::string component_type() const override;
|
std::string component_type() const override;
|
||||||
const EntityBase *get_entity() const override;
|
const EntityBase *get_entity() const override;
|
||||||
std::string unique_id() override;
|
|
||||||
|
|
||||||
sensor::Sensor *sensor_;
|
sensor::Sensor *sensor_;
|
||||||
optional<uint32_t> expire_after_; // Override the expire after advertised to Home Assistant
|
optional<uint32_t> expire_after_; // Override the expire after advertised to Home Assistant
|
||||||
|
@ -40,7 +40,6 @@ bool MQTTTextSensor::send_initial_state() {
|
|||||||
}
|
}
|
||||||
std::string MQTTTextSensor::component_type() const { return "sensor"; }
|
std::string MQTTTextSensor::component_type() const { return "sensor"; }
|
||||||
const EntityBase *MQTTTextSensor::get_entity() const { return this->sensor_; }
|
const EntityBase *MQTTTextSensor::get_entity() const { return this->sensor_; }
|
||||||
std::string MQTTTextSensor::unique_id() { return this->sensor_->unique_id(); }
|
|
||||||
|
|
||||||
} // namespace mqtt
|
} // namespace mqtt
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
@ -28,7 +28,6 @@ class MQTTTextSensor : public mqtt::MQTTComponent {
|
|||||||
protected:
|
protected:
|
||||||
std::string component_type() const override;
|
std::string component_type() const override;
|
||||||
const EntityBase *get_entity() const override;
|
const EntityBase *get_entity() const override;
|
||||||
std::string unique_id() override;
|
|
||||||
|
|
||||||
text_sensor::TextSensor *sensor_;
|
text_sensor::TextSensor *sensor_;
|
||||||
};
|
};
|
||||||
|
@ -11,8 +11,6 @@ const std::string &OneWireDevice::get_address_name() {
|
|||||||
return this->address_name_;
|
return this->address_name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string OneWireDevice::unique_id() { return "dallas-" + str_lower_case(format_hex(this->address_)); }
|
|
||||||
|
|
||||||
bool OneWireDevice::send_command_(uint8_t cmd) {
|
bool OneWireDevice::send_command_(uint8_t cmd) {
|
||||||
if (!this->bus_->select(this->address_))
|
if (!this->bus_->select(this->address_))
|
||||||
return false;
|
return false;
|
||||||
|
@ -24,8 +24,6 @@ class OneWireDevice {
|
|||||||
/// Helper to create (and cache) the name for this sensor. For example "0xfe0000031f1eaf29".
|
/// Helper to create (and cache) the name for this sensor. For example "0xfe0000031f1eaf29".
|
||||||
const std::string &get_address_name();
|
const std::string &get_address_name();
|
||||||
|
|
||||||
std::string unique_id();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint64_t address_{0};
|
uint64_t address_{0};
|
||||||
OneWireBus *bus_{nullptr}; ///< pointer to OneWireBus instance
|
OneWireBus *bus_{nullptr}; ///< pointer to OneWireBus instance
|
||||||
|
@ -50,6 +50,7 @@ optional<float> MedianFilter::new_value(float value) {
|
|||||||
if (!this->queue_.empty()) {
|
if (!this->queue_.empty()) {
|
||||||
// Copy queue without NaN values
|
// Copy queue without NaN values
|
||||||
std::vector<float> median_queue;
|
std::vector<float> median_queue;
|
||||||
|
median_queue.reserve(this->queue_.size());
|
||||||
for (auto v : this->queue_) {
|
for (auto v : this->queue_) {
|
||||||
if (!std::isnan(v)) {
|
if (!std::isnan(v)) {
|
||||||
median_queue.push_back(v);
|
median_queue.push_back(v);
|
||||||
|
@ -96,7 +96,6 @@ void Sensor::clear_filters() {
|
|||||||
}
|
}
|
||||||
float Sensor::get_state() const { return this->state; }
|
float Sensor::get_state() const { return this->state; }
|
||||||
float Sensor::get_raw_state() const { return this->raw_state; }
|
float Sensor::get_raw_state() const { return this->raw_state; }
|
||||||
std::string Sensor::unique_id() { return ""; }
|
|
||||||
|
|
||||||
void Sensor::internal_send_state_to_frontend(float state) {
|
void Sensor::internal_send_state_to_frontend(float state) {
|
||||||
this->set_has_state(true);
|
this->set_has_state(true);
|
||||||
|
@ -28,9 +28,6 @@ namespace sensor {
|
|||||||
if (!(obj)->get_icon().empty()) { \
|
if (!(obj)->get_icon().empty()) { \
|
||||||
ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, (obj)->get_icon().c_str()); \
|
ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, (obj)->get_icon().c_str()); \
|
||||||
} \
|
} \
|
||||||
if (!(obj)->unique_id().empty()) { \
|
|
||||||
ESP_LOGV(TAG, "%s Unique ID: '%s'", prefix, (obj)->unique_id().c_str()); \
|
|
||||||
} \
|
|
||||||
if ((obj)->get_force_update()) { \
|
if ((obj)->get_force_update()) { \
|
||||||
ESP_LOGV(TAG, "%s Force Update: YES", prefix); \
|
ESP_LOGV(TAG, "%s Force Update: YES", prefix); \
|
||||||
} \
|
} \
|
||||||
@ -141,12 +138,6 @@ class Sensor : public EntityBase, public EntityBase_DeviceClass, public EntityBa
|
|||||||
*/
|
*/
|
||||||
float raw_state;
|
float raw_state;
|
||||||
|
|
||||||
/** Override this method to set the unique ID of this sensor.
|
|
||||||
*
|
|
||||||
* @deprecated Do not use for new sensors, a suitable unique ID is automatically generated (2023.4).
|
|
||||||
*/
|
|
||||||
virtual std::string unique_id();
|
|
||||||
|
|
||||||
void internal_send_state_to_frontend(float state);
|
void internal_send_state_to_frontend(float state);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -176,7 +176,7 @@ void SSD1306::setup() {
|
|||||||
// Disable scrolling mode (0x2E)
|
// Disable scrolling mode (0x2E)
|
||||||
this->command(SSD1306_COMMAND_DEACTIVATE_SCROLL);
|
this->command(SSD1306_COMMAND_DEACTIVATE_SCROLL);
|
||||||
|
|
||||||
// Contrast and brighrness
|
// Contrast and brightness
|
||||||
// SSD1306 does not have brightness setting
|
// SSD1306 does not have brightness setting
|
||||||
set_contrast(this->contrast_);
|
set_contrast(this->contrast_);
|
||||||
if (this->is_ssd1305_())
|
if (this->is_ssd1305_())
|
||||||
|
@ -70,7 +70,5 @@ void TextSensor::internal_send_state_to_frontend(const std::string &state) {
|
|||||||
this->callback_.call(state);
|
this->callback_.call(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string TextSensor::unique_id() { return ""; }
|
|
||||||
|
|
||||||
} // namespace text_sensor
|
} // namespace text_sensor
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
@ -20,9 +20,6 @@ namespace text_sensor {
|
|||||||
if (!(obj)->get_icon().empty()) { \
|
if (!(obj)->get_icon().empty()) { \
|
||||||
ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, (obj)->get_icon().c_str()); \
|
ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, (obj)->get_icon().c_str()); \
|
||||||
} \
|
} \
|
||||||
if (!(obj)->unique_id().empty()) { \
|
|
||||||
ESP_LOGV(TAG, "%s Unique ID: '%s'", prefix, (obj)->unique_id().c_str()); \
|
|
||||||
} \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SUB_TEXT_SENSOR(name) \
|
#define SUB_TEXT_SENSOR(name) \
|
||||||
@ -64,11 +61,6 @@ class TextSensor : public EntityBase, public EntityBase_DeviceClass {
|
|||||||
|
|
||||||
// ========== INTERNAL METHODS ==========
|
// ========== INTERNAL METHODS ==========
|
||||||
// (In most use cases you won't need these)
|
// (In most use cases you won't need these)
|
||||||
/** Override this method to set the unique ID of this sensor.
|
|
||||||
*
|
|
||||||
* @deprecated Do not use for new sensors, a suitable unique ID is automatically generated (2023.4).
|
|
||||||
*/
|
|
||||||
virtual std::string unique_id();
|
|
||||||
|
|
||||||
void internal_send_state_to_frontend(const std::string &state);
|
void internal_send_state_to_frontend(const std::string &state);
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ void UptimeSecondsSensor::update() {
|
|||||||
const float seconds = float(seconds_int) + (this->uptime_ % 1000ULL) / 1000.0f;
|
const float seconds = float(seconds_int) + (this->uptime_ % 1000ULL) / 1000.0f;
|
||||||
this->publish_state(seconds);
|
this->publish_state(seconds);
|
||||||
}
|
}
|
||||||
std::string UptimeSecondsSensor::unique_id() { return get_mac_address() + "-uptime"; }
|
|
||||||
float UptimeSecondsSensor::get_setup_priority() const { return setup_priority::HARDWARE; }
|
float UptimeSecondsSensor::get_setup_priority() const { return setup_priority::HARDWARE; }
|
||||||
void UptimeSecondsSensor::dump_config() {
|
void UptimeSecondsSensor::dump_config() {
|
||||||
LOG_SENSOR("", "Uptime Sensor", this);
|
LOG_SENSOR("", "Uptime Sensor", this);
|
||||||
|
@ -13,8 +13,6 @@ class UptimeSecondsSensor : public sensor::Sensor, public PollingComponent {
|
|||||||
|
|
||||||
float get_setup_priority() const override;
|
float get_setup_priority() const override;
|
||||||
|
|
||||||
std::string unique_id() override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint64_t uptime_{0};
|
uint64_t uptime_{0};
|
||||||
};
|
};
|
||||||
|
@ -17,7 +17,6 @@ void VersionTextSensor::setup() {
|
|||||||
}
|
}
|
||||||
float VersionTextSensor::get_setup_priority() const { return setup_priority::DATA; }
|
float VersionTextSensor::get_setup_priority() const { return setup_priority::DATA; }
|
||||||
void VersionTextSensor::set_hide_timestamp(bool hide_timestamp) { this->hide_timestamp_ = hide_timestamp; }
|
void VersionTextSensor::set_hide_timestamp(bool hide_timestamp) { this->hide_timestamp_ = hide_timestamp; }
|
||||||
std::string VersionTextSensor::unique_id() { return get_mac_address() + "-version"; }
|
|
||||||
void VersionTextSensor::dump_config() { LOG_TEXT_SENSOR("", "Version Text Sensor", this); }
|
void VersionTextSensor::dump_config() { LOG_TEXT_SENSOR("", "Version Text Sensor", this); }
|
||||||
|
|
||||||
} // namespace version
|
} // namespace version
|
||||||
|
@ -12,7 +12,6 @@ class VersionTextSensor : public text_sensor::TextSensor, public Component {
|
|||||||
void setup() override;
|
void setup() override;
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
float get_setup_priority() const override;
|
float get_setup_priority() const override;
|
||||||
std::string unique_id() override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool hide_timestamp_{false};
|
bool hide_timestamp_{false};
|
||||||
|
@ -28,7 +28,6 @@ class IPAddressWiFiInfo : public PollingComponent, public text_sensor::TextSenso
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
||||||
std::string unique_id() override { return get_mac_address() + "-wifiinfo-ip"; }
|
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
void add_ip_sensors(uint8_t index, text_sensor::TextSensor *s) { this->ip_sensors_[index] = s; }
|
void add_ip_sensors(uint8_t index, text_sensor::TextSensor *s) { this->ip_sensors_[index] = s; }
|
||||||
|
|
||||||
@ -51,7 +50,6 @@ class DNSAddressWifiInfo : public PollingComponent, public text_sensor::TextSens
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
||||||
std::string unique_id() override { return get_mac_address() + "-wifiinfo-dns"; }
|
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -80,7 +78,6 @@ class ScanResultsWiFiInfo : public PollingComponent, public text_sensor::TextSen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
||||||
std::string unique_id() override { return get_mac_address() + "-wifiinfo-scanresults"; }
|
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -97,7 +94,6 @@ class SSIDWiFiInfo : public PollingComponent, public text_sensor::TextSensor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
||||||
std::string unique_id() override { return get_mac_address() + "-wifiinfo-ssid"; }
|
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -116,7 +112,6 @@ class BSSIDWiFiInfo : public PollingComponent, public text_sensor::TextSensor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
||||||
std::string unique_id() override { return get_mac_address() + "-wifiinfo-bssid"; }
|
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -126,7 +121,6 @@ class BSSIDWiFiInfo : public PollingComponent, public text_sensor::TextSensor {
|
|||||||
class MacAddressWifiInfo : public Component, public text_sensor::TextSensor {
|
class MacAddressWifiInfo : public Component, public text_sensor::TextSensor {
|
||||||
public:
|
public:
|
||||||
void setup() override { this->publish_state(get_mac_address_pretty()); }
|
void setup() override { this->publish_state(get_mac_address_pretty()); }
|
||||||
std::string unique_id() override { return get_mac_address() + "-wifiinfo-macadr"; }
|
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ class WiFiSignalSensor : public sensor::Sensor, public PollingComponent {
|
|||||||
void update() override { this->publish_state(wifi::global_wifi_component->wifi_rssi()); }
|
void update() override { this->publish_state(wifi::global_wifi_component->wifi_rssi()); }
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
|
|
||||||
std::string unique_id() override { return get_mac_address() + "-wifisignal"; }
|
|
||||||
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ void Application::setup() {
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
uint8_t new_app_state = STATUS_LED_WARNING;
|
uint8_t new_app_state = STATUS_LED_WARNING;
|
||||||
this->scheduler.call();
|
this->scheduler.call(millis());
|
||||||
this->feed_wdt();
|
this->feed_wdt();
|
||||||
for (uint32_t j = 0; j <= i; j++) {
|
for (uint32_t j = 0; j <= i; j++) {
|
||||||
// Update loop_component_start_time_ right before calling each component
|
// Update loop_component_start_time_ right before calling each component
|
||||||
@ -97,11 +97,11 @@ void Application::setup() {
|
|||||||
void Application::loop() {
|
void Application::loop() {
|
||||||
uint8_t new_app_state = 0;
|
uint8_t new_app_state = 0;
|
||||||
|
|
||||||
this->scheduler.call();
|
|
||||||
|
|
||||||
// Get the initial loop time at the start
|
// Get the initial loop time at the start
|
||||||
uint32_t last_op_end_time = millis();
|
uint32_t last_op_end_time = millis();
|
||||||
|
|
||||||
|
this->scheduler.call(last_op_end_time);
|
||||||
|
|
||||||
// Feed WDT with time
|
// Feed WDT with time
|
||||||
this->feed_wdt(last_op_end_time);
|
this->feed_wdt(last_op_end_time);
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ void Application::loop() {
|
|||||||
this->yield_with_select_(0);
|
this->yield_with_select_(0);
|
||||||
} else {
|
} else {
|
||||||
uint32_t delay_time = this->loop_interval_ - elapsed;
|
uint32_t delay_time = this->loop_interval_ - elapsed;
|
||||||
uint32_t next_schedule = this->scheduler.next_schedule_in().value_or(delay_time);
|
uint32_t next_schedule = this->scheduler.next_schedule_in(last_op_end_time).value_or(delay_time);
|
||||||
// next_schedule is max 0.5*delay_time
|
// next_schedule is max 0.5*delay_time
|
||||||
// otherwise interval=0 schedules result in constant looping with almost no sleep
|
// otherwise interval=0 schedules result in constant looping with almost no sleep
|
||||||
next_schedule = std::max(next_schedule, delay_time / 2);
|
next_schedule = std::max(next_schedule, delay_time / 2);
|
||||||
|
@ -91,7 +91,7 @@ void HOT Scheduler::set_timer_common_(Component *component, SchedulerItem::Type
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const auto now = this->millis_();
|
const auto now = this->millis_64_(millis());
|
||||||
|
|
||||||
// Type-specific setup
|
// Type-specific setup
|
||||||
if (type == SchedulerItem::INTERVAL) {
|
if (type == SchedulerItem::INTERVAL) {
|
||||||
@ -193,9 +193,7 @@ void HOT Scheduler::set_retry(Component *component, const std::string &name, uin
|
|||||||
name.c_str(), initial_wait_time, max_attempts, backoff_increase_factor);
|
name.c_str(), initial_wait_time, max_attempts, backoff_increase_factor);
|
||||||
|
|
||||||
if (backoff_increase_factor < 0.0001) {
|
if (backoff_increase_factor < 0.0001) {
|
||||||
ESP_LOGE(TAG,
|
ESP_LOGE(TAG, "backoff_factor %0.1f too small, using 1.0: %s", backoff_increase_factor, name.c_str());
|
||||||
"set_retry(name='%s'): backoff_factor cannot be close to zero nor negative (%0.1f). Using 1.0 instead",
|
|
||||||
name.c_str(), backoff_increase_factor);
|
|
||||||
backoff_increase_factor = 1;
|
backoff_increase_factor = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,19 +213,19 @@ bool HOT Scheduler::cancel_retry(Component *component, const std::string &name)
|
|||||||
return this->cancel_timeout(component, "retry$" + name);
|
return this->cancel_timeout(component, "retry$" + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
optional<uint32_t> HOT Scheduler::next_schedule_in() {
|
optional<uint32_t> HOT Scheduler::next_schedule_in(uint32_t now) {
|
||||||
// IMPORTANT: This method should only be called from the main thread (loop task).
|
// IMPORTANT: This method should only be called from the main thread (loop task).
|
||||||
// It calls empty_() and accesses items_[0] without holding a lock, which is only
|
// It calls empty_() and accesses items_[0] without holding a lock, which is only
|
||||||
// safe when called from the main thread. Other threads must not call this method.
|
// safe when called from the main thread. Other threads must not call this method.
|
||||||
if (this->empty_())
|
if (this->empty_())
|
||||||
return {};
|
return {};
|
||||||
auto &item = this->items_[0];
|
auto &item = this->items_[0];
|
||||||
const auto now = this->millis_();
|
const auto now_64 = this->millis_64_(now);
|
||||||
if (item->next_execution_ < now)
|
if (item->next_execution_ < now_64)
|
||||||
return 0;
|
return 0;
|
||||||
return item->next_execution_ - now;
|
return item->next_execution_ - now_64;
|
||||||
}
|
}
|
||||||
void HOT Scheduler::call() {
|
void HOT Scheduler::call(uint32_t now) {
|
||||||
#if !defined(USE_ESP8266) && !defined(USE_RP2040)
|
#if !defined(USE_ESP8266) && !defined(USE_RP2040)
|
||||||
// Process defer queue first to guarantee FIFO execution order for deferred items.
|
// Process defer queue first to guarantee FIFO execution order for deferred items.
|
||||||
// Previously, defer() used the heap which gave undefined order for equal timestamps,
|
// Previously, defer() used the heap which gave undefined order for equal timestamps,
|
||||||
@ -256,22 +254,22 @@ void HOT Scheduler::call() {
|
|||||||
// Execute callback without holding lock to prevent deadlocks
|
// Execute callback without holding lock to prevent deadlocks
|
||||||
// if the callback tries to call defer() again
|
// if the callback tries to call defer() again
|
||||||
if (!this->should_skip_item_(item.get())) {
|
if (!this->should_skip_item_(item.get())) {
|
||||||
this->execute_item_(item.get());
|
this->execute_item_(item.get(), now);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const auto now = this->millis_();
|
const auto now_64 = this->millis_64_(now);
|
||||||
this->process_to_add();
|
this->process_to_add();
|
||||||
|
|
||||||
#ifdef ESPHOME_DEBUG_SCHEDULER
|
#ifdef ESPHOME_DEBUG_SCHEDULER
|
||||||
static uint64_t last_print = 0;
|
static uint64_t last_print = 0;
|
||||||
|
|
||||||
if (now - last_print > 2000) {
|
if (now_64 - last_print > 2000) {
|
||||||
last_print = now;
|
last_print = now_64;
|
||||||
std::vector<std::unique_ptr<SchedulerItem>> old_items;
|
std::vector<std::unique_ptr<SchedulerItem>> old_items;
|
||||||
ESP_LOGD(TAG, "Items: count=%zu, now=%" PRIu64 " (%u, %" PRIu32 ")", this->items_.size(), now, this->millis_major_,
|
ESP_LOGD(TAG, "Items: count=%zu, now=%" PRIu64 " (%u, %" PRIu32 ")", this->items_.size(), now_64,
|
||||||
this->last_millis_);
|
this->millis_major_, this->last_millis_);
|
||||||
while (!this->empty_()) {
|
while (!this->empty_()) {
|
||||||
std::unique_ptr<SchedulerItem> item;
|
std::unique_ptr<SchedulerItem> item;
|
||||||
{
|
{
|
||||||
@ -283,7 +281,7 @@ void HOT Scheduler::call() {
|
|||||||
const char *name = item->get_name();
|
const char *name = item->get_name();
|
||||||
ESP_LOGD(TAG, " %s '%s/%s' interval=%" PRIu32 " next_execution in %" PRIu64 "ms at %" PRIu64,
|
ESP_LOGD(TAG, " %s '%s/%s' interval=%" PRIu32 " next_execution in %" PRIu64 "ms at %" PRIu64,
|
||||||
item->get_type_str(), item->get_source(), name ? name : "(null)", item->interval,
|
item->get_type_str(), item->get_source(), name ? name : "(null)", item->interval,
|
||||||
item->next_execution_ - now, item->next_execution_);
|
item->next_execution_ - now_64, item->next_execution_);
|
||||||
|
|
||||||
old_items.push_back(std::move(item));
|
old_items.push_back(std::move(item));
|
||||||
}
|
}
|
||||||
@ -328,7 +326,7 @@ void HOT Scheduler::call() {
|
|||||||
{
|
{
|
||||||
// Don't copy-by value yet
|
// Don't copy-by value yet
|
||||||
auto &item = this->items_[0];
|
auto &item = this->items_[0];
|
||||||
if (item->next_execution_ > now) {
|
if (item->next_execution_ > now_64) {
|
||||||
// Not reached timeout yet, done for this call
|
// Not reached timeout yet, done for this call
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -342,13 +340,13 @@ void HOT Scheduler::call() {
|
|||||||
const char *item_name = item->get_name();
|
const char *item_name = item->get_name();
|
||||||
ESP_LOGV(TAG, "Running %s '%s/%s' with interval=%" PRIu32 " next_execution=%" PRIu64 " (now=%" PRIu64 ")",
|
ESP_LOGV(TAG, "Running %s '%s/%s' with interval=%" PRIu32 " next_execution=%" PRIu64 " (now=%" PRIu64 ")",
|
||||||
item->get_type_str(), item->get_source(), item_name ? item_name : "(null)", item->interval,
|
item->get_type_str(), item->get_source(), item_name ? item_name : "(null)", item->interval,
|
||||||
item->next_execution_, now);
|
item->next_execution_, now_64);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Warning: During callback(), a lot of stuff can happen, including:
|
// Warning: During callback(), a lot of stuff can happen, including:
|
||||||
// - timeouts/intervals get added, potentially invalidating vector pointers
|
// - timeouts/intervals get added, potentially invalidating vector pointers
|
||||||
// - timeouts/intervals get cancelled
|
// - timeouts/intervals get cancelled
|
||||||
this->execute_item_(item.get());
|
this->execute_item_(item.get(), now);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -367,7 +365,7 @@ void HOT Scheduler::call() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (item->type == SchedulerItem::INTERVAL) {
|
if (item->type == SchedulerItem::INTERVAL) {
|
||||||
item->next_execution_ = now + item->interval;
|
item->next_execution_ = now_64 + item->interval;
|
||||||
// Add new item directly to to_add_
|
// Add new item directly to to_add_
|
||||||
// since we have the lock held
|
// since we have the lock held
|
||||||
this->to_add_.push_back(std::move(item));
|
this->to_add_.push_back(std::move(item));
|
||||||
@ -423,11 +421,9 @@ void HOT Scheduler::pop_raw_() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper to execute a scheduler item
|
// Helper to execute a scheduler item
|
||||||
void HOT Scheduler::execute_item_(SchedulerItem *item) {
|
void HOT Scheduler::execute_item_(SchedulerItem *item, uint32_t now) {
|
||||||
App.set_current_component(item->component);
|
App.set_current_component(item->component);
|
||||||
|
WarnIfComponentBlockingGuard guard{item->component, now};
|
||||||
uint32_t now_ms = millis();
|
|
||||||
WarnIfComponentBlockingGuard guard{item->component, now_ms};
|
|
||||||
item->callback();
|
item->callback();
|
||||||
guard.finish();
|
guard.finish();
|
||||||
}
|
}
|
||||||
@ -486,15 +482,15 @@ bool HOT Scheduler::cancel_item_locked_(Component *component, const char *name_c
|
|||||||
return total_cancelled > 0;
|
return total_cancelled > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Scheduler::millis_() {
|
uint64_t Scheduler::millis_64_(uint32_t now) {
|
||||||
// Get the current 32-bit millis value
|
|
||||||
const uint32_t now = millis();
|
|
||||||
// Check for rollover by comparing with last value
|
// Check for rollover by comparing with last value
|
||||||
if (now < this->last_millis_) {
|
if (now < this->last_millis_) {
|
||||||
// Detected rollover (happens every ~49.7 days)
|
// Detected rollover (happens every ~49.7 days)
|
||||||
this->millis_major_++;
|
this->millis_major_++;
|
||||||
|
#ifdef ESPHOME_DEBUG_SCHEDULER
|
||||||
ESP_LOGD(TAG, "Incrementing scheduler major at %" PRIu64 "ms",
|
ESP_LOGD(TAG, "Incrementing scheduler major at %" PRIu64 "ms",
|
||||||
now + (static_cast<uint64_t>(this->millis_major_) << 32));
|
now + (static_cast<uint64_t>(this->millis_major_) << 32));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
this->last_millis_ = now;
|
this->last_millis_ = now;
|
||||||
// Combine major (high 32 bits) and now (low 32 bits) into 64-bit time
|
// Combine major (high 32 bits) and now (low 32 bits) into 64-bit time
|
||||||
|
@ -52,9 +52,9 @@ class Scheduler {
|
|||||||
std::function<RetryResult(uint8_t)> func, float backoff_increase_factor = 1.0f);
|
std::function<RetryResult(uint8_t)> func, float backoff_increase_factor = 1.0f);
|
||||||
bool cancel_retry(Component *component, const std::string &name);
|
bool cancel_retry(Component *component, const std::string &name);
|
||||||
|
|
||||||
optional<uint32_t> next_schedule_in();
|
optional<uint32_t> next_schedule_in(uint32_t now);
|
||||||
|
|
||||||
void call();
|
void call(uint32_t now);
|
||||||
|
|
||||||
void process_to_add();
|
void process_to_add();
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ class Scheduler {
|
|||||||
void set_timer_common_(Component *component, SchedulerItem::Type type, bool is_static_string, const void *name_ptr,
|
void set_timer_common_(Component *component, SchedulerItem::Type type, bool is_static_string, const void *name_ptr,
|
||||||
uint32_t delay, std::function<void()> func);
|
uint32_t delay, std::function<void()> func);
|
||||||
|
|
||||||
uint64_t millis_();
|
uint64_t millis_64_(uint32_t now);
|
||||||
void cleanup_();
|
void cleanup_();
|
||||||
void pop_raw_();
|
void pop_raw_();
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ class Scheduler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper to execute a scheduler item
|
// Helper to execute a scheduler item
|
||||||
void execute_item_(SchedulerItem *item);
|
void execute_item_(SchedulerItem *item, uint32_t now);
|
||||||
|
|
||||||
// Helper to check if item should be skipped
|
// Helper to check if item should be skipped
|
||||||
bool should_skip_item_(const SchedulerItem *item) const {
|
bool should_skip_item_(const SchedulerItem *item) const {
|
||||||
|
@ -240,26 +240,6 @@ class TypeInfo(ABC):
|
|||||||
value = value_expr if value_expr else name
|
value = value_expr if value_expr else name
|
||||||
return f"ProtoSize::{method}(total_size, {field_id_size}, {value});"
|
return f"ProtoSize::{method}(total_size, {field_id_size}, {value});"
|
||||||
|
|
||||||
def _get_fixed_size_calculation(
|
|
||||||
self, name: str, force: bool, num_bytes: int, zero_check: str
|
|
||||||
) -> str:
|
|
||||||
"""Helper for fixed-size field calculations.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
name: Field name
|
|
||||||
force: Whether this is for a repeated field
|
|
||||||
num_bytes: Number of bytes (4 or 8)
|
|
||||||
zero_check: Expression to check for zero value (e.g., "!= 0.0f")
|
|
||||||
"""
|
|
||||||
field_id_size = self.calculate_field_id_size()
|
|
||||||
# Fixed-size repeated fields are handled differently in RepeatedTypeInfo
|
|
||||||
# so we should never get force=True here
|
|
||||||
assert not force, (
|
|
||||||
"Fixed-size repeated fields should be handled by RepeatedTypeInfo"
|
|
||||||
)
|
|
||||||
method = f"add_fixed_field<{num_bytes}>"
|
|
||||||
return f"ProtoSize::{method}(total_size, {field_id_size}, {name} {zero_check});"
|
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_size_calculation(self, name: str, force: bool = False) -> str:
|
def get_size_calculation(self, name: str, force: bool = False) -> str:
|
||||||
"""Calculate the size needed for encoding this field.
|
"""Calculate the size needed for encoding this field.
|
||||||
@ -345,7 +325,8 @@ class DoubleType(TypeInfo):
|
|||||||
return o
|
return o
|
||||||
|
|
||||||
def get_size_calculation(self, name: str, force: bool = False) -> str:
|
def get_size_calculation(self, name: str, force: bool = False) -> str:
|
||||||
return self._get_fixed_size_calculation(name, force, 8, "!= 0.0")
|
field_id_size = self.calculate_field_id_size()
|
||||||
|
return f"ProtoSize::add_double_field(total_size, {field_id_size}, {name});"
|
||||||
|
|
||||||
def get_fixed_size_bytes(self) -> int:
|
def get_fixed_size_bytes(self) -> int:
|
||||||
return 8
|
return 8
|
||||||
@ -368,7 +349,8 @@ class FloatType(TypeInfo):
|
|||||||
return o
|
return o
|
||||||
|
|
||||||
def get_size_calculation(self, name: str, force: bool = False) -> str:
|
def get_size_calculation(self, name: str, force: bool = False) -> str:
|
||||||
return self._get_fixed_size_calculation(name, force, 4, "!= 0.0f")
|
field_id_size = self.calculate_field_id_size()
|
||||||
|
return f"ProtoSize::add_float_field(total_size, {field_id_size}, {name});"
|
||||||
|
|
||||||
def get_fixed_size_bytes(self) -> int:
|
def get_fixed_size_bytes(self) -> int:
|
||||||
return 4
|
return 4
|
||||||
@ -451,7 +433,8 @@ class Fixed64Type(TypeInfo):
|
|||||||
return o
|
return o
|
||||||
|
|
||||||
def get_size_calculation(self, name: str, force: bool = False) -> str:
|
def get_size_calculation(self, name: str, force: bool = False) -> str:
|
||||||
return self._get_fixed_size_calculation(name, force, 8, "!= 0")
|
field_id_size = self.calculate_field_id_size()
|
||||||
|
return f"ProtoSize::add_fixed64_field(total_size, {field_id_size}, {name});"
|
||||||
|
|
||||||
def get_fixed_size_bytes(self) -> int:
|
def get_fixed_size_bytes(self) -> int:
|
||||||
return 8
|
return 8
|
||||||
@ -474,7 +457,8 @@ class Fixed32Type(TypeInfo):
|
|||||||
return o
|
return o
|
||||||
|
|
||||||
def get_size_calculation(self, name: str, force: bool = False) -> str:
|
def get_size_calculation(self, name: str, force: bool = False) -> str:
|
||||||
return self._get_fixed_size_calculation(name, force, 4, "!= 0")
|
field_id_size = self.calculate_field_id_size()
|
||||||
|
return f"ProtoSize::add_fixed32_field(total_size, {field_id_size}, {name});"
|
||||||
|
|
||||||
def get_fixed_size_bytes(self) -> int:
|
def get_fixed_size_bytes(self) -> int:
|
||||||
return 4
|
return 4
|
||||||
@ -663,7 +647,8 @@ class SFixed32Type(TypeInfo):
|
|||||||
return o
|
return o
|
||||||
|
|
||||||
def get_size_calculation(self, name: str, force: bool = False) -> str:
|
def get_size_calculation(self, name: str, force: bool = False) -> str:
|
||||||
return self._get_fixed_size_calculation(name, force, 4, "!= 0")
|
field_id_size = self.calculate_field_id_size()
|
||||||
|
return f"ProtoSize::add_sfixed32_field(total_size, {field_id_size}, {name});"
|
||||||
|
|
||||||
def get_fixed_size_bytes(self) -> int:
|
def get_fixed_size_bytes(self) -> int:
|
||||||
return 4
|
return 4
|
||||||
@ -686,7 +671,8 @@ class SFixed64Type(TypeInfo):
|
|||||||
return o
|
return o
|
||||||
|
|
||||||
def get_size_calculation(self, name: str, force: bool = False) -> str:
|
def get_size_calculation(self, name: str, force: bool = False) -> str:
|
||||||
return self._get_fixed_size_calculation(name, force, 8, "!= 0")
|
field_id_size = self.calculate_field_id_size()
|
||||||
|
return f"ProtoSize::add_sfixed64_field(total_size, {field_id_size}, {name});"
|
||||||
|
|
||||||
def get_fixed_size_bytes(self) -> int:
|
def get_fixed_size_bytes(self) -> int:
|
||||||
return 8
|
return 8
|
||||||
|
Loading…
x
Reference in New Issue
Block a user