This commit is contained in:
2024-12-07 18:11:36 +01:00
parent b59ee51d27
commit ad6b2ff830
2 changed files with 22 additions and 21 deletions

View File

@@ -24,7 +24,7 @@ namespace esphome
void KQM6600TAComponent::update()
{
uint8_t response[KQM6600TA_RESPONSE_LENGTH];
this->read_array(&response, KQM6600TA_RESPONSE_LENGTH);
this->read_array(response, KQM6600TA_RESPONSE_LENGTH);
if (response[0] != 0x5F)
{
ESP_LOGW(TAG, "Invalid preamble from KQM6600TA!");
@@ -45,7 +45,6 @@ namespace esphome
const uint32_t formaldehyde = ((uint16_t(response[3]) << 8) | response[4]) * 10;
const uint16_t co2 = ((uint16_t(response[5]) << 8) | response[6]) * 10;
ESP_LOGD(TAG, "KQM6600TA Received VOC=%f Formaldehyde=%dmg/m³ CO₂=%dppm", voc, formaldehyde, co2);
if (this->voc_sensor_ != nullptr)
this->voc_sensor_->publish_state(voc);

View File

@@ -5,10 +5,13 @@
#include "esphome/components/sensor/sensor.h"
#include "esphome/components/uart/uart.h"
namespace esphome {
namespace kqm6600ta {
namespace esphome
{
namespace kqm6600ta
{
class KQM6600TAComponent : public PollingComponent, public uart::UARTDevice {
class KQM6600TAComponent : public PollingComponent, public uart::UARTDevice
{
public:
float get_setup_priority() const override;
@@ -21,7 +24,6 @@ class KQM6600TAComponent : public PollingComponent, public uart::UARTDevice {
void set_co2_sensor(sensor::Sensor *co2_sensor) { co2_sensor_ = co2_sensor; }
protected:
sensor::Sensor *formaldehyde_sensor_{nullptr};
sensor::Sensor *voc_sensor_{nullptr};
sensor::Sensor *co2_sensor_{nullptr};