ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
ecocomfort2_hub.h
Go to the documentation of this file.
1#pragma once
2
4#ifdef USE_ESP32
5
9#include "ecocomfort2_child.h"
10
11#ifdef USE_SENSOR
13#endif
14#ifdef USE_BINARY_SENSOR
16#endif
17#ifdef USE_TEXT_SENSOR
19#endif
20#ifdef USE_TIME
22#endif
23
24namespace esphome::ecocomfort2 {
25
27
28// C_OPER byte 0: operating mode
29static constexpr uint8_t OPER_OFF = 0x00;
30static constexpr uint8_t OPER_IN = 0x01;
31static constexpr uint8_t OPER_OUT = 0x02;
32static constexpr uint8_t OPER_IN_OUT = 0x03;
33static constexpr uint8_t OPER_SENSOR_OR_AUTO = 0x04;
34
35// Speed byte: speed in the low nibble, flags in the high nibble.
36// C_OPER carries FLAG_AUTO; the unit reports FLAG_BOOST in byte 1 of C_STATE.
37static constexpr uint8_t SPEED_OFF = 0x00;
38static constexpr uint8_t SPEED_SLEEP = 0x01;
39static constexpr uint8_t SPEED_VEL1 = 0x02;
40static constexpr uint8_t SPEED_VEL2 = 0x03;
41static constexpr uint8_t SPEED_VEL3 = 0x04;
42static constexpr uint8_t SPEED_MASK = 0x0F;
43static constexpr uint8_t FLAG_AUTO = 0x10;
44static constexpr uint8_t FLAG_BOOST = 0x40;
45
48 public:
49 void setup() override;
50 void update() override;
51 void dump_config() override;
52 float get_setup_priority() const override { return setup_priority::BLUETOOTH; }
53
54 void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
55 esp_ble_gattc_cb_param_t *param) override;
56 void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) override;
57
58#ifdef ECOCOMFORT2_CHILD_COUNT
60#endif
61#ifdef USE_SENSOR
66#endif
67#ifdef USE_BINARY_SENSOR
70#endif
71#ifdef USE_TEXT_SENSOR
73#endif
74#ifdef USE_TIME
76 void set_time(time::RealTimeClock *time) { this->time_ = time; }
77#endif
78
80 bool is_ready() const { return this->node_state == espbt::ClientState::ESTABLISHED && this->parent_->is_paired(); }
81
83 void write_oper(uint8_t mode, uint8_t speed);
84
86 uint8_t get_mode() const { return this->mode_; }
87 uint8_t get_speed() const { return this->speed_; }
88
89 protected:
90 static constexpr uint32_t AUTH_TIMEOUT_ID = 0;
91 static constexpr uint32_t READBACK_TIMEOUT_ID = 1;
92 static constexpr uint32_t AUTH_TIMEOUT_MS = 10000;
93 static constexpr uint32_t READBACK_DELAY_MS = 300;
94
95 void on_paired_();
96 void set_connected_(bool connected);
97 void publish_unknown_();
98 void read_char_(uint16_t handle);
99 bool read_ok_(const esp_ble_gattc_cb_param_t *param);
100 void on_oper_(const uint8_t *data, uint16_t len);
101 void on_state_(const uint8_t *data, uint16_t len);
102 void on_info_(const uint8_t *data, uint16_t len);
103#ifdef USE_TIME
104 void sync_clock_();
105#endif
106
107#ifdef ECOCOMFORT2_CHILD_COUNT
109#endif
110#ifdef USE_SENSOR
115#endif
116#ifdef USE_BINARY_SENSOR
119#endif
120#ifdef USE_TEXT_SENSOR
122#endif
123#ifdef USE_TIME
125#endif
126 uint16_t char_handle_oper_{0};
128 uint16_t char_handle_info_{0};
130 uint8_t mode_{OPER_OFF};
131 uint8_t speed_{SPEED_OFF};
132};
133
134} // namespace esphome::ecocomfort2
135
136#endif // USE_ESP32
BedjetMode mode
BedJet operating mode.
This class simplifies creating components that periodically check a state.
Definition component.h:514
Minimal static vector - saves memory by avoiding std::vector overhead.
Definition helpers.h:286
Base class for all binary_sensor-type classes.
Hub component for Ecocomfort 2.0 VMC via BLE.
float get_setup_priority() const override
binary_sensor::BinarySensor * boost_binary_sensor_
static constexpr uint32_t READBACK_DELAY_MS
uint8_t get_mode() const
Raw C_OPER values from the last readback.
void set_humidity_sensor(sensor::Sensor *s)
static constexpr uint32_t AUTH_TIMEOUT_ID
bool is_ready() const
True once the link is established and paired.
void on_state_(const uint8_t *data, uint16_t len)
text_sensor::TextSensor * firmware_text_sensor_
void set_direction_sensor(sensor::Sensor *s)
void on_info_(const uint8_t *data, uint16_t len)
void set_firmware_text_sensor(text_sensor::TextSensor *s)
StaticVector< Ecocomfort2Client *, ECOCOMFORT2_CHILD_COUNT > children_
binary_sensor::BinarySensor * connected_binary_sensor_
static constexpr uint32_t READBACK_TIMEOUT_ID
void set_connected_binary_sensor(binary_sensor::BinarySensor *s)
void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) override
void set_voc_sensor(sensor::Sensor *s)
void register_child(Ecocomfort2Client *obj)
bool read_ok_(const esp_ble_gattc_cb_param_t *param)
void set_boost_binary_sensor(binary_sensor::BinarySensor *s)
void set_time(time::RealTimeClock *time)
Keeps the unit's clock in step with this time source while connected.
void write_oper(uint8_t mode, uint8_t speed)
Write C_OPER (mode byte, speed/flags byte) and read it back shortly after.
void set_temperature_sensor(sensor::Sensor *s)
void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) override
void on_oper_(const uint8_t *data, uint16_t len)
static constexpr uint32_t AUTH_TIMEOUT_MS
Base-class for all sensors.
Definition sensor.h:47
The RealTimeClock class exposes common timekeeping functions via the device's local real-time clock.
constexpr float BLUETOOTH
Definition component.h:48
const void size_t len
Definition hal.h:68
static void uint32_t
spi_device_handle_t handle