mirror of
https://github.com/esphome/esphome.git
synced 2026-07-10 08:55:36 +00:00
tests update
This commit is contained in:
@@ -13,22 +13,22 @@ climate:
|
||||
on_state:
|
||||
- logger.log: State changed!
|
||||
- lambda: |-
|
||||
// Test get_custom_fan_mode() returns std::string_view
|
||||
// Test get_custom_fan_mode() returns StringRef
|
||||
if (id(midea_unit).has_custom_fan_mode()) {
|
||||
auto fan_mode = id(midea_unit).get_custom_fan_mode();
|
||||
// Compare with string literal using ==
|
||||
if (fan_mode == "SILENT") {
|
||||
ESP_LOGD("test", "Fan mode is SILENT");
|
||||
}
|
||||
// Log using %.*s format for string_view
|
||||
ESP_LOGD("test", "Custom fan mode: %.*s", (int) fan_mode.size(), fan_mode.data());
|
||||
// Log using %.*s format for StringRef
|
||||
ESP_LOGD("test", "Custom fan mode: %.*s", (int) fan_mode.size(), fan_mode.c_str());
|
||||
}
|
||||
// Test get_custom_preset() returns std::string_view
|
||||
// Test get_custom_preset() returns StringRef
|
||||
if (id(midea_unit).has_custom_preset()) {
|
||||
auto preset = id(midea_unit).get_custom_preset();
|
||||
// Check if empty
|
||||
if (!preset.empty()) {
|
||||
ESP_LOGD("test", "Custom preset: %.*s", (int) preset.size(), preset.data());
|
||||
ESP_LOGD("test", "Custom preset: %.*s", (int) preset.size(), preset.c_str());
|
||||
}
|
||||
}
|
||||
transmitter_id: xmitr
|
||||
|
||||
Reference in New Issue
Block a user