ESPHome 2026.5.0b1
Loading...
Searching...
No Matches
airthings_wave_mini.cpp
Go to the documentation of this file.
2
3#ifdef USE_ESP32
4
6
7static const char *const TAG = "airthings_wave_mini";
8
9void AirthingsWaveMini::read_sensors(uint8_t *raw_value, uint16_t value_len) {
10 auto *value = (WaveMiniReadings *) raw_value;
11
12 if (sizeof(WaveMiniReadings) <= value_len) {
13 if (this->humidity_sensor_ != nullptr) {
14 this->humidity_sensor_->publish_state(value->humidity / 100.0f);
15 }
16
17 if (this->pressure_sensor_ != nullptr) {
18 this->pressure_sensor_->publish_state(value->pressure / 50.0f);
19 }
20
21 if (this->temperature_sensor_ != nullptr) {
22 this->temperature_sensor_->publish_state(value->temperature / 100.0f - 273.15f);
23 }
24
25 if ((this->tvoc_sensor_ != nullptr) && this->is_valid_voc_value_(value->voc)) {
26 this->tvoc_sensor_->publish_state(value->voc);
27 }
28 }
29
30 this->response_received_();
31}
32
34 // these really don't belong here, but there doesn't seem to be a
35 // practical way to have the base class use LOG_SENSOR and include
36 // the TAG from this component
37 LOG_SENSOR(" ", "Humidity", this->humidity_sensor_);
38 LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
39 LOG_SENSOR(" ", "Pressure", this->pressure_sensor_);
40 LOG_SENSOR(" ", "TVOC", this->tvoc_sensor_);
41 LOG_SENSOR(" ", "Battery Voltage", this->battery_voltage_);
42}
43
45 this->service_uuid_ = espbt::ESPBTUUID::from_raw(SERVICE_UUID);
46 this->sensors_data_characteristic_uuid_ = espbt::ESPBTUUID::from_raw(CHARACTERISTIC_UUID);
48 espbt::ESPBTUUID::from_raw(ACCESS_CONTROL_POINT_CHARACTERISTIC_UUID);
49}
50
51} // namespace esphome::airthings_wave_mini
52
53#endif // USE_ESP32
void read_sensors(uint8_t *raw_value, uint16_t value_len) override
void publish_state(float state)
Publish a new state to the front-end.
Definition sensor.cpp:68