check if the select is configured

This commit is contained in:
Samuel Sieb 2025-04-11 20:48:24 -07:00 committed by GitHub
parent 865157afba
commit b6dce21154
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -140,14 +140,16 @@ void LD2420Component::setup() {
if (get_firmware_int_(ld2420_firmware_ver_) < CALIBRATE_VERSION_MIN) { if (get_firmware_int_(ld2420_firmware_ver_) < CALIBRATE_VERSION_MIN) {
this->set_operating_mode(OP_SIMPLE_MODE_STRING); this->set_operating_mode(OP_SIMPLE_MODE_STRING);
#ifdef USE_SELECT #ifdef USE_SELECT
this->operating_selector_->publish_state(OP_SIMPLE_MODE_STRING); if (this->operating_selector_ != nullptr)
this->operating_selector_->publish_state(OP_SIMPLE_MODE_STRING);
#endif #endif
this->set_mode_(CMD_SYSTEM_MODE_SIMPLE); this->set_mode_(CMD_SYSTEM_MODE_SIMPLE);
ESP_LOGW(TAG, "LD2420 Frimware Version %s and older are only supported in Simple Mode", ld2420_firmware_ver_); ESP_LOGW(TAG, "LD2420 Frimware Version %s and older are only supported in Simple Mode", ld2420_firmware_ver_);
} else { } else {
this->set_mode_(CMD_SYSTEM_MODE_ENERGY); this->set_mode_(CMD_SYSTEM_MODE_ENERGY);
#ifdef USE_SELECT #ifdef USE_SELECT
this->operating_selector_->publish_state(OP_NORMAL_MODE_STRING); if (this->operating_selector_ != nullptr)
this->operating_selector_->publish_state(OP_NORMAL_MODE_STRING);
#endif #endif
} }
#ifdef USE_NUMBER #ifdef USE_NUMBER
@ -300,7 +302,8 @@ void LD2420Component::set_operating_mode(const std::string &state) {
this->current_operating_mode = OP_MODE_TO_UINT.at(state); this->current_operating_mode = OP_MODE_TO_UINT.at(state);
// Entering Auto Calibrate we need to clear the privoiuos data collection // Entering Auto Calibrate we need to clear the privoiuos data collection
#ifdef USE_SELECT #ifdef USE_SELECT
this->operating_selector_->publish_state(state); if (this->operating_selector_ != nullptr)
this->operating_selector_->publish_state(state);
#endif #endif
if (current_operating_mode == OP_CALIBRATE_MODE) { if (current_operating_mode == OP_CALIBRATE_MODE) {
this->set_calibration_(true); this->set_calibration_(true);
@ -321,7 +324,8 @@ void LD2420Component::set_operating_mode(const std::string &state) {
} else { } else {
this->current_operating_mode = OP_SIMPLE_MODE; this->current_operating_mode = OP_SIMPLE_MODE;
#ifdef USE_SELECT #ifdef USE_SELECT
this->operating_selector_->publish_state(OP_SIMPLE_MODE_STRING); if (this->operating_selector_ != nullptr)
this->operating_selector_->publish_state(OP_SIMPLE_MODE_STRING);
#endif #endif
} }
} }