44#include " esphome/core/log.h"
55#include < cinttypes>
66
7+ #define ESP_LOG_MSG_CO2_CAL_FAIL = " Perform Forced CO₂ Calibration failed" ;
8+ #define ESP_LOG_MSG_ACT_SHT_HEATER_FAIL = " Activate SHT Heater failed" ;
9+ #define ESP_LOG_MSG_FAN_CLEAN_FAIL = " Fan Cleaning failed" ;
10+
711namespace esphome {
812namespace sen5x {
913
1014static const char *const TAG = " sen5x" ;
11- static const char *const ESP_LOG_MSG_CO2_CAL_FAIL = " Perform Forced CO₂ Calibration failed" ;
12- static const char *const ESP_LOG_MSG_ACT_SHT_HEATER_FAIL = " Activate SHT Heater failed" ;
13- static const char *const ESP_LOG_MSG_FAN_CLEAN_FAIL = " Fan Cleaning failed" ;
1415
1516static const uint16_t SEN5X_CMD_READ_MEASUREMENT = 0x03C4 ;
1617static const uint16_t SEN60_CMD_READ_MEASUREMENT = 0xEC05 ;
@@ -79,21 +80,21 @@ static const char *model_to_str(Sen5xType model) {
7980 }
8081}
8182static const Sen5xType str_to_model (const char *product_name) {
82- if (product_name == " SEN50" ) {
83+ if (strcmp ( product_name, " SEN50" ) == 0 ) {
8384 return SEN50;
84- } else if (product_name == " SEN54" ) {
85+ } else if (strcmp ( product_name, " SEN54" ) == 0 ) {
8586 return SEN54;
86- } else if (product_name == " SEN55" ) {
87+ } else if (strcmp ( product_name, " SEN55" ) == 0 ) {
8788 return SEN55;
88- } else if (product_name == " SEN60" ) {
89+ } else if (strcmp ( product_name, " SEN60" ) == 0 ) {
8990 return SEN60;
90- } else if (product_name == " SEN63C" ) {
91+ } else if (strcmp ( product_name, " SEN63C" ) == 0 ) {
9192 return SEN63C;
92- } else if (product_name == " SEN65" ) {
93+ } else if (strcmp ( product_name, " SEN65" ) == 0 ) {
9394 return SEN65;
94- } else if (product_name == " SEN66" ) {
95+ } else if (strcmp ( product_name, " SEN66" ) == 0 ) {
9596 return SEN66;
96- } else if (product_name == " SEN68" ) {
97+ } else if (strcmp ( product_name, " SEN68" ) == 0 ) {
9798 return SEN68;
9899 } else {
99100 return UNKNOWN_MODEL;
@@ -688,7 +689,7 @@ void SEN5XComponent::update() {
688689 if (this ->model_ .value () == SEN66) {
689690 measurement = measurements[8 ];
690691 }
691- ESP_LOGVV (TAG, " co2 = 0x%.4x" , co2 );
692+ ESP_LOGVV (TAG, " co2 = 0x%.4x" , measurement );
692693 float co2 = measurement == UINT16_MAX ? NAN : measurement / 1 .0f ;
693694 if (this ->co2_sensor_ != nullptr ) {
694695 this ->co2_sensor_ ->publish_state (co2);
@@ -979,4 +980,4 @@ bool SEN5XComponent::perform_forced_co2_calibration(uint16_t co2) {
979980 }
980981}
981982} // namespace sen5x
982- } // namespace esphome
983+ } // namespace esphome
0 commit comments