mirror of
https://github.com/esphome/esphome.git
synced 2026-07-10 17:05:36 +00:00
Use plain vector compat members, add custom modes benchmark
The owned vectors add 48 bytes to ClimateTraits copies — this is the cost of backward compat and will be removed in 2026.11.0. Add ClimatePublish_WithCustomModes benchmark to show the improvement for climate devices that use custom fan modes and presets (the case that previously heap-allocated on every publish).
This commit is contained in:
@@ -54,6 +54,9 @@ static void setup_hvac_climate(BenchClimate &climate) {
|
||||
climate.traits_.set_visual_target_temperature_step(0.5f);
|
||||
climate.traits_.set_visual_current_temperature_step(0.1f);
|
||||
climate.traits_.add_feature_flags(climate::CLIMATE_SUPPORTS_CURRENT_TEMPERATURE | climate::CLIMATE_SUPPORTS_ACTION);
|
||||
// Custom modes use the new API — stored on Climate entity, zero-copy in get_traits()
|
||||
climate.set_supported_custom_fan_modes({"Turbo", "Silent", "Eco"});
|
||||
climate.set_supported_custom_presets({"My Preset", "Night Mode"});
|
||||
}
|
||||
|
||||
// --- Climate::publish_state() with temperature update ---
|
||||
|
||||
Reference in New Issue
Block a user