ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
daikin_madoka.h
Go to the documentation of this file.
1#pragma once
2
3#ifdef USE_ESP32
4
5#include <array>
6#include <span>
7
8#include <esp_gattc_api.h>
9
15
17
18namespace esphome::daikin_madoka {
19
21
22// Deepest backlog is one poll (5) plus each SET command once (4): a command queued again replaces
23// its queued entry, and the readback poll is only queued once the queue has drained
24static constexpr uint8_t QUERY_QUEUE_SIZE = 9;
25
26// BLE service and characteristic UUIDs
27static const espbt::ESPBTUUID MADOKA_SERVICE_UUID = espbt::ESPBTUUID::from_raw("2141e110-213a-11e6-b67b-9e71128cae77");
28static const espbt::ESPBTUUID NOTIFY_CHARACTERISTIC_UUID =
29 espbt::ESPBTUUID::from_raw("2141e111-213a-11e6-b67b-9e71128cae77");
30static const espbt::ESPBTUUID WWR_CHARACTERISTIC_UUID =
31 espbt::ESPBTUUID::from_raw("2141e112-213a-11e6-b67b-9e71128cae77");
32
33struct Query {
34 uint16_t cmd;
36};
37
39 public:
40 void update() override;
41 void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
42 esp_ble_gattc_cb_param_t *param) override;
43 void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) override;
44 void dump_config() override;
70
71 protected:
72 void control(const climate::ClimateCall &call) override;
73
74 void enqueue_query_(uint16_t cmd, std::span<const uint8_t> args);
75 void send_next_query_();
76 bool write_query_(const Query &query);
77 void process_incoming_chunk_(std::span<const uint8_t> chunk);
78 void parse_cb_(std::span<const uint8_t> msg);
80 void fail_connection_(const LogString *reason);
81
84 uint16_t notify_handle_{0};
85 uint16_t wwr_handle_{0};
86 uint8_t device_mode_{0};
87 bool power_on_{false};
88 // True while the query timeout is armed to pace the next send
89 bool query_cooldown_{false};
90 // A poll waits for the queue to drain, so it runs after any SET command ahead of it
91 bool poll_pending_{false};
92 // The last command written was a GET, so its reply may still be arriving
93 bool get_in_flight_{false};
94
95 static constexpr uint32_t QUERY_TIMEOUT_ID = 0;
96 static constexpr uint32_t PUBLISH_TIMEOUT_ID = 1;
97};
98
99} // namespace esphome::daikin_madoka
100
101#endif
This class simplifies creating components that periodically check a state.
Definition component.h:532
Fixed-size circular buffer with FIFO semantics and iteration support.
Definition helpers.h:408
This class is used to encode all control actions on a climate device.
Definition climate.h:31
ClimateDevice - This is the base class for all climate integrations.
Definition climate.h:192
void set_visual_max_temperature(float visual_max_temperature)
void add_feature_flags(uint32_t feature_flags)
void set_visual_temperature_step(float temperature_step)
void set_visual_min_temperature(float visual_min_temperature)
void set_supported_modes(ClimateModeMask modes)
void set_supported_fan_modes(ClimateFanModeMask modes)
void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) override
StaticRingBuffer< Query, QUERY_QUEUE_SIZE > query_queue_
void enqueue_query_(uint16_t cmd, std::span< const uint8_t > args)
void control(const climate::ClimateCall &call) override
climate::ClimateTraits traits() override
static constexpr uint32_t QUERY_TIMEOUT_ID
bool write_query_(const Query &query)
void process_incoming_chunk_(std::span< const uint8_t > chunk)
void fail_connection_(const LogString *reason)
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 parse_cb_(std::span< const uint8_t > msg)
static constexpr uint32_t PUBLISH_TIMEOUT_ID
Reassembles notifications (one chunk id byte followed by payload) into a message.
@ CLIMATE_SUPPORTS_TWO_POINT_TARGET_TEMPERATURE
@ CLIMATE_SUPPORTS_CURRENT_TEMPERATURE
@ CLIMATE_REQUIRES_TWO_POINT_TARGET_TEMPERATURE
@ CLIMATE_MODE_DRY
The climate device is set to dry/humidity mode.
@ CLIMATE_MODE_FAN_ONLY
The climate device only has the fan enabled, no heating or cooling is taking place.
@ CLIMATE_MODE_HEAT
The climate device is set to heat to reach the target temperature.
@ CLIMATE_MODE_COOL
The climate device is set to cool to reach the target temperature.
@ CLIMATE_MODE_HEAT_COOL
The climate device is set to heat/cool to reach the target temperature.
@ CLIMATE_MODE_OFF
The climate device is off.
@ CLIMATE_FAN_MEDIUM
The fan mode is set to Medium.
@ CLIMATE_FAN_AUTO
The fan mode is set to Auto.
@ CLIMATE_FAN_LOW
The fan mode is set to Low.
@ CLIMATE_FAN_HIGH
The fan mode is set to High.
static void uint32_t