mirror of
https://github.com/esphome/esphome.git
synced 2026-06-24 13:27:14 +00:00
[select] Remove deprecated state member (#17027)
This commit is contained in:
@@ -27,10 +27,6 @@ void Select::publish_state(size_t index) {
|
|||||||
const char *option = this->option_at(index);
|
const char *option = this->option_at(index);
|
||||||
this->set_has_state(true);
|
this->set_has_state(true);
|
||||||
this->active_index_ = index;
|
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);
|
ESP_LOGV(TAG, "'%s' >> %s (%zu)", this->get_name().c_str(), option, index);
|
||||||
this->state_callback_.call(index);
|
this->state_callback_.call(index);
|
||||||
#if defined(USE_SELECT) && defined(USE_CONTROLLER_REGISTRY)
|
#if defined(USE_SELECT) && defined(USE_CONTROLLER_REGISTRY)
|
||||||
|
|||||||
@@ -30,15 +30,8 @@ class Select : public EntityBase {
|
|||||||
public:
|
public:
|
||||||
SelectTraits traits;
|
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;
|
||||||
~Select() = default;
|
~Select() = default;
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
|
|
||||||
void publish_state(const std::string &state);
|
void publish_state(const std::string &state);
|
||||||
void publish_state(const char *state);
|
void publish_state(const char *state);
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ select:
|
|||||||
set_action:
|
set_action:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
ESP_LOGI("test", "Device A Mode set to %s", x.c_str());
|
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
|
- platform: template
|
||||||
name: Mode
|
name: Mode
|
||||||
@@ -124,7 +124,7 @@ select:
|
|||||||
set_action:
|
set_action:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
ESP_LOGI("test", "Device B Mode set to %s", x.c_str());
|
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
|
- platform: template
|
||||||
name: Mode
|
name: Mode
|
||||||
@@ -138,7 +138,7 @@ select:
|
|||||||
set_action:
|
set_action:
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
ESP_LOGI("test", "Main Mode set to %s", x.c_str());
|
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 to trigger preference logging test
|
||||||
button:
|
button:
|
||||||
@@ -153,9 +153,9 @@ button:
|
|||||||
ESP_LOGI("test", "Device A Setpoint: %.1f", id(setpoint_device_a).state);
|
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", "Device B Setpoint: %.1f", id(setpoint_device_b).state);
|
||||||
ESP_LOGI("test", "Main Setpoint: %.1f", id(setpoint_main).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 A Mode: %s", id(mode_device_a).current_option().c_str());
|
||||||
ESP_LOGI("test", "Device B Mode: %s", id(mode_device_b).state.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).state.c_str());
|
ESP_LOGI("test", "Main Mode: %s", id(mode_main).current_option().c_str());
|
||||||
// Log preference hashes for entities that actually store preferences
|
// 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 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());
|
ESP_LOGI("test", "Device B Switch Pref Hash: %u", id(light_device_b).get_preference_hash());
|
||||||
|
|||||||
Reference in New Issue
Block a user