[select] Remove deprecated state member (#17027)

This commit is contained in:
J. Nick Koston
2026-06-19 00:08:07 -05:00
committed by GitHub
parent 6a79dfb5c5
commit 4ae6dc355f
3 changed files with 6 additions and 17 deletions

View File

@@ -27,10 +27,6 @@ void Select::publish_state(size_t index) {
const char *option = this->option_at(index);
this->set_has_state(true);
this->active_index_ = index;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
this->state = option; // Update deprecated member for backward compatibility
#pragma GCC diagnostic pop
ESP_LOGV(TAG, "'%s' >> %s (%zu)", this->get_name().c_str(), option, index);
this->state_callback_.call(index);
#if defined(USE_SELECT) && defined(USE_CONTROLLER_REGISTRY)

View File

@@ -30,15 +30,8 @@ class Select : public EntityBase {
public:
SelectTraits traits;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
/// @deprecated Use current_option() instead. This member will be removed in ESPHome 2026.7.0.
ESPDEPRECATED("Use current_option() instead of .state. Will be removed in 2026.7.0", "2026.1.0")
std::string state{};
Select() = default;
~Select() = default;
#pragma GCC diagnostic pop
void publish_state(const std::string &state);
void publish_state(const char *state);

View File

@@ -109,7 +109,7 @@ select:
set_action:
- lambda: |-
ESP_LOGI("test", "Device A Mode set to %s", x.c_str());
id(mode_device_a).state = x;
id(mode_device_a).publish_state(x);
- platform: template
name: Mode
@@ -124,7 +124,7 @@ select:
set_action:
- lambda: |-
ESP_LOGI("test", "Device B Mode set to %s", x.c_str());
id(mode_device_b).state = x;
id(mode_device_b).publish_state(x);
- platform: template
name: Mode
@@ -138,7 +138,7 @@ select:
set_action:
- lambda: |-
ESP_LOGI("test", "Main Mode set to %s", x.c_str());
id(mode_main).state = x;
id(mode_main).publish_state(x);
# Button to trigger preference logging test
button:
@@ -153,9 +153,9 @@ button:
ESP_LOGI("test", "Device A Setpoint: %.1f", id(setpoint_device_a).state);
ESP_LOGI("test", "Device B Setpoint: %.1f", id(setpoint_device_b).state);
ESP_LOGI("test", "Main Setpoint: %.1f", id(setpoint_main).state);
ESP_LOGI("test", "Device A Mode: %s", id(mode_device_a).state.c_str());
ESP_LOGI("test", "Device B Mode: %s", id(mode_device_b).state.c_str());
ESP_LOGI("test", "Main Mode: %s", id(mode_main).state.c_str());
ESP_LOGI("test", "Device A Mode: %s", id(mode_device_a).current_option().c_str());
ESP_LOGI("test", "Device B Mode: %s", id(mode_device_b).current_option().c_str());
ESP_LOGI("test", "Main Mode: %s", id(mode_main).current_option().c_str());
// Log preference hashes for entities that actually store preferences
ESP_LOGI("test", "Device A Switch Pref Hash: %u", id(light_device_a).get_preference_hash());
ESP_LOGI("test", "Device B Switch Pref Hash: %u", id(light_device_b).get_preference_hash());