7static 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];
58 switch (message->
type) {
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?");
104 ESP_LOGCONFIG(TAG,
"ZyAuraSensor:");
107 LOG_UPDATE_INTERVAL(
this);
119 if (co2_result && temperature_result && humidity_result) {
void status_set_warning(const char *message="unspecified")
void status_clear_warning()
void attach_interrupt(void(*func)(T *), T *arg, gpio::InterruptType type) const
virtual ISRInternalGPIOPin to_isr() const =0
Base-class for all sensors.
void publish_state(float state)
Publish a new state to the front-end.
uint8_t buffer_[ZA_MSG_LEN]
bool decode(uint32_t ms, bool data)
void set_data_(ZaMessage *message)
ZaDataProcessor processor_
ISRInternalGPIOPin pin_data_
void setup(InternalGPIOPin *pin_clock, InternalGPIOPin *pin_data)
static void interrupt(ZaSensorStore *arg)
ISRInternalGPIOPin pin_clock_
sensor::Sensor * temperature_sensor_
InternalGPIOPin * pin_clock_
sensor::Sensor * humidity_sensor_
InternalGPIOPin * pin_data_
void dump_config() override
bool publish_state_(ZaDataType data_type, sensor::Sensor *sensor, uint16_t *data_value)
sensor::Sensor * co2_sensor_
Providing packet encoding functions for exchanging data with a remote host.
uint32_t IRAM_ATTR HOT millis()