Skip to content

Commit 6e94f1b

Browse files
committed
Add sensor not initialized warning
Let user know in dump_config() when the sensor is not initialized. Default some values to "Unknown"
1 parent 435c5bd commit 6e94f1b

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

components/sen5x/sen5x.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,14 +449,17 @@ void SEN5XComponent::internal_setup_(uint8_t state) {
449449
this->set_timeout(20, [this]() { this->internal_setup_(16); });
450450
break;
451451
case 16:
452-
initialized_ = true;
452+
this->initialized_ = true;
453453
ESP_LOGD(TAG, "Sensor initialized");
454454
break;
455455
}
456456
}
457457

458458
void SEN5XComponent::dump_config() {
459459
ESP_LOGCONFIG(TAG, "sen5x:");
460+
if (!this->initialized_) {
461+
ESP_LOGCONFIG(TAG, " Initialization is not complete, some values may not be filled in");
462+
}
460463
if (this->is_failed()) {
461464
switch (this->error_code_) {
462465
case COMMUNICATION_FAILED:
@@ -534,7 +537,7 @@ void SEN5XComponent::dump_config() {
534537
}
535538

536539
void SEN5XComponent::update() {
537-
if (!initialized_) {
540+
if (!this->initialized_) {
538541
return;
539542
}
540543

components/sen5x/sen5x.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ class SEN5XComponent : public PollingComponent, public sensirion_common::Sensiri
137137
sensor::Sensor *nox_sensor_{nullptr};
138138
sensor::Sensor *co2_sensor_{nullptr};
139139

140-
std::string product_name_;
141-
std::string serial_number_;
140+
std::string product_name_ = "Unknown";
141+
std::string serial_number_ = "Unknown";
142142
uint8_t firmware_major_{0xFF};
143143
uint8_t firmware_minor_{0xFF};
144144
Sen5xBaselines voc_baselines_storage_;

0 commit comments

Comments
 (0)