ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
airthings_wave_plus.cpp
Go to the documentation of this file.
2
3#ifdef USE_ESP32
4
6
7ESPHOME_LOG_TAG(TAG, "airthings_wave_plus");
8
9void AirthingsWavePlus::read_sensors(uint8_t *raw_value, uint16_t value_len) {
10 auto *value = (WavePlusReadings *) raw_value;
11
12 if (sizeof(WavePlusReadings) <= value_len) {
13 ESP_LOGD(TAG, "version = %d", value->version);
14
15 if (value->version == 1) {
16 PUBLISH_STATE(this->humidity_sensor_, value->humidity / 2.0f);
17
18 if ((this->radon_sensor_ != nullptr) && this->is_valid_radon_value_(value->radon)) {
19 this->radon_sensor_->publish_state(value->radon);
20 }
21
22 if ((this->radon_long_term_sensor_ != nullptr) && this->is_valid_radon_value_(value->radon_lt)) {
23 this->radon_long_term_sensor_->publish_state(value->radon_lt);
24 }
25
26 PUBLISH_STATE(this->temperature_sensor_, value->temperature / 100.0f);
27
28 PUBLISH_STATE(this->pressure_sensor_, value->pressure / 50.0f);
29
30 if ((this->co2_sensor_ != nullptr) && this->is_valid_co2_value_(value->co2)) {
31 this->co2_sensor_->publish_state(value->co2);
32 }
33
34 if ((this->tvoc_sensor_ != nullptr) && this->is_valid_voc_value_(value->voc)) {
35 this->tvoc_sensor_->publish_state(value->voc);
36 }
37
38 PUBLISH_STATE(this->illuminance_sensor_, value->ambientLight);
39 } else {
40 ESP_LOGE(TAG, "Invalid payload version (%d != 1, newer version or not a Wave Plus?)", value->version);
41 }
42 }
43
44 this->response_received_();
45}
46
47bool AirthingsWavePlus::is_valid_radon_value_(uint16_t radon) { return radon <= 16383; }
48
49bool AirthingsWavePlus::is_valid_co2_value_(uint16_t co2) { return co2 <= 16383; }
50
51void AirthingsWavePlus::dump_config() {
52 // these really don't belong here, but there doesn't seem to be a
53 // practical way to have the base class use LOG_SENSOR and include
54 // the TAG from this component
55 LOG_SENSOR(" ", "Humidity", this->humidity_sensor_);
56 LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
57 LOG_SENSOR(" ", "Pressure", this->pressure_sensor_);
58 LOG_SENSOR(" ", "TVOC", this->tvoc_sensor_);
59 LOG_SENSOR(" ", "Battery Voltage", this->battery_voltage_);
60
61 LOG_SENSOR(" ", "Radon", this->radon_sensor_);
62 LOG_SENSOR(" ", "Radon Long Term", this->radon_long_term_sensor_);
63 LOG_SENSOR(" ", "CO2", this->co2_sensor_);
64 LOG_SENSOR(" ", "Illuminance", this->illuminance_sensor_);
65}
66
68 const char *service_uuid;
69 const char *characteristic_uuid;
70 const char *access_control_point_characteristic_uuid;
71
72 // Change UUIDs for Wave Radon Gen2
73 switch (this->wave_device_type_) {
75 service_uuid = SERVICE_UUID_WAVE_RADON_GEN2;
76 characteristic_uuid = CHARACTERISTIC_UUID_WAVE_RADON_GEN2;
77 access_control_point_characteristic_uuid = ACCESS_CONTROL_POINT_CHARACTERISTIC_UUID_WAVE_RADON_GEN2;
78 break;
79 default:
80 // Wave Plus
81 service_uuid = SERVICE_UUID;
82 characteristic_uuid = CHARACTERISTIC_UUID;
83 access_control_point_characteristic_uuid = ACCESS_CONTROL_POINT_CHARACTERISTIC_UUID;
84 }
85
86 this->service_uuid_ = espbt::ESPBTUUID::from_raw(service_uuid);
87 this->sensors_data_characteristic_uuid_ = espbt::ESPBTUUID::from_raw(characteristic_uuid);
89 espbt::ESPBTUUID::from_raw(access_control_point_characteristic_uuid);
90}
91
92} // namespace esphome::airthings_wave_plus
93
94#endif // USE_ESP32
virtual void setup()
Where the component's initialization should happen.
Definition component.cpp:84
void read_sensors(uint8_t *raw_value, uint16_t value_len) override
ESPHOME_LOG_TAG(TAG, "airthings_wave_plus")
uint32_t value
Definition hal.cpp:41