7 static const char *
const TAG =
"zyaura";
11 if ((ms - this->
prev_ms_) > ZA_MAX_MS) {
27 if (checksum != this->buffer_[ZA_BYTE_SUM] || this->buffer_[ZA_BYTE_END] != ZA_MSG_DELIMETER) {
32 this->
message->
value = this->buffer_[ZA_BYTE_HIGH] << 8 | this->buffer_[ZA_BYTE_LOW];
43 this->pin_clock_ = pin_clock->
to_isr();
44 this->pin_data_ = pin_data->
to_isr();
58 switch (message->
type) {
60 this->humidity = message->
value;
66 this->co2 = message->
value;
73 if (sensor ==
nullptr) {
80 value = (*data_value > 10000) ? NAN : (*data_value / 100.0f);
83 value = (*data_value > 5970) ? NAN : (*data_value / 16.0f - 273.15f);
86 value = (*data_value > 10000) ? NAN : *data_value;
93 if (std::isnan(value)) {
94 ESP_LOGW(TAG,
"Sensor reported invalid data. Is the update interval too small?");
95 this->status_set_warning();
104 ESP_LOGCONFIG(TAG,
"ZyAuraSensor:");
105 LOG_PIN(
" Pin Clock: ", this->pin_clock_);
106 LOG_PIN(
" Pin Data: ", this->pin_data_);
107 LOG_UPDATE_INTERVAL(
this);
109 LOG_SENSOR(
" ",
"CO2", this->co2_sensor_);
110 LOG_SENSOR(
" ",
"Temperature", this->temperature_sensor_);
111 LOG_SENSOR(
" ",
"Humidity", this->humidity_sensor_);
115 bool co2_result = this->publish_state_(
CO2, this->co2_sensor_, &this->store_.co2);
116 bool temperature_result = this->publish_state_(
TEMPERATURE, this->temperature_sensor_, &this->store_.temperature);
117 bool humidity_result = this->publish_state_(
HUMIDITY, this->humidity_sensor_, &this->store_.humidity);
119 if (co2_result && temperature_result && humidity_result) {
120 this->status_clear_warning();
void set_data_(ZaMessage *message)
uint32_t IRAM_ATTR HOT millis()
static void interrupt(ZaSensorStore *arg)
void setup(InternalGPIOPin *pin_clock, InternalGPIOPin *pin_data)
void publish_state(float state)
Publish a new state to the front-end.
ISRInternalGPIOPin pin_data_
ZaDataProcessor processor_
bool publish_state_(ZaDataType data_type, sensor::Sensor *sensor, uint16_t *data_value)
void dump_config() override
virtual ISRInternalGPIOPin to_isr() const =0
uint8_t buffer_[ZA_MSG_LEN]
Implementation of SPI Controller mode.
Base-class for all sensors.
void attach_interrupt(void(*func)(T *), T *arg, gpio::InterruptType type) const
esphome::sensor::Sensor * sensor
bool decode(uint32_t ms, bool data)