From b2d516c70a5b2357cf0c7c7cf394269c631e6653 Mon Sep 17 00:00:00 2001 From: Christian Taedcke Date: Mon, 27 Sep 2021 21:53:05 +0200 Subject: [PATCH] ccs811: Skip reading data if it is not available (#2404) On bootup the ccs811 reports that no data is available. No error flag is set in that case. The current implementation ignores this, reads and publishes the invalid data, which is 0xFDFD for both tvoc and co2 in my case. This commit fixes this and does not read and publish invalid data. --- esphome/components/ccs811/ccs811.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/esphome/components/ccs811/ccs811.cpp b/esphome/components/ccs811/ccs811.cpp index 6bdb4739cf..11a66f5100 100644 --- a/esphome/components/ccs811/ccs811.cpp +++ b/esphome/components/ccs811/ccs811.cpp @@ -86,8 +86,11 @@ void CCS811Component::setup() { } } void CCS811Component::update() { - if (!this->status_has_data_()) + if (!this->status_has_data_()) { + ESP_LOGD(TAG, "Status indicates no data ready!"); this->status_set_warning(); + return; + } // page 12 - alg result data auto alg_data = this->read_bytes<4>(0x02);