mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	Added missing PM_1_0 and PM_10_0 for PMS5003T and PMS5003ST (#4560)
* Added missing PM_1_0 and PM_10_0 for PMS5003T
Added missing PM_1_0 and PM_10_0 for PMS5003T
* Revert "Added missing PM_1_0 and PM_10_0 for PMS5003T"
This reverts commit 86084f7c61.
* Added tests for PMS5003T
* Added missing PM_1_0 and PM_10_0 for PMS5003T PMS5003ST
* Added missing PM_1_0 and PM_10_0 for PMS5003T
* lint: Trailing whitespace fixed
* tab character removed
* Clang format suggested edit
			
			
This commit is contained in:
		| @@ -264,13 +264,52 @@ void PMSX003Component::parse_data_() { | |||||||
|       break; |       break; | ||||||
|     } |     } | ||||||
|     case PMSX003_TYPE_5003T: { |     case PMSX003_TYPE_5003T: { | ||||||
|  |       uint16_t pm_1_0_std_concentration = this->get_16_bit_uint_(4); | ||||||
|  |       uint16_t pm_2_5_std_concentration = this->get_16_bit_uint_(6); | ||||||
|  |       uint16_t pm_10_0_std_concentration = this->get_16_bit_uint_(8); | ||||||
|  |  | ||||||
|  |       uint16_t pm_1_0_concentration = this->get_16_bit_uint_(10); | ||||||
|       uint16_t pm_2_5_concentration = this->get_16_bit_uint_(12); |       uint16_t pm_2_5_concentration = this->get_16_bit_uint_(12); | ||||||
|  |       uint16_t pm_10_0_concentration = this->get_16_bit_uint_(14); | ||||||
|  |  | ||||||
|  |       uint16_t pm_particles_03um = this->get_16_bit_uint_(16); | ||||||
|  |       uint16_t pm_particles_05um = this->get_16_bit_uint_(18); | ||||||
|  |       uint16_t pm_particles_10um = this->get_16_bit_uint_(20); | ||||||
|  |       uint16_t pm_particles_25um = this->get_16_bit_uint_(22); | ||||||
|  |       // Note the pm particles 50um & 100um are not returned, | ||||||
|  |       // as PMS5003T uses those data values for temperature and humidity. | ||||||
|  |  | ||||||
|       float temperature = this->get_16_bit_uint_(24) / 10.0f; |       float temperature = this->get_16_bit_uint_(24) / 10.0f; | ||||||
|       float humidity = this->get_16_bit_uint_(26) / 10.0f; |       float humidity = this->get_16_bit_uint_(26) / 10.0f; | ||||||
|       ESP_LOGD(TAG, "Got PM2.5 Concentration: %u µg/m^3, Temperature: %.1f°C, Humidity: %.1f%%", pm_2_5_concentration, |  | ||||||
|                temperature, humidity); |       ESP_LOGD(TAG, | ||||||
|  |                "Got PM1.0 Concentration: %u µg/m^3, PM2.5 Concentration %u µg/m^3, PM10.0 Concentration: %u µg/m^3, " | ||||||
|  |                "Temperature: %.1f°C, Humidity: %.1f%%", | ||||||
|  |                pm_1_0_concentration, pm_2_5_concentration, pm_10_0_concentration, temperature, humidity); | ||||||
|  |  | ||||||
|  |       if (this->pm_1_0_std_sensor_ != nullptr) | ||||||
|  |         this->pm_1_0_std_sensor_->publish_state(pm_1_0_std_concentration); | ||||||
|  |       if (this->pm_2_5_std_sensor_ != nullptr) | ||||||
|  |         this->pm_2_5_std_sensor_->publish_state(pm_2_5_std_concentration); | ||||||
|  |       if (this->pm_10_0_std_sensor_ != nullptr) | ||||||
|  |         this->pm_10_0_std_sensor_->publish_state(pm_10_0_std_concentration); | ||||||
|  |  | ||||||
|  |       if (this->pm_1_0_sensor_ != nullptr) | ||||||
|  |         this->pm_1_0_sensor_->publish_state(pm_1_0_concentration); | ||||||
|       if (this->pm_2_5_sensor_ != nullptr) |       if (this->pm_2_5_sensor_ != nullptr) | ||||||
|         this->pm_2_5_sensor_->publish_state(pm_2_5_concentration); |         this->pm_2_5_sensor_->publish_state(pm_2_5_concentration); | ||||||
|  |       if (this->pm_10_0_sensor_ != nullptr) | ||||||
|  |         this->pm_10_0_sensor_->publish_state(pm_10_0_concentration); | ||||||
|  |  | ||||||
|  |       if (this->pm_particles_03um_sensor_ != nullptr) | ||||||
|  |         this->pm_particles_03um_sensor_->publish_state(pm_particles_03um); | ||||||
|  |       if (this->pm_particles_05um_sensor_ != nullptr) | ||||||
|  |         this->pm_particles_05um_sensor_->publish_state(pm_particles_05um); | ||||||
|  |       if (this->pm_particles_10um_sensor_ != nullptr) | ||||||
|  |         this->pm_particles_10um_sensor_->publish_state(pm_particles_10um); | ||||||
|  |       if (this->pm_particles_25um_sensor_ != nullptr) | ||||||
|  |         this->pm_particles_25um_sensor_->publish_state(pm_particles_25um); | ||||||
|  |  | ||||||
|       if (this->temperature_sensor_ != nullptr) |       if (this->temperature_sensor_ != nullptr) | ||||||
|         this->temperature_sensor_->publish_state(temperature); |         this->temperature_sensor_->publish_state(temperature); | ||||||
|       if (this->humidity_sensor_ != nullptr) |       if (this->humidity_sensor_ != nullptr) | ||||||
|   | |||||||
| @@ -55,9 +55,9 @@ PMSX003_TYPES = { | |||||||
| } | } | ||||||
|  |  | ||||||
| SENSORS_TO_TYPE = { | SENSORS_TO_TYPE = { | ||||||
|     CONF_PM_1_0: [TYPE_PMSX003, TYPE_PMS5003ST, TYPE_PMS5003S], |     CONF_PM_1_0: [TYPE_PMSX003, TYPE_PMS5003T, TYPE_PMS5003ST, TYPE_PMS5003S], | ||||||
|     CONF_PM_2_5: [TYPE_PMSX003, TYPE_PMS5003T, TYPE_PMS5003ST, TYPE_PMS5003S], |     CONF_PM_2_5: [TYPE_PMSX003, TYPE_PMS5003T, TYPE_PMS5003ST, TYPE_PMS5003S], | ||||||
|     CONF_PM_10_0: [TYPE_PMSX003, TYPE_PMS5003ST, TYPE_PMS5003S], |     CONF_PM_10_0: [TYPE_PMSX003, TYPE_PMS5003T, TYPE_PMS5003ST, TYPE_PMS5003S], | ||||||
|     CONF_TEMPERATURE: [TYPE_PMS5003T, TYPE_PMS5003ST], |     CONF_TEMPERATURE: [TYPE_PMS5003T, TYPE_PMS5003ST], | ||||||
|     CONF_HUMIDITY: [TYPE_PMS5003T, TYPE_PMS5003ST], |     CONF_HUMIDITY: [TYPE_PMS5003T, TYPE_PMS5003ST], | ||||||
|     CONF_FORMALDEHYDE: [TYPE_PMS5003ST, TYPE_PMS5003S], |     CONF_FORMALDEHYDE: [TYPE_PMS5003ST, TYPE_PMS5003S], | ||||||
|   | |||||||
| @@ -630,8 +630,26 @@ sensor: | |||||||
|   - platform: pmsx003 |   - platform: pmsx003 | ||||||
|     uart_id: uart5 |     uart_id: uart5 | ||||||
|     type: PMS5003T |     type: PMS5003T | ||||||
|  |     pm_1_0: | ||||||
|  |       name: PM 1.0 Concentration | ||||||
|     pm_2_5: |     pm_2_5: | ||||||
|       name: PM 2.5 Concentration |       name: PM 2.5 Concentration | ||||||
|  |     pm_10_0: | ||||||
|  |       name: PM 10.0 Concentration | ||||||
|  |     pm_1_0_std: | ||||||
|  |       name: PM 1.0 Standard Atmospher Concentration | ||||||
|  |     pm_2_5_std: | ||||||
|  |       name: PM 2.5 Standard Atmospher Concentration | ||||||
|  |     pm_10_0_std: | ||||||
|  |       name: PM 10.0 Standard Atmospher Concentration | ||||||
|  |     pm_0_3um: | ||||||
|  |       name: Particulate Count >0.3um | ||||||
|  |     pm_0_5um: | ||||||
|  |       name: Particulate Count >0.5um | ||||||
|  |     pm_1_0um: | ||||||
|  |       name: Particulate Count >1.0um | ||||||
|  |     pm_2_5um: | ||||||
|  |       name: Particulate Count >2.5um | ||||||
|     temperature: |     temperature: | ||||||
|       name: PMS Temperature |       name: PMS Temperature | ||||||
|     humidity: |     humidity: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user